PDA

View Full Version : OpenGL.pas?



IlovePascal
11-04-2007, 12:25 AM
Hello everybody!

I was trying to run one of Nehe's tutorials, and the compiler came accross
uses GLaux;
and in Glaux.pas, it has

uses OpenGL;
Which Lazarus says it cannot find.

I searched my hard drives and could not find anything with the name OpenGL.pas. Where could I get it from?
(I have Lazarus and all the JEDI-SDL stuff as well)

Thanks for ur time!

WILL
11-04-2007, 02:01 AM
If you have JEDI-SDL then the OpenGL headers should be in one of the folders.

Look in 'JEDI-SDLv1.0\OpenGL\Pas' and the file you probably want is gl.pas.

Traveler
11-04-2007, 08:17 AM
Alternatively, you could also try this (http://www.gameprogrammer.net/zip/OpenGl.zip) version.

IlovePascal
12-04-2007, 03:05 AM
If you have JEDI-SDL then the OpenGL headers should be in one of the folders.

Look in 'JEDI-SDLv1.0\OpenGL\Pas' and the file you probably want is gl.pas.
Haha, I didnt'know it waas that simple! haha.

Then why does it say 'uses OpenGL' in the program (that's the translated version to Pascal from Nehe's C++ tuts btw) if what it means is 'uses gl' ?

Anyways thanks, ill go try it out.

And Traveller: the ] I'm sorry, but the page you requested was not found.
Click here to start your journey... [/code] page.
I had a look around the (your?) site and I really like it!
I'll have a look through the tutorials and maybe ask for some help to get something similar to those cool textures and fonts in my game, if you don't mind! :D
Is it your site anyways? well, if it is, jst a tiny little comment: in ur 'tutorial overview', you have 'where' instead of 'were' ! :)

Cheers

savage
12-04-2007, 06:12 AM
If you have JEDI-SDL then the OpenGL headers should be in one of the folders.

Look in 'JEDI-SDLv1.0\OpenGL\Pas' and the file you probably want is gl.pas.
Haha, I didnt'know it waas that simple! haha.

Then why does it say 'uses OpenGL' in the program (that's the translated version to Pascal from Nehe's C++ tuts btw) if what it means is 'uses gl' ?

Delphi ships with OpenGL.pas, while Tom Nuydens did the initial transalation that kept the files the way the C/C++ files are ie gl.pas, glu.pas etc.

Traveler
12-04-2007, 08:02 AM
I had a look around the (your?) site and I really like it!
I'll have a look through the tutorials and maybe ask for some help to get something similar to those cool textures and fonts in my game, if you don't mind! :D
Is it your site anyways? well, if it is, jst a tiny little comment: in ur 'tutorial overview', you have 'where' instead of 'were' ! :)

Cheers

Thanks! I have not made any updates recently, although I might be soon as I have some cool things to show regarding my competition entry.

Most of the graphics you see on my site were made with Lightwave and Photoshop. The letters for example are 3d objects with a wood texture on them.

Thanks for the typo error, I'll fix that with the next update as well.

The link is also fixed, although I take it from your message that it isn't really needed anymore.

IlovePascal
14-04-2007, 08:07 AM
Hey Im back!

I tried changing 'OpenGL' with 'gl' and now that doesn't seem to be a problem anymore! Good!

However, now the compiler complains about the unit Glaux. It doesn't seem to accept the 'export' procedures/functions. I have no idea how 'export' works, or even what 'stdcall' means, so I dont know how to solve this.
Here is some of the Glaux unit, so that u have an idea of what's going on:


unit Glaux;

interface

uses Windows, gl;

type
TAUX_RGBImageRec= record
sizeX, sizeY: integer;
data: pointer;
end;
PTAUX_RGBImageRec= ^TAUX_RGBImageRec;

function auxDIBImageLoadA(const dibfile: PChar): PTAUX_RGBImageRec; stdcall;
procedure auxWireSphere(value: double);stdcall;
procedure auxSolidSphere(value: double);stdcall;
procedure auxWireCube(value: double);stdcall;

(...)

const
glaux1 = 'glaux.dll';

implementation

function auxDIBImageLoadA; external glaux1;
procedure auxWireSphere;external glaux1;
procedure auxSolidSphere;external glaux1;
procedure auxWireCube;external glaux1;

(...)

end.


And the compiler(Lazarus) says:
':' expected but ';' found (at the line 'function auxDIBImageLoadA; external glaux1;')

