lazarus for a 3d game lazarus / 39-Graphics ---------------------------------------------------------------------- laggyluk · 2012-11-19 22:13 Hi guys. I'd like to make a 3D game in Lazarus. I don't know opengl yet but that's one of reasons for making it 3d. It's a voxel based game so I recon I don't need sophisticated 3d engine, just some painless access to opengl surface and I'll figure out how to build and draw those meshes. Now, is lazarus any good for this? I'd really like to use pascal for this project but after some searching I've found that most  resources are for old 2.1 opengl/ in russian/ won't compile Should forget my pascal sympathy and just get back to c++ or is there some working solution that I've missed? ---------------------------------------------------------------------- Blaazen · 2012-11-20 00:09 Hi and welcome, I personally have no experience with OpenGL. Anyway, I am a long time on this forum so I know that ZenGL is used for (commercial) games: http://zengl.org/ One year ago someone gave here bindings to Horde3D: http://www.lazarus .freepascal.org/index.php/topic,13573.msg71016.html#msg71016 Also, Kambi VRML is here: http://forum.lazarus.freepascal.org/index.php?topic=13729.0 (I don't know what version is up to date). Last but not least, look at this web: http://www.pascalgamedevelopment.com/content.php ---------------------------------------------------------------------- irfanbagus · 2012-11-20 05:21 if you need to stick with opengl directly (without any 3d engine) you have many choices. you can use TOpenGlControl, and you can mix with other lazarus control (button,edit,etc). or if don't need lcl component, you can use sdl,(free)glut,glfw,ect to handle window and input. for up to date opengl headers you could try dglOpenGL. QuoteShould forget my pascal sympathy and just get back to c++ or is there some working solution that I've missed?based on my experience while learning opengl, it does not metter what language you chose. i do learn in pascal but all my example source code are in c and few of them in java (for android). you can copy c source code and with minimum changes it will run in pascal. ---------------------------------------------------------------------- Leledumbo · 2012-11-20 06:23 You have quite a lot of choices in Pascal for 3D games: Castle Game EngineSDLCast IInxPascaland many more (google up yourself). QuoteShould forget my pascal sympathy and just get back to c++ or is there some working solution that I've missed?It's up to you, using direct OpenGL won't differ much between languages. It's the language dependent features that you'll miss when you use another language. Decide yourself. For me, I will never pick C++ anymore if I'm not forced to. A lot of error detections don't exist, not even at runtime (your program will only crash or misbehave without any clear reason). ---------------------------------------------------------------------- Wodzu · 2012-11-20 06:35 Since I like to do all by myself (which is tedious task sometimes that is why people came up with 3D engines after all  ) I can recommend you this site: http://www.freepascal-meets-sdl.net/ As for examples for OpenGL, here is a good site: http://nehe.gamedev.net/ It has examples in Delphi so you will be able to translate them to Free Pascal. However, as guys mentioned - it is easy to translate examples from other languages to Pascal and FPC is totally capable of making a 3D game. You will probably also need a Vampyre Imaging Library (it has some OpenGL examples too): http://imaginglib.sourceforge.net/ Good luck:) ---------------------------------------------------------------------- avra · 2012-11-20 08:06 You might want to explore Lazarus CodeTyphon edition, since it already comes with some of the mentioned 3D engines and has many examples. ---------------------------------------------------------------------- mariuz · 2012-11-20 11:01 Quote from: laggyluk on November 19, 2012, 11:13:13 pmHi guys. I'd like to make a 3D game in Lazarus. I don't know opengl yet but that's one of reasons for making it 3d. It's a voxel based game so I recon I don't need sophisticated 3d engine, just some painless access to opengl surface and I'll figure out how to build and draw those meshes. Now, is lazarus any good for this? I'd really like to use pascal for this project but after some searching I've found that most  resources are for old 2.1 opengl/ in russian/ won't compile Should forget my pascal sympathy and just get back to c++ or is there some working solution that I've missed? There are full opengl 4.3 headers for pascal if you want advanced opengl http://www.pascalgamedevelopment.com/content.php?262-Delphi-Object- Pascal-OpenGL-4-2-Headers-Released http://wiki.delphigl.com/index.php/dglOpenGL.pas/en As for game engines there are a few enumerated before on this thread ---------------------------------------------------------------------- laggyluk · 2012-11-22 19:23 thanks for all the replies. I didn't find any basic example of setting up programmable pipeline in pascal but managed to craft it using dglOpenGL.pas, some old tut and modern c++ ,now can see a colorful triangle ---------------------------------------------------------------------- laggyluk · 2012-11-27 13:55 so far so good. i have a small problem though: in  OnClose event I'm calling these function as found in dlg tutorial Code: [Select] DeactivateRenderingContext;  DestroyRenderingContext(RC);  ReleaseDC(Handle, DC); and app freezes on DestroyRenderingContext. Any ideas why? I can just comment this line out and then it closes  but still.. ---------------------------------------------------------------------- Leledumbo · 2012-11-27 14:51 I'm not sure whether it's a good idea to call at OnClose, as maybe the RC is already invalid (CMIIW). ---------------------------------------------------------------------- laggyluk · 2012-11-27 22:26 in tutorial it was OnDestroy but also results in freeze. If i launch the exe not through debugger it closes normally ---------------------------------------------------------------------- Leledumbo · 2012-11-27 22:35 Quotein tutorial it was OnDestroy but also results in freeze. If i launch the exe not through debugger it closes normallyIt's debugger problem then, not your application. ---------------------------------------------------------------------- User137 · 2012-11-28 05:01 Are you using LazOpenGLContext? It makes it so much easier, because it's automatically destroyed. If you use dglOpenGL with it, just call Code: [Select]InitOpenGL; ReadExtensions; ReadImplementationProperties;in the formCreate. ---------------------------------------------------------------------- laggyluk · 2012-11-28 19:06 Quote from: User137 on November 28, 2012, 06:01:34 amAre you using LazOpenGLContext? It makes it so much easier, because it's automatically destroyed. If you use dglOpenGL with it, just call Code: [Select]InitOpenGL; ReadExtensions; ReadImplementationProperties;in the formCreate. no, i'm just assigning panel handle to the context:   DC:= GetDC(panel1.handle);   if not InitOpenGL then Application.Terminate;   RC:=CreateRenderingContext(DC,[opDoubleBuffered],32, 24, 0,0,0, 0);   ActivateRenderingContext(DC, RC);