Ywa Posted July 3, 2010 Share Posted July 3, 2010 Hi guys, I tried to generate delphi headers with Wchris his tools and tried to PM him (no answer yet). But I bet there are a few couple more Delphi experts here who could help me out. Whenver I try to compile LeadWerks.pas I get around 15 times the same compilation error, which is: [DCC Error] E2026 Constant expression expected. It happens on lines which contain a PAnsiChar constant. Specifically the ones with a ='VALUE' behind it. Removing these does make the sourcecode compile, but it's not a good solution since it removes the default values. procedure LESetEntityKey ( entity:TEntity; hkey:PAnsiChar; hvalue:PAnsiChar='1' ); stdcall; external ENGINE_DLL name 'SetEntityKey'; Also, I don't know if it's related to this. But my test application also gives a can't open scripts/class error when I load a scene. And a crash (not related to the scene loading) on application close related to atioglxx.dll (Win7 x64, HD4870 with Catalyst drivers 10.3) Any help with this would be great. - Ywa Quote Link to comment Share on other sites More sharing options...
ZioRed Posted July 5, 2010 Share Posted July 5, 2010 For the error message box loading a scene you probably forgot to copy the Scripts folder into your compilation folder (if you don't set the LE folder as abstract path then you need to copy into your compilation folder at least the models and materials of the lights I think). Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Ywa Posted July 5, 2010 Author Share Posted July 5, 2010 Ah thanks. That fixes the error box (I use abstract stuff now). However, I still get a crash as soon as I close my application. Quote Link to comment Share on other sites More sharing options...
Wchris Posted July 15, 2010 Share Posted July 15, 2010 Ah thanks. That fixes the error box (I use abstract stuff now). However, I still get a crash as soon as I close my application. Hi Ywa, I was away ant did not get a mail notification of your pm, just answered. Welcome PS : i do not provide official support, i just updated Lupin's converter for my personnal use and share what i've done. But the generator is opensource (for the community members) so feel free to implement features and share. (I however converted it to Lazarus/freepascal, so you'll have to update the dfm for delphi, but this should be pretty easy.) Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Wchris Posted July 15, 2010 Share Posted July 15, 2010 Hi guys, I tried to generate delphi headers with Wchris his tools and tried to PM him (no answer yet). But I bet there are a few couple more Delphi experts here who could help me out. Whenver I try to compile LeadWerks.pas I get around 15 times the same compilation error, which is: [DCC Error] E2026 Constant expression expected. It happens on lines which contain a PAnsiChar constant. Specifically the ones with a ='VALUE' behind it. Removing these does make the sourcecode compile, but it's not a good solution since it removes the default values. procedure LESetEntityKey ( entity:TEntity; hkey:PAnsiChar; hvalue:PAnsiChar='1' ); stdcall; external ENGINE_DLL name 'SetEntityKey'; I checked this issue at work, my Delphi 2007 does not allow PansiChar parameter assignation and i get the same error. C++ en Freepascal support it. I'll try to workarond this limitation using AnsiString (handled internally as a PansiChar anyway, but allowing assignation. The PascalTypes.txt template needs an update anyway, because since LE 2.32R5 the engine.h header uses a new custop datatype 'const_str' and the generator is unable to guess it's meaning. so update you're LE to the latest 2.38 and replace the PascalTypes.txt template by the attached one. i'll update the generator later if you tell me the problem is solved. Also, I don't know if it's related to this. But my test application also gives a can't open scripts/class error when I load a scene. And a crash (not related to the scene loading) on application close related to atioglxx.dll (Win7 x64, HD4870 with Catalyst drivers 10.3) Any help with this would be great. - Ywa Huh , i have a nvidia card ... and no problem. sorry on this one. what i can do is send you an executable compiled with freepascal that runs without errors on my nvidia machine to see how it runs on yours. PascalTypes.txt Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted July 15, 2010 Author Share Posted July 15, 2010 Thanks Wchris. Already managed to get it compiling, but my method caused some instability with those functions. So I'll try your PascalTypes.txt method instead. Would be great indeed if you can compile a Delphi test project that works fine on yours. - Ywa Quote Link to comment Share on other sites More sharing options...
Canardia Posted July 15, 2010 Share Posted July 15, 2010 In PascalTypes.txt byte=Pointer is wrong, it should be either byte*=Pointer or byte=Byte. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Wchris Posted July 16, 2010 Share Posted July 16, 2010 In PascalTypes.txt byte=Pointer is wrong, it should be either byte*=Pointer or byte=Byte. True, this is an heritage from the original converter, but since there is no BYTE and only BYTE* in the engine.h i did not bother so far. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Wchris Posted July 16, 2010 Share Posted July 16, 2010 Thanks Wchris. Already managed to get it compiling, but my method caused some instability with those functions. So I'll try your PascalTypes.txt method instead. Would be great indeed if you can compile a Delphi test project that works fine on yours. - Ywa Hi Ywa I'm at work for now, did you try it already ? It could be could be cool to post your source code that generates the instability also. If you just started coding it should not be too big. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted July 16, 2010 Author Share Posted July 16, 2010 Well, I regenerated the Leadwerks.pas file. And it compiles ok now. Didn't test any functions which utilize the AnsiString-type yet. For the crash. I basically get it with your SimpleFWExample code. And even a stripped down version of it. I could send you the exe, but the path of our LE installations may vary.. so that would not work anyways. Guess it's an ATi + Delphi problem then. I might move to C++ anyways. Thanks for now. Quote Link to comment Share on other sites More sharing options...
Wchris Posted July 17, 2010 Share Posted July 17, 2010 Well, I regenerated the Leadwerks.pas file. And it compiles ok now. Didn't test any functions which utilize the AnsiString-type yet. For the crash. I basically get it with your SimpleFWExample code. And even a stripped down version of it. I could send you the exe, but the path of our LE installations may vary.. so that would not work anyways. Guess it's an ATi + Delphi problem then. I might move to C++ anyways. Thanks for now. Even with SimpleFWExample ? i'm clueless, will have to buy me an ati card Here is my executable SimpleFWExample.zip compiled with freepascal, can you try it please ? Is you LE SDK located in C:\Program Files\Leadwerks Engine SDK and updated to 2.32 ? A quick google search shows that 10.3 is not the latest ati driver, maybe you could also try to update the driver. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted July 17, 2010 Author Share Posted July 17, 2010 Well, mine is in H:\Leadwerks Engine SDK (can't move it to C:\ ). I copied some of the directories to the SimpleFWExample folder. And it runs fine. But when I shutdown I get a lot Access Violations in the console. So it's a bit different. Yes I know it's not the latest driver. But it's seems it's more a Delphi problem since other LE templates (C++ for example) work fine. Quote Link to comment Share on other sites More sharing options...
Wchris Posted July 17, 2010 Share Posted July 17, 2010 Well, mine is in H:\Leadwerks Engine SDK (can't move it to C:\ ). I copied some of the directories to the SimpleFWExample folder. And it runs fine. But when I shutdown I get a lot Access Violations in the console. So it's a bit different. Yes I know it's not the latest driver. But it's seems it's more a Delphi problem since other LE templates (C++ for example) work fine. Delphi is reported to have problems setting the Floating point unit that can generate A/V with opengl and newton. This is not a pure delphi problem but more a compiler compatibility problem when the main program is compiled with one compiler and the dll with another like explained here http://www.axiworld.be/vst_vcl.html at the end of the leadwerks.pas header you'll find a line trying to adress this issue for previous dephi versions Set8087CW(Default8087CW or $133F); but many google hits disagree on the value to apply $3F £13F $1332 $133F ? the control word bits are like this http://www.efg2.com/Lab/Library/Delphi/MathFunctions/FPUControlWord.Txt and here are some other links http://docwiki.embarcadero.com/CodeSamples/en/Set8087CW_(Delphi) and here http://www.efg2.com/Lab/Library/Delphi/Graphics/Resources.htm you could experiment with these values (with 'Default8087CW or' or directly with the value) , it's my best guess. (or maybe delphi 2010 does not require this anymore ? and remove it) mayself i had to add the command SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); to avoid freepascal crashing with newton.dll. here's a newtom forum thread where they use my solution for FPC http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=5571&start=15. This problem is not visible with common dlls, but 3D dll use intensive floating point maths. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted July 24, 2010 Author Share Posted July 24, 2010 Wchris, I tried to use the GetEntityKey function in Delphi, but it gives an A/V in engine.dll. GetEntityKey uses a AnsiString with assignation. So I guess that doesn't fix it. Got any other ideas? Edit: Got a work-around. Simply use PAnsiChar without a default value assigned to it. Kinda sucks, but it works. Quote Link to comment Share on other sites More sharing options...
Wchris Posted July 24, 2010 Share Posted July 24, 2010 Wchris, I tried to use the GetEntityKey function in Delphi, but it gives an A/V in engine.dll. GetEntityKey uses a AnsiString with assignation. So I guess that doesn't fix it. Got any other ideas? Edit: Got a work-around. Simply use PAnsiChar without a default value assigned to it. Kinda sucks, but it works. Hi again. Glad to see you did not give up downloaded delphi 2010 trial and got everything running with delphi 2010 too. Without your code it'll be very difficult to help you. GetEntityKey will get you an AV if your entity handle is not correct. i assume, if you want to read a key, then the entity that holds the key is created in the editor and not by code, right ? so how do you retrieve the entity handle ? what's your code to do that ? Edit: still waiting ... what's your timezone ? i'm in gmt+1 Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Wchris Posted July 26, 2010 Share Posted July 26, 2010 Wchris, I tried to use the GetEntityKey function in Delphi, but it gives an A/V in engine.dll. GetEntityKey uses a AnsiString with assignation. So I guess that doesn't fix it. Got any other ideas? Edit: Got a work-around. Simply use PAnsiChar without a default value assigned to it. Kinda sucks, but it works. Well i'll have to go to work now. Too bad, i had time to help you this weekend. i did not understand why you said you have problems with "GetEntityKey uses a AnsiString with assignation" since the modified header i use specifies this : str=PAnsiChar const_str=AnsiString only const_str are changed to ansistring, the result of the function was still a pansichar, so there is no assignation to an ansistring here. if you want to assign the result of the function to an ansistring you can still cast it like this : myvar := Ansistring(Getentitykey(...)), delphi should even do the cast automatically. An Ansistring is actually a pAnsichar with length data at relative negative position of the start pointer, so transmitting a read-pnly constant ansistring to LE as a parameter is possible. but you must use ansistring (and not string or pchar) everywhere in your program because delphi (since version 2009) defaults string to unicode and LE doesn't support unicode, so you must specify ansistring everywhere to specify non-uniccde strings. if only you could share a sample of your code, C++ programmers do that all the time, they post their code when they want help, and don't let others guess what's happening. PS: i have installed a 30 days trial of delphi 2010 to help you, time is running now. i still believe we can find a solution and it's my birthday soon, so maybe i'll get a radeon 5770 nevermind, this is my code, to retrieve teh entity handle with name as ansistring function FindEntityByNameCallback(Entity: TEntity; var extra: ansistring): integer; stdcall; begin if GetEntityKey(Entity, 'Name', '')=trim(extra) then begin extra := IntToSTr(Entity); result := 0; end else result := 1; end; Function FindEntityByName(aValue: ansistring; classes: integer=ENTITY_ALL): TEntity; begin ForEachEntityDo(@FindEntityByNameCallback, @avalue, classes); Result := StrToIntDef(avalue, 0); end; WARNING: never add the callback as a method of an object, you'll get an AV, let it as a standalone procedure Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted August 13, 2010 Author Share Posted August 13, 2010 Bump (sorry for not replying Wchris). I tried it with Lazarus now. And managed to get your example code compile. However, it still gives a crash when I close the application. But it only happens on machines with ATi cards Works fine on nVidia machines. Here're the files I send to the testers: http://www.xoti.net/stuff/uploads/MelonSurvivalLazarus_234e.rar Sourcecode is basically your example from the downloads section. Quote Link to comment Share on other sites More sharing options...
Wchris Posted August 13, 2010 Share Posted August 13, 2010 Bump (sorry for not replying Wchris). I tried it with Lazarus now. And managed to get your example code compile. However, it still gives a crash when I close the application. But it only happens on machines with ATi cards Works fine on nVidia machines. Here're the files I send to the testers: http://www.xoti.net/stuff/uploads/MelonSurvivalLazarus_234e.rar Sourcecode is basically your example from the downloads section. Only ATI ... hmmm ... just buyed me an NVidia GTX 460 for my birthday ... i was hesitating between ATI and Nvidia, maybe i would have choosen an ATI to see your problem but now it'll be difficult to reproduce without the hardware. I'll look at your code tomorrow. I have an old machine with an ATI X1950 but i don't think it can run leadwerks. EDIT: Ok tryed it immediately, runs smoothly on my nvidia. But you did not provide the sourcecode. is it still the same ATI 4870, what other ATI cards did you test ? A quick forum search shows that other people report problems with ATI 10.3 driver and 4870 http://leadwerks.com/werkspace/index.php?/topic/1587-problems-with-the-new-103-ati-drivers/page__p__14731__hl__%2Bati+%2Bcrash__fromsearch__1#entry14731 Unfortunately not everybody encounters the problem, so it seems random. Some people say clearing drivers and reinstalling helped. Also, can you please post the engine.log file from the machine where the problem occurs ? maybe i'll see something strange in there if i compare to mine. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted August 14, 2010 Author Share Posted August 14, 2010 I tested it with a HD4850 and HD4870 with latest drivers. I'll ask a few others about the latest series (HD5xxx). And the problem is just that application terminate/close crash (and it only happens with the Delphi and Lazarus editions). Everything else works fine. Here's the source code: http://www.xoti.net/stuff/uploads/MelonSurvivalLazarusSRC_1f7d.rar Engine.log seems to stay at 0 kb all the time. So I basically have no log. Edit: Also happens on AMD/ATi HD5850 mobility card. Quote Link to comment Share on other sites More sharing options...
Wchris Posted August 14, 2010 Share Posted August 14, 2010 I tested it with a HD4850 and HD4870 with latest drivers. I'll ask a few others about the latest series (HD5xxx). And the problem is just that application terminate/close crash (and it only happens with the Delphi and Lazarus editions). Everything else works fine. Here's the source code: http://www.xoti.net/stuff/uploads/MelonSurvivalLazarusSRC_1f7d.rar Engine.log seems to stay at 0 kb all the time. So I basically have no log. Edit: Also happens on AMD/ATi HD5850 mobility card. WOAW Incredible ! my old X1950 pro with an athlon 3000+ and catalyst 7.7 did not want to run your melonsurvival demo. Then i upgraded to the catalyst 10.2 (the latest available for X1950) And it works !!! no problem, no AV, no crash and 50 FPS !!! more than my 8600GS where i only get 40fps ! That's crazy ! I just ran your MSL.exe and did not change anything. Why did you not bump back before !!! i would have buyed me an ati if y would have seen this happen ! Well it won't help you much if i still cannot reproduce your bug. What catalyst version do you have ? still 10.3 ? Any chance you could make a try to go back to 10.2 ? the guy here http://leadwerks.com/werkspace/index.php?/topic/1587-problems-with-the-new-103-ati-drivers/page__p__14731__hl__%2Bati+%2Bcrash__fromsearch__1#entry14731 also said his problem went away with 10.2 EDIT: For the log file i have the same problem as you on my X1950 pro machine, empty log file; but on my nvidia machine the same program MSL.exe generates a correct log file ! That's weird ! the log file is not generated by code, it's directly created by leadwerks engine.dll without anything to do. Hey ! if it's the log file that makes me loose 10 FPS on my 8600GS i'll have to try to disable this !! ROFL ! Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted August 14, 2010 Author Share Posted August 14, 2010 I'm at 10.6 currently (others aswell). Downgrading won't help a lot, since it's a Delphi/FPC specific problem. Since I don't got any problems with with Leadwerks C++ project (unlike the guy from the other thread/topic). Quote Link to comment Share on other sites More sharing options...
Wchris Posted August 14, 2010 Share Posted August 14, 2010 I'm at 10.6 currently (others aswell). Downgrading won't help a lot, since it's a Delphi/FPC specific problem. Since I don't got any problems with with Leadwerks C++ project (unlike the guy from the other thread/topic). Hmm strange, i'm stuck in 10.2 on my X1950 pro machine, but i'll do more tests because this empty engine.log is really strange, maybe i'll find something if i search what's happening there. I'll be busy this afternoon, but i'll have more time this evening or tomorrow. I'll PM you if i find something. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted August 14, 2010 Author Share Posted August 14, 2010 Wchris. I think it's my Leadwerks.pas which is bugged! Your SimpleFWExample.exe from post #11 works perfectly on my machine! Quote Link to comment Share on other sites More sharing options...
Wchris Posted August 15, 2010 Share Posted August 15, 2010 Wchris. I think it's my Leadwerks.pas which is bugged! Your SimpleFWExample.exe from post #11 works perfectly on my machine! The only difference between your header and mine is String vs AnsiString. You must be carefull with this because default string type is not compatible with C++ Pchar, you must either specify AnsiString or set the compiler to translate them to AnsiString for you like this Sorry i'll be out for two days because my wife prepared something for my birthday, so i'll not have much more time to investigate until tuesday. I just hope i'll be more helpfull on tuesday. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Ywa Posted August 15, 2010 Author Share Posted August 15, 2010 Hm, I fixed the AnsiString stuff and it still happens. Anyways, I kinda prevented it from happening by killing the process before shutting down. Will look into it later. Thanks for all the help and enjoy your birthday. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.