PDA

View Full Version : Starting to program with OpenGL.



MentalSentinel
08-17-2004, 01:33 AM
Hey,
I would like to start programming with OpenGL. I have C++ experience. I was wondering, where can i download the OpenGL developer stuff? I've searched this site, but no luck. Or do i have to buy it?
Please help.
Cheers.

ZbuffeR
08-17-2004, 01:53 AM
No need to pay to program with OpenGL API.

See the coding FAQ :
http://www.opengl.org/resources/faq/getting_started.html

MentalSentinel
08-17-2004, 05:36 AM
Ok thanks.
I've downloaded some SDK which contained a few header files. But not some file required for opengl, windows.h.
Could anyone please tell me where to get this file?
Cheers, Sentinel

mikael_aronsson
08-17-2004, 07:20 AM
Hi !

You will need at compiler to compile your OpenGL code, like Visual Studio or MinGW32 or something like that, those compilers comes with all files you need to compile OpenGL code.

Visual Studio is available as a free console only download I belive at msdn.microsoft.com, or you could use gcc (www.mingw.org).

There are of course other alternatives also like Borland, Watcom, LCC and so on.

Mikael

MentalSentinel
08-17-2004, 07:40 AM
Yeah i have a compiler, (two actually) but it hasn't got windows.h.

MentalSentinel
08-17-2004, 08:20 AM
I have found windows.h, thanks to all that helped.

But now i have other problems, it seems that almost every program requires header files that i DON'T have, so if anyone could point me directly to a valid OpenGL library, that would be most helpfull, i now got a few header files from a package i got from sgi.com.
Please help me.

08-17-2004, 08:26 AM
windows.h is a include file for "Microsoft Windows".
Since your compiler(s) dont have it, I assume we arent talking about a MS Windows environment.

As said before, the compilers should come with everything you need. If they dont then it dosent help to randomly download stuff that is not meant for your environment (whatever that may be).

So what compiler(s) and os are we talking about?

MentalSentinel
08-17-2004, 08:34 AM
I did some search and the compiler did include it. I'm using Digital Mars for my library stuff and Dev-C++ for compiling.
I just need a valid OGL package. Someone please point me to one. I can't seem to find a package with all the files the tutorials and programs are talking about.

dorbie
08-17-2004, 08:37 AM
Getting programs to compile involves making sure headers are found at compile time and that libs are found at link and probably run time.

You will have the required headers especially if you have installed an SDK from here or from NVIDIA or ATI. Same with the libraries. You need to find the headers and either add the path to your project or move the libs to an existing path.

Once you find the headers your compiler will probably start asking for missing libs or complaining about unresolved symbols during link time and you will have to add the link path or move the files locally or to an appropriate system directory. This is basic compilation stuff. You should probably get a book on OpenGL development if you can't get this working soon. Pretty much any of the OS specific books will help you with this.

