smateja Posted September 5, 2010 Share Posted September 5, 2010 Hi @ all, first sorry about my bad english - i will try.... i try to use Leadwerks Engine with PureBasic - and i have a little Problem with. 1. TFramework needs a Structure - don´t know atm how to fix this. 2. When i use graphics command it shows up correclty - but want responding - if i use apptitel command - nothing appears .... so on - i will show you - maybe someone can use this for himself... plz help me to get it work - thanks a lot. code.txt Quote Link to comment Share on other sites More sharing options...
Ywa Posted September 5, 2010 Share Posted September 5, 2010 What's your game code at this moment (initialization and such)? - Ywa Quote Link to comment Share on other sites More sharing options...
Wchris Posted September 6, 2010 Share Posted September 6, 2010 Hi @ all, first sorry about my bad english - i will try.... i try to use Leadwerks Engine with PureBasic - and i have a little Problem with. 1. TFramework needs a Structure - don´t know atm how to fix this. 2. When i use graphics command it shows up correclty - but want responding - if i use apptitel command - nothing appears .... so on - i will show you - maybe someone can use this for himself... plz help me to get it work - thanks a lot. Hi Smateja, Your post is a bit long and truncated in the end. Could you remove the code and add it in an attached zip file ? it'll be easyer to read (forum has scrolling problems with big texts). Thanks I'll go at work and this evening i'll try to see if i can convert the delphi/freepascal SimpleFWsample i have posted in the download section to purebasic. I have only the trial version of purebasic (limited to 800 lines of code) but if i extract from the header all unused procedures i may succed in compiling. There was an old thread here http://leadwerks.com/werkspace/index.php?/topic/955-any-headers/page__p__8619__hl__purebasic__fromsearch__1#entry8619 where Paul successfully succeeded in running a minimal LE application with purebasic. But he didn't plan to use PB himself so i decided we would wait until a true PB users asks for it and return to our own game. Now that you're here i think we can resume PS: (please don't tell me you changed your mind and want to use C++, because it would disapoint me and i would stop again ) 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...
smateja Posted September 6, 2010 Author Share Posted September 6, 2010 Code is now working, maybe a little buggy and can be a lot of optimized - i updated the attachment. I only have a problem with the tframework structure - then it´s done. Greetings PPS to Wchris: no no - i will stay at pb. C++ is to complex at this time for me. Quote Link to comment Share on other sites More sharing options...
Wchris Posted September 6, 2010 Share Posted September 6, 2010 Code is now working, maybe a little buggy and can be a lot of optimized - i updated the attachment. I only have a problem with the tframework structure - then it´s done. Greetings Sorry if i'm slow, i'm learning purebasic this code generated by the header generator is probably wrong Prototype.TFramework LECreateFramework ( ) should be Prototype.i LECreateFramework ( ) because TFramework=.i is missing at the end of the template PureBasicTypes.txt you don't need the générated macros ? PS and this damn trial version say i'm allowed to 800 lines, and finally won't let me have more then about 600 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 September 6, 2010 Share Posted September 6, 2010 Ok i think i reached my purebasic limits and need some help the stripped out purebasic sample attached crashes when Lua_pushobject command tries to access the fw memory address (read error at address 12). I don't know what's wrong with my PB pointer and i need help from purebasic programmers source code SimpleFWExample.zip 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...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 What's your game code at this moment (initialization and such)? - Ywa mmhm - there is no game code there *G - only initialisation things. Quote Link to comment Share on other sites More sharing options...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 (edited) Ok i think i reached my purebasic limits and need some help the stripped out purebasic sample attached crashes when Lua_pushobject command tries to access the fw memory address (read error at address 12). I don't know what's wrong with my PB pointer and i need help from purebasic programmers source code SimpleFWExample.zip Try this in combination with my first attachment in this post: LESetAppTitle("Test") LEGraphics(640,480) LECreateWorld() fw = LECreateFramework() If fw>0 Lua = LEGetLuaState() LElua_pushobject(Lua, fw) LElua_setglobal(Lua,"fw") LElua_pop(Lua, 1); EndIf I have tested it and it will work fine. No need for the @. Edited September 7, 2010 by smateja Quote Link to comment Share on other sites More sharing options...
Paul Posted September 7, 2010 Share Posted September 7, 2010 I know I did it myself, but the Vec* functions shouldn't return the address of a local variable. Use static or dynamically allocate memory. Quote Intel Core i7 975 @ 3.33GHz, 6GB ram, GTX 560 Super OC, Windows 7 Pro 64bit Link to comment Share on other sites More sharing options...
Wchris Posted September 7, 2010 Share Posted September 7, 2010 I know I did it myself, but the Vec* functions shouldn't return the address of a local variable. Use static or dynamically allocate memory. Interresting. Do you have a little sample of code for this ? 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 September 7, 2010 Share Posted September 7, 2010 Try this in combination with my first attachment in this post: LESetAppTitle("Test") LEGraphics(640,480) LECreateWorld() fw = LECreateFramework() If fw>0 Lua = LEGetLuaState() LElua_pushobject(Lua, @fw); LElua_setglobal(Lua, "fw"); LElua_pop(Lua, 1); EndIf I have tested it and it will work fine. The only différence with my code is that you create a world, wich is not necessary when using framework. maybe i crash because eof my trial version, or because it's an old 4.31 ? hmm ... i forgot the bracket () with LEGetLuaState ... maybe it's the problem ? will try this evening LERegisterAbstractPath("C:\Program Files\Leadwerks Engine SDK"); LESetAppTitle("SimpleFWexample") If LEGraphics(640,480)>0 fw = LECreateFramework() If fw>0 Lua = LEGetLuaState LElua_pushobject(Lua, @fw); LElua_setglobal(Lua, "fw"); LElua_pop(Lua, 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...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 By the way - u can use xincludefile in Purebasic... in engine.pb - the code for the functions macros and so on.... The main programm file looks then like: XIncludeFile ("engine.pb") LESetAppTitle("Test") LEGraphics(640,480) LECreateWorld() framework = LECreateFramework() If framework>0 Lua = LEGetLuaState() LElua_pushobject(Lua,framework) LElua_setglobal(Lua,"framework") LElua_pop(Lua, 1) EndIf Repeat LEDrawText("Hello World!",32,32) LEUpdateWorld() LERenderWorld() LEFlip() Until Quit = 1 Or LEAppTerminate() Quote Link to comment Share on other sites More sharing options...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 The only différence with my code is that you create a world, wich is not necessary when using framework. maybe i crash because eof my trial version, or because it's an old 4.31 ? hmm ... i forgot the bracket () with LEGetLuaState ... maybe it's the problem ? will try this evening LERegisterAbstractPath("C:\Program Files\Leadwerks Engine SDK"); LESetAppTitle("SimpleFWexample") If LEGraphics(640,480)>0 fw = LECreateFramework() If fw>0 Lua = LEGetLuaState LElua_pushobject(Lua, @fw); LElua_setglobal(Lua, "fw"); LElua_pop(Lua, 1); I have tested it without the createworld command - will run without errors. Attention - the difference ist the @ - symbol in my code, also there is no need for the ; at the line end - this ist pascal statemante or delphi i think. try this : LElua_pushobject(Lua, fw) Quote Link to comment Share on other sites More sharing options...
Wchris Posted September 7, 2010 Share Posted September 7, 2010 By the way - u can use xincludefile in Purebasic... in engine.pb - the code for the functions macros and so on.... i don't understand . do you have a sample for this ? (sorry i'm nearly a newbie if pb ) try removing your createworld, updateworld, renderworld commands and replace them by UpdateFramework; RenderFramework; i'm at work now, can't try myself until this evening 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...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 arg - sorry - i found an error in my code in the line LElua_setglobal(Lua,"Framework") <- this is false corrected code: XIncludeFile ("hwengine.pb") LERegisterAbstractPath(GetCurrentDirectory()) LESetAppTitle("Test") LEGraphics(640,480) framework = LECreateFramework() If framework>0 Lua = LEGetLuaState() LElua_pushobject(Lua,framework) LElua_setglobal(Lua, ""+Str(framework)) LElua_pop(Lua, 1) EndIf Repeat LEDrawText("Hello World!",32,32) LEUpdateWorld() LERenderWorld() LEFlip() Until Quit = 1 Or LEAppTerminate() Quote Link to comment Share on other sites More sharing options...
Wchris Posted September 7, 2010 Share Posted September 7, 2010 your code does still not use UpdateFramework; RenderFramework; so you create the framework but you don't use it UpdateFramework; RenderFramework; call updateworld and renderworld internaly 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...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 your code does still not use UpdateFramework; RenderFramework; so you create the framework but you don't use it UpdateFramework; RenderFramework; call updateworld and renderworld internaly okay.... XIncludeFile ("hwengine.pb") LERegisterAbstractPath(GetCurrentDirectory()) LESetAppTitle("Test") LEGraphics(640,480) framework = LECreateFramework() If framework>0 Lua = LEGetLuaState() LElua_pushobject(Lua,framework) LElua_setglobal(Lua, ""+Str(framework)) LElua_pop(Lua, 1) EndIf Repeat LEDrawText("Hello World!",32,32) LEUpdateFramework() LERenderFramework() LEFlip() Until Quit = 1 Or LEAppTerminate() runs - and shows the framerate - don´t know why - and don´t show the draw text text - because of the fps? Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 7, 2010 Share Posted September 7, 2010 well it shows FPS because thats the default in LE when using framework. You would have to set the SetStats() to a zero to remove it... and all 2D elements like text and images should be done right before the Flip and after the update and render... so it should look like this: Repeat LEUpdateFramework() LERenderFramework() LEDrawText("Hello World!",32,32) LEFlip() Until Quit = 1 Or LEAppTerminate() Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Wchris Posted September 7, 2010 Share Posted September 7, 2010 runs - and shows the framerate - don´t know why - and don´t show the draw text text - because of the fps? Framework does plenty of cool stuff (mainly postfilters effects) and uses Set.. commands to activate the features like SetStats, SetBloom, etc ... The drawtext does not work because the 3D scene is drawn by Renderframework on top of it. Main Leadwerks loop is always like this 1) get inputs and move 3D objects 2) update the entity positions in the world 3) render the world 4) draw additionnal 2D on top 5) flip background buffer at this point you could use loadscene before the loop and load one of your sbx file you made with the editor, it should display like in the editor if the camera is well positionned. unless you are very skilled, always use framework commands instead of world commands because framework already uses world commands for you, and you would simply end up rewriting framework and would not benefit from changes or new fetures Josh may add to the framework. 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...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 Update okay - works also fine - shows full stats etc. but only shows a black screen - maybe the graphiccard drivers @ my work pc seems to be broken - i will try this @ home this evening XIncludeFile ("hwengine.pb") LERegisterAbstractPath(GetCurrentDirectory()) LESetAppTitle("Test") LEGraphics(640,480) ;LECreateWorld() framework = LECreateFramework() If framework>0 Lua = LEGetLuaState() LElua_pushobject(Lua,framework) LElua_setglobal(Lua, ""+Str(framework)) LElua_pop(Lua, 1) EndIf LESetBackgroundMode(1) LESetStats(2) mesh=LECreateCube() light=LECreateSpotLight() LESetFarDOF(1) LESetFarDOFStrength(1) LESetFarDOFRange(1.5, 5) LESetGodRays(1) ;LESetSSAO(1) ;LESetAntialias(1) Repeat LETurnEntity(mesh,Vec3(0.5)) LETurnEntity(light,Vec3(-0.25)) LEUpdateFramework() LERenderFramework() LEFlip() Until Quit = 1 Or LEAppTerminate() LEFreeFramework(framework) Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 7, 2010 Share Posted September 7, 2010 your camera is inside the cube... either move the cube forward a couple of meters or move the camera back a couple of meters... and CreateSpotLight() needs the range parameter filled out... and also moved because its also currently inside the cube Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Wchris Posted September 7, 2010 Share Posted September 7, 2010 Update okay - works also fine - shows full stats etc. but only shows a black screen - maybe the graphiccard drivers @ my work pc seems to be broken - i will try this @ home this evening you must retrieve the handle of the camera the framework created for you and position it in pascal it would be something like : Camera := GetLayerCamera(GetFrameworkLayer(0)); PositionEntity(Camera, Vec3(0, 0, -2)); you must also call EndRender at the end of your program (i dont know if freeframework does the EndRender) or ati cards owner will have a surprise . 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...
Paul Posted September 7, 2010 Share Posted September 7, 2010 Interresting. Do you have a little sample of code for this ? What do you mean? On the PureBasic forums one of the developers stated returning the address of a local variable is a bad idea. The C++ code returns the structure by value, thereby copying the struct; PureBasic can't do this, atleast not automatically. Quote Intel Core i7 975 @ 3.33GHz, 6GB ram, GTX 560 Super OC, Windows 7 Pro 64bit Link to comment Share on other sites More sharing options...
Wchris Posted September 7, 2010 Share Posted September 7, 2010 What do you mean? On the PureBasic forums one of the developers stated returning the address of a local variable is a bad idea. The C++ code returns the structure by value, thereby copying the struct; PureBasic can't do this, atleast not automatically. Ok i think understood, will replace Protected result by Static Result Thanks (sorry, i'm a bit slow) I have a problem with LEKeyHit(KEY_ESCAPE) does not work. Don't know why yet Here's my curent code if you want to try Edit : OK got it ! i forgot the # in LEKeyHit(#KEY_ESCAPE) The compiler does not complain, he just ignores it ! This behaviour can lead easily to hidden bugs. Is there a way to force him to complain ? 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...
smateja Posted September 7, 2010 Author Share Posted September 7, 2010 Edit : OK got it ! i forgot the # in LEKeyHit(#KEY_ESCAPE) The compiler does not complain, he just ignores it ! This behaviour can lead easily to hidden bugs. Is there a way to force him to complain ? nopes - because the compiler think its an variable without the # by hte way - have you tried the command - LESetSSAO(1) - *G freezes my app 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.