PDA

View Full Version : Lazarus and OpenGL - Help a newbie Please!



theduck
23-01-2005, 04:24 AM
Hi, I am a 14 year old programmer, who has programmed in 6 languages.

I am using the current lazarus win32 build, and the dgl1.5 opengl unit. I need help. Can anybody help me? I am totally lost. I don't need help on
the commands or anything. I copied and pasted a tutorial's code and saved it with the stuff for OpenGL in the same directory. It wont compile.
I get errors. Can anybody help me? Please. I need help fast.


You can get what I have right now here:
http://www.freewebs.com/duckgames/Games/OPENGL_TEST.zip
*You may need to copy+paste in address bar*

Please help me. I have been working 3 days non-stop to get OpenGL to work with Lazarus.

savage
23-01-2005, 12:14 PM
It seems that Lazarus's Windows unit does not containt a definition for "PWGLSwap" which should look something like this..

type
PWGLSwap = ^TWGLSwap;
_WGLSWAP = packed record
hdc: HDC;
uiFlags: UINT;
end;
TWGLSwap = _WGLSWAP;
WGLSWAP = _WGLSWAP;

theduck
23-01-2005, 02:58 PM
Thanks! But where to I put it? :roll:

Sorry to cause any inconvienance, but do you think you can
edit my file, and put it in a .zip and send it to me?
My Email = cdrake4@woh.rr.com
I would really appreciate it if you could. It would help a lot.
I have really been wanting to start OpenGL. I've been trying to
get it to work all day for the past 3 days (We had a snow day on Friday! :D).

Robert Kosek
23-01-2005, 03:34 PM
Ok, open your "windows" unit. Near the top, where the type definitions are put that code in at the top, just under type.

He's doing a good job, I reccommended he come here because I don't know enough! I've been showing him the way at my forums, and got into a few tight spots.

theduck
23-01-2005, 03:47 PM
Ok.... I get the same error....

savage
23-01-2005, 04:21 PM
OK this is probably a silly question, but if you are using FreePascal, why are you using dglOpenGL as your OpenGL interface? dglOpenGL and most demos from Sulaco's site are specifically built for the Delphi compiler. So in order to get it working with FreePascal will take a fair bit of jiggery pokery.

IIRC, FreePascal has it's own set of OpenGL headers. Replace dglOpenGL in your uses clause with, gl, glu and you also need glext in there as well. This change should take place in both your project file and in the texture.pas file. The project will need a few more tweaks before it works. One main issue is that Textures.pas uses the Delphi Graphics unit. You will need to find out which FreePascal unit is its equivalent before proceeding.

Actually I just checked and FreePascal comes with a few OpenGL GLUT based Pascal demos.

theduck
23-01-2005, 04:24 PM
Ok... I am confused now...
But I am using Lazarus compiler with the Lazarus IDE.
No Delphi.

EDIT:Oops... sorry, didn't mean to triple post. :S Don't even know how
I did that!


DOUBLE EDIT: I understand now! I'll google it and ask the Lazarus developers on what the Laz compatible Graphics Unit is. Thanks a lot for your help

savage
23-01-2005, 04:52 PM
Hi Duck,
I should have been more explicit, I should have clarified that the Lazarus IDE uses FreePascal as it's backend compiler. I tend to refer to the compiler rather than the IDE.

Btw, as I am an admin, in these here parts, I decided to delete the the double posts as everything you wanted to say, appeared in the 3rd post.

theduck
23-01-2005, 05:29 PM
Thants ok.
Thanks for deleting my triple post... :roll:

Thanks a lot for your help. I am looking like crazy for the Laz compatible Graphics unit. I have googled and asked on the Lazarus Forum so far. Hopefully I will find it. :D

savage
23-01-2005, 07:59 PM
Looks like someone already tried to create a FreePascal friendly verison of dglOpenGL.pas over @ http://www.delphigl.com/forum/download.php?id=548, you may want to try that if you don't want to use the FPC gl &? glu units, but you will still have the Delphi Graphics reference problem in textures.pas.

savage
23-01-2005, 08:10 PM
Actually I just spotted that over on the Friends for FreePascal site they have a whole OpenGL tutorial @ http://www.friends-of-fpc.org/tutorials/graphics/dlx_ogl/

That may be more usefull as a starting point.

theduck
24-01-2005, 02:32 AM
Yay! It works!

To any starting OpenGL people using Lazarus:
- Switch to FreePascal - http://www.freepascal.org
- Get Dev-Pascal IDE - http://www.bloodshed.net
- Lazarus + OpenGL = A big no-no

It works flawlessly. Just had to switch to FreePascal.

Thanks for the link savage, it helps a lot.

Lightning
25-01-2005, 06:59 PM
I can't understand how can someone swich to FreePascal if they are already using it.
Dev Pascal is made with Delphi and windows only.
Lazarus is THE ONLY Delphi-Like IDE wich is CrossPlatform and supported by the FPC team.
I still don't see what problems did you have with it, you can just compile all FPC projects in Lazarus and i bet i can get OpenGL rendering in a Lazarus window but i like the Delphi3D units included with FPC so i don't get into trouble.