That is really annoying! What am I supposed to do?


Another problem that I get with one of the tutorials is about some 'dereferencing', which I don't know anything about. I guess it's the opposite of making a refrence by pointer, but how do I 'dereference'?

And to Traveler: I don't think ill need it (I might, if it solves either of the problems above!), bt thanks anyways!

Thanks all for your help ;)

savage
14-04-2007, 08:37 AM
Actually if I remember correctly I did send Nehe quite a few JEDI-SDL compatible ports. Have you tried those instead?

IlovePascal
15-04-2007, 12:04 AM
Actually if I remember correctly I did send Nehe quite a few JEDI-SDL compatible ports. Have you tried those instead?
Oh yep, I hadn't seen that one in the list!

Well, I jst downloaded it and tried to compile it, and here's what Lazarus says about the unit OpenGL12 that it requires:

OpenGL12.pas(2506,5) Error: Incompatible types: got "Pointer" expected " [ procedure variable type of procedure(LongWord, Single);StdCall ] "
at the line

glAccum := GetProcAddress(GLHandle, 'glAccum');
and every line after that in that same procedure has the same error message! lol

So what should I do? haha

And since i always have problems with those 'stdcall' and 'export', could you explain what they do?

Cheers all!

savage
15-04-2007, 01:41 AM
Ok it looks like Nehe does not have the latest version of those demos that work with gl.pas, glu.pas etc.

Could you please have a look here -
http://jedi-sdl.cvs.sourceforge.net/jedi-sdl/JEDI-SDLv1.0/Demos/3D/NeHe/

You will also need to ensure that you have the latest version of gl.pas ( OpenGL12.pas is no longer supported in v1.0 of JEDI-SDL ) etc which can be downloaded from...
http://jedi-sdl.cvs.sourceforge.net/jedi-sdl/JEDI-SDLv1.0/OpenGL/Pas/

stdcall is a Windows function calling convention while cdecl tends to be used on other platforms/operating systems. You can use cdecl on Windows, but most Dlls export their functions using stdcall. If you need further clarification let me know.

IlovePascal
15-04-2007, 03:09 AM
Ok, I made sure I had all the units from OpenGL up-to-date.
I have also downloaded one of the tutorials I was having problems with from the site you mentioned; I will try them soon, and give you feedback. Thanks a lot

IlovePascal
15-04-2007, 07:21 AM
Hey, Im back!

I tested the tutorial 7 from the link you gave.
The issues I had with Glaux are obviously gone, but I still get the same problem as before, at the line

glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage.x,
TextureImage.h, 0, GL_BGR,
GL_UNSIGNED_BYTE, TextureImage.pixels );
I get the error message

lesson7.pas(136,53) Error: Illegal qualifier
lesson7.pas(136,53) Hint: may be pointer dereference is missing
How do I 'derefrence'?????? :evil: :cry:

Thanks again

JSoftware
15-04-2007, 09:04 AM
How do I 'derefrence'?????? :evil: :cry:
Thanks again
@ would be my guess :)

savage
15-04-2007, 10:26 AM
Hey, Im back!


glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage.x,
TextureImage.h, 0, GL_BGR,
GL_UNSIGNED_BYTE, TextureImage.pixels );
I get the error message

lesson7.pas(136,53) Error: Illegal qualifier
lesson7.pas(136,53) Hint: may be pointer dereference is missing
How do I 'derefrence'?????? :evil: :cry:

How are you compiling these demos? Are you using Delphi compatability mode? Which I believe is -Sd compiler directive.

Can you post what command line parameters you are using.

IlovePascal
16-04-2007, 04:35 AM
How are you compiling these demos? Are you using Delphi compatability mode? Which I believe is -Sd compiler directive.

Can you post what command line parameters you are using.
Hey, Im sorry Im not sure where to find the 'command line parameters' that Im using, because I never change those. :oops:

I don't know if this is it, bt I had a look in the 'parsing' section of the 'compiler options' and there was indeed a box saying 'Delphi compatible(-Sd)', i ticked it but I still get an error on the same line.
The difference is that now it says:

lesson7.pas(136,54) Error: Unknown record field identifier "X"
Btw, "TextureImage" is defined as

TextureImage: PSDL_Surface;
and the latter is defined (in sdl.pas) as

PSDL_Surface = ^TSDL_Surface;

So does that mean there is no such thing as an x variable in the TSDL_Surface record?

----