MentalSentinel
08-17-2004, 09:00 AM
I know what to do with the headers once i have them, but my problem is, i don't have them. :(
Could anyone point me to a valid package of OpenGL header files? It would be most apreciated. :(
Cheers.

ZbuffeR
08-17-2004, 09:59 AM
Did you actually read the link I posted ?

Which header files do you need ?

MentalSentinel
08-17-2004, 10:05 AM
Yes i read it and i used the information. I downloaded a package with header files, but unfortunately very few header files.
I've seen header files like glaux.h and glu.h in tuts, but they are not in my package :( . So if anyone could point me directly to a complete package that'll be most helpfull.
Cheers.

ZbuffeR
08-17-2004, 10:31 AM
That is right, GLU can not be downloaded from that page, despite there is a link that says "you may need include files and libraries for GLU and GLUT."
http://www.opengl.org/documentation/spec.html/

And there is only gl.h related files ???

A webmaster could fix this ???

Very often, glu.h comes with the compiler. Anyway :
http://freedesktop.org/cgi-bin/viewcvs.cgi/*checkout*/mesa/Mesa/include/GL/glu.h

About glaux.h : very old lib. Try to find tutorials for glut instead, you can find Glut versions for most tutorials at http://nehe.gamedev.net

08-17-2004, 10:39 AM
Ahhh ok so you use the Bloodshed Dev C++ compiler.

I think you will find this webpage very usefull:

http://www.angelfire.com/linux/nexusone/dev4.html

A quote from that page:

"Note all files needed to compile with openGL are shipped with DEV-C++"

Hope that helps.

dorbie
08-17-2004, 01:32 PM
You mentioned you downloaded an SDK but perhaps not one I was hoping. Both NVIDIA and ATI have SDKs available for download that will provide the correct libs. You can also get glut online if they don't provide that.

glaux is dead, get some better examples to compile, most glaux examples have been ported to glut, even the ones in early revisions of the red book. glu.h is legit and will be in any OpenGL SDK from any manufacturer (looks like opengl.org is missing it !?). glut is popular and can be found online easily if it doesn't ship with your chosen SDK.

http://www.opengl.org/resources/libraries/glut.html

08-17-2004, 08:46 PM
Dorbie he said he uses the bloodsheed Dev C++ compiler, Nvidia's and ATI's SDK are meant for the MS VS so he will have trouble getting them to work because Dev C++ uses a different .lib format.

As I said, Dev C++ comes with the OpenGL/GLUT/GLAUX libs and headers, he should have everything he needs.

MentalSentinel
08-18-2004, 12:32 AM
Ok i see Dev-Cpp should come with glut.h, glaux, glu.h, glext.h and gl.h.
There's another problem, mine has only glu.h, glext.h and gl.h.
I've read all the links you guys provided, but still no luck... :(
Please point me directly to a package with them....
Or to a better Dev-C++ version....
Cheers.

08-18-2004, 01:18 AM
DEV-C++ V4.0

http://ftp1.sourceforge.net/dev-cpp/devcpp4.zip

Content of include/gl

gl.h
glaux.h
glut.h
readme.txt (with a description)

Content of lib (among others)

libglaux.a
libopengl32.a
libglut32.a

MentalSentinel
08-18-2004, 11:34 AM
Hmm. I've done everything like it should be done now. I've placed the header files in the good directory, correct library's everywhere. But still the compiler refuses to work...
I've tried all the versions of Dev-C++ about now :p
And i seem to need MSVC++ for NeHe's tuts.
Could someone point me directly to the proper version of MSVC++ used in NeHe's tuts... All i seem to find are updates.
Cheers.

ZbuffeR
08-18-2004, 12:13 PM
Nehe's tuts ?
Just download the right package :
"DOWNLOAD Dev C++ Code For This Lesson."
http://nehe.gamedev.net/data/lessons/devc/lesson01.zip

No offence, but if you are unable to read, I am afraid you will have hard time programming in OpenGL (or whatever).

MentalSentinel
08-18-2004, 10:24 PM
I can read and actually downloaded that package.
That's not the problem. Dev-Cpp just isn't working. glaux.h and it's library isn't in, only in older versions, and when you import glaux.h and it's lib from the older version it gives all weird compiling errors. So you understand, that i need a better compiler... such as MSVC++....
So please just point me to it...
Cheers.
BTW, that conversion isn't in every lesson, and NeHe explains it in valid VC++ code i believe, else it wouldn't need a conversion...

08-18-2004, 10:27 PM
Originally posted by MentalSentinel:
Hmm. I've done everything like it should be done now. I've placed the header files in the good directory, correct library's everywhere.
Dude, no offense but I dont think you know what you are doing. If you just had downloaded and installed DEV-C++ from the link I gave you. You wouldnt need to copy header files around, they are where they belong.


Originally posted by MentalSentinel:
But still the compiler refuses to work...
I've tried all the versions of Dev-C++ about now :p
*sigh*


Originally posted by MentalSentinel:
And i seem to need MSVC++ for NeHe's tuts.
The MSVC++ tuts are for *surprise* the MSVC++ compiler. If you want to use Dev C++ you need the Dev C++ tuts.


Originally posted by MentalSentinel:
Could someone point me directly to the proper version of MSVC++ used in NeHe's tuts... All i seem to find are updates.
MSVC++ cost money. Downloading it would be theft.

Perhaps it would be ALOT easier if you tell us what exactly you want to do and:

1.) Which compiler (and version) do you want use.
2.) Which operating system do you use.
3.) Which tutorials are you trying to compile.
4.) And what error messages do you get.

