Jump to content
  • Advertisement
Sign in to follow this  
BenMo

Getting Started: Beginning OpenGL

This topic is 4489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently bought Astle and Hawkins' Beginning OpenGL Game Programming book, however I am having much trouble getting the Book CD code up and running. While the code in the book was written using VC++ 6.0, I'm trying to use Dev C++, which is what I've used for the NeHe tutorials, and it's much simpler than the new VC++ Express (I can't figure that out for the life of me...). Anyway, I'm trying to run the first program, Simple.cpp, but when I try to compile it says "In file included from Simple.cpp" and it highlights the #include <gl\glut.h> line. I've included this file in DevC++'s include/GL folder, and I'm also linked a good many libraries that were needed to get NeHe's tutorials working. How can I get this program started? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Uh...it's definitely there on the code right off of the CD. The Simple folder from Chapter 1 includes the Simple.cpp and glut.h, in addition to other things. Maybe we have different editions?

Share this post


Link to post
Share on other sites
Well I'm mostly new to OpenGL as well but I can at least give you a list of all my links and compiler options as I also use Dev-C++.

In the Project Options menu, Parameter tab I have the following:
Compiler:
-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS

C++ Compiler:
<nothing>

Linker:
-lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32

I have no idea what all that crap means all I know is that when I use it I can display graphics. :-P

I don't, however, use glut.h. I have glu.h, gl.h, and glext.h. So I'm probably no help at all. Sorry. I did use NeHe's tutorials to do some basic 3D graphics so I know that at least what I have works on my machine. Got up to lesson 30-something, so if you use what I use you can at least get that far.

If I remember correctly glut.h is old and crappy and I'd recommend not using it. To use NeHe's tuts there's a work around, basically all you have to do is rewrite one of his file loading functions and you're done. I believe the tutorial is even on the NeHe site.

<-- Bad at OpenGL. I'll stick with 2D for now. :-P

Anyway, I've probably only confused but that's all I know. Sorry.

-Artum

Share this post


Link to post
Share on other sites
No luck yet...when I comment out the glut.h declaration, then the next error coming up is an "undeclared" on the line

glutInit(&argc, argv);

along with a flurry of other errors.

Share this post


Link to post
Share on other sites
[Random Bad Advice Warning!!!]

Try enclosing the #include statement in apostrophes #include "..gl\glut.h" or however it goes... If it's in the folder, it should load using this method.

[/Random Bad Advice Warning!!!]

Share this post


Link to post
Share on other sites
Quote:
Original post by BenMo
... Anyway, I'm trying to run the first program, Simple.cpp, but when I try to compile it says "In file included from Simple.cpp" and it highlights the

#include <gl\glut.h>

line.

What error is reported? You didn't say what the error is. It is very difficult to suggest a solution without knowing what error was reported.

My guess is that you need to include windows.h before including the gl header files, or maybe you need to include gl.h before glut.h.

Share this post


Link to post
Share on other sites
Yes, sorry.

When I add in the includes from the NeHe tutorials, stdlib.h, windows.h, stdio.h, gl\gl.h, gl\glu.h, gl\glaux.h, gl\glut.h, then I get a new set of errors...

[Linker error] undefined reference to `__glutInitWithExit@12'
[Linker error] undefined reference to `__glutCreateWindowWithExit@8'
[Linker error] undefined reference to `__glutCreateMenuWithExit@8'
[Linker error] undefined reference to `glutInitDisplayMode@4'
[Linker error] undefined reference to `glutInitWindowSize@8'

...etc.

Share this post


Link to post
Share on other sites
For compilers that do not support "#pragma comment(lib)" you need to add glut32.lib or glut32.a (depending on your compiler) to your linker settings.
Also, glut.h already includes gl.h, glu.h and the like.

Good luck,
Pat.

Share this post


Link to post
Share on other sites
Only the first example uses Glut. The whole rest of the book uses Win32 which should work fine for you. I would not even worry about it.

PS In this thread, Dave Astle (the author) explains this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!