@ would be my guess
Well, I had tried that before! haha
But I think @ is used to reference, and the problem Im having is that the variable is already a pointer! And the parameter needs to be a longint! so thats not it...

Thanks anyways

paul_nicholls
16-04-2007, 04:45 AM
Hey, Im back!

I tested the tutorial 7 from the ]glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage.x,
TextureImage.h, 0, GL_BGR,
GL_UNSIGNED_BYTE, TextureImage.pixels );[/code]
I get the error message

lesson7.pas(136,53) Error: Illegal qualifier
lesson7.pas(136,53) Hint: may be pointer dereference is missing
How do I 'derefrence'?????? :evil: :cry:

Thanks again

Have you tried doing it this way?


glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage^.x,
TextureImage^.h, 0, GL_BGR,
GL_UNSIGNED_BYTE, TextureImage^.pixels );

Since TextureImage is a pointer type, I think freepascal requires the '^'.

cheers,
Paul.

savage
16-04-2007, 07:56 AM
I've never used Lazarus so I'm not sure how it handles Delphi compatability.

When I use the command compiler I do the following...

1. Check that fpc.cfg contains the paths to the JEDI-SDL files ( sdl.pas, jedi-sdl.inc, gl.pas, glu.pas etc ). If the paths are not there, add them into the file.

2. At a command line type the following...

fpc -Sd tutorial7.pas

If 1. is set up correctly, 2 should just work and you do not need to dereference anything.

If you definitely want to dereference it, then try what Paul suggested. The thing is, if you are using Delphi compatibility mode, you do NOT need to dereference, because Delphi supports smart dereferencing.

IlovePascal
16-04-2007, 09:00 AM
Mmmm...
Ok, ok. Interesting (both above).

Well, unfortunately, I tried using the '^' as Paul suggested with the 'Delphi Compatible' box ticked, without it ticked, ticked and without the '^', unticked and without the '^'. In other words, all the combinations of those two. In vain. :(

What I think, however, is that the problem is actually with the X variable, because the compiler says 'Unknown record field identifier X', so maybe it's not struggling with dereferencing, but with finding the right variable, right? I can't check because I don't know where 'TSDL_Surface' is defined, but couldn't that be the problem? Although it's true it seems to be working for you (Savage) just the way it is... :scratch:

Maybe if it's really something I have to do with the compiler, maybe Will could help? He seems to know Lazarus very well. How do I ask him to have a look at this thread? :D

Well, anyways, thanks so much for the time! :wink:

savage
16-04-2007, 10:18 AM
This is the output I get using a v1.9.4 of the compiler...


E:\Development\Borland\Delphi4\Headers\JEDI-SDLv1.0\Demos\3D\NeHe\Tutorial 7>fpc
-Sd JEDISDLOpenGL7.dpr
Hint: End of reading config file e:\development\fpc\bin\win32\fpc.cfg
Free Pascal Compiler version 1.9.4 [2004/05/30] for i386
Copyright (c) 1993-2004 by Florian Klaempfl
Target OS: Win32 for i386
Compiling jedisdlopengl7.dpr
Compiling e:\development\borland\delphi4\headers\jedi-sdlv1.0\opengl\pas\gl.pas
Compiling e:\development\borland\delphi4\headers\jedi-sdlv1.0\sdl\pas\moduleload
er.pas
moduleloader.pas(58,2) Warning: Illegal compiler directive "$WEAKPACKAGEUNIT"
Compiling e:\development\borland\delphi4\headers\jedi-sdlv1.0\opengl\pas\glu.pas

glu.pas(140,14) Hint: Type "PPOINTER" redefinition
Compiling e:\development\borland\delphi4\headers\jedi-sdlv1.0\opengl\pas\glext.p
as
glext.pas(3774,27) Hint: Conversion between ordinals and pointers are not portab
le
glext.pas(3774,19) Hint: Conversion between ordinals and pointers are not portab
le
glext.pas(3775,34) Hint: Conversion between ordinals and pointers are not portab
le
glext.pas(3775,28) Hint: Conversion between ordinals and pointers are not portab
le
glext.pas(3895,3) Note: Local variable "extstring" is assigned but never used
glext.pas(63,15) Hint: Unit "MODULELOADER" not used in GLEXT
jedisdlopengl7.dpr(205,31) Hint: use DIV instead to get an integer result
Linking jedisdlopengl7.exe
13619 Lines compiled, 8.0 sec

And the executable works fine.