MentalSentinel
08-19-2004, 12:00 AM
I DID download and DID install it and it DID NOT work.
I was trying to compile the Dev-C++ conversion of Lesson01 by NeHe.
I tried it with both that older version and the newest version with the glaux lib of the older version.
Here is a list of errors that i get:
- [Linker error] undefined reference to `glViewport@16'
- [Linker error] undefined reference to `glMatrixMode@4'
- [Linker error] undefined reference to `glLoadIdentity@0'
- [Linker error] undefined reference to `gluPerspective@32'
- [Linker error] undefined reference to `glMatrixMode@4'
- [Linker error] undefined reference to `glLoadIdentity@0'
- [Linker error] undefined reference to `glShadeModel@4'
- [Linker error] undefined reference to `glClearColor@16'
- [Linker error] undefined reference to `glClearDepth@8'
- [Linker error] undefined reference to `glEnable@4'
- [Linker error] undefined reference to `glDepthFunc@4'
- [Linker error] undefined reference to `glHint@8'
- [Linker error] undefined reference to `glClear@4'
- [Linker error] undefined reference to `glLoadIdentity@0'
- [Linker error] undefined reference to `wglMakeCurrent@8'
- [Linker error] undefined reference to `wglDeleteContext@4'
- [Linker error] undefined reference to `ChoosePixelFormat@8'
- [Linker error] undefined reference to `SetPixelFormat@12'
- [Linker error] undefined reference to `wglCreateContext@4'
- [Linker error] undefined reference to `wglMakeCurrent@8'
- [Linker error] undefined reference to `SwapBuffers@4'

And ofcourse i don't know what i'm doing. That's why i ask help in the first place.

MentalSentinel
08-19-2004, 12:28 AM
Ok, i've found some tuts for a compiler called .NET or something, is that compiler free?

jean-bobby
08-20-2004, 02:39 AM
For your compile errors, the reason is that the compiler don't find the libraries. Check that you have them in the lib directory of your compiler. If you use dev-c++, the compiler is provided by mingw (minimal gnu for windows) and is gcc. The library directory should be in the mingw directory. You need glu, opengl and wgl libraries. They should be called libglu.a or glu.lib, opengl32.lib or libopengl32.a and i don't know wgl. If you don't find them, you can try to search on google opengl95.exe. It contains all that you need for doing opengl (but not contains wgl).
If you have the libraries and it still don't compile, then configure dev c++ (options menu) to add to its library path the lib directory where are opengl libraries.

I found this page page (http://www.microsoft.com/downloads/details.aspx?familyid=272be09d-40bb-49fd-9cb0-4bfa122fa91b&displaylang=en) where it seems that visual c++ can be downloaded (i don't try). I heard that it is free since the new .net platform. If you can, use it rather than dev c++! It compiles very faster and can save you a lot of time.

Finally, if you can, perhaps should you not use wgl. That limits you to windows and you won't lose time to use a portable library like glut or SDL (better!).

Hope it can help.
Fabien

MentalSentinel
08-20-2004, 04:14 AM
Thanks, but that toolkit didn't inlude the OpenGL libs and Header files..
Is it suposed to be in a Dos environment?
Has anyone ever got OpenGL to work with Dev-C++?

jean-bobby
08-20-2004, 05:52 AM
I think you have the include files otherwise you would have had errors before the link step like :"gl.h : file not found".
Have you looked at lib directory of mingw (in the dev c++ directory if you haven't installed it separetely)?
There is an opengl package for dev c++. Perhaps you have it. Create a new project in dev-c++. In the wizard's first page, select the multimedia tab. Perhaps you will see opengl. Otherwise you could find it on the bloodshed site.

Have you read the opengl faq on this site? All libraries and includes files are accessible via this faq in the opengl95.exe that i talked about.

MentalSentinel
08-20-2004, 07:53 AM
Now that i placed glaux.a in the mingw's lib directory, it solves the errors! But replaces them for two other.... :(
- [Linker error] undefined reference to `WinMain@16'
- C:\Dev-Cpp\Makefile.win [Build Error] [Project1.exe] Error 1

I have every .a and every .h file already.. so no need to download them anymore..
Anyone know how to fix these two?
Cheers.

EDIT: I FINALLY GOT IT TO WORK!!! THANKS MAN!