• Advertisement
Sign in to follow this  

Getting Started: Beginning OpenGL

This topic is 4246 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
None of my BOGLGP code uses glut - why do you have that?

Share this post


Link to post
Share on other sites
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
I ran across these errors not too long ago trying to compile with MinGW.. Googled it and found this: http://www.mingw.org/MinGWiki/index.php/Glut?PHPSESSID=54cdd9e3099a2a6b87d403eed

Assuming all of your include directories, and lib directories are correct and you're including the glut lib, then before your #include "glut.h" place the following defines

#define _STDCALL_SUPPORTED
#define _M_IX86

It fixed the problem for me..

Share this post


Link to post
Share on other sites
I've already included glut32.lib in my linker, along with everything else that Artum listed in the post above.

When I try to put in the two #define lines you suggested, I get more errors in addition to the previous ones I listed, and it highlights the #include <windows.h> line...

9:1 C:\Dev-Cpp\OpenGL\Simple\Simple.cpp [Warning] "_M_IX86" redefined
28:1 C:\Dev-Cpp\include\windows.h [Warning] this is the location of the previous definition

Share this post


Link to post
Share on other sites
Hmmm. I wonder why it's pulling up a warning on windows.h? You're building this as a console application right? As for the warnings on the defines, you can simply do:

#ifndef _STDCALL_SUPPORTED
#define _STDCALL_SUPPORTED
#endif
#ifndef _M_IX86
#define _M_IX86
#endif

Share this post


Link to post
Share on other sites
I've tried it as a windows application and as a console application, with the same linker errors for both. Adding in your defs seemed to have no effect.

Share this post


Link to post
Share on other sites
Well, I never got the Chapter One project working, but the other Chapters seem to work fine as long as I load in all the files and list the right things in the linker. Thanks guys!

Share this post


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

  • Advertisement