Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Getting this code to work .....

This topic is 6485 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

Hello. What must I do to get the example code in The Red Book to compile? Using VC++ 4.0 (I also use DJGPP). The compiler gives me a mile of errors from gl.h. Ask for more info if you need it. Thanks muchly. Chris

Share this post

Link to post
Share on other sites
What, OpenGL32.lib, GLu32.lib and glaux.lib? Been there, done that; I can get the NeHe tutorials working fine. It''s those Red Book examples alone that cause me problems.


Share this post

Link to post
Share on other sites
never include glaux ,sgi (its makers say u should use glut instead )
if youve downloaded glut (latest windows version here http://www.xmission.com/%7Enate/glut.html )

with vc.
create a console application not a win32 one
copy the red book code in a file eg main.cpp
DONOT link with any libraries what so ever if the file has #include does this automatically.
a lot of the demos on me site use glut (and they come with make files so u should have to alter anything)


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
GLUT tries to avoid including windows.h but glut.h needs some minor modification for some compilers. You can get it from the net or edit glut.h yourself.

One brutal solution is to include windows.h before glut.h if that works is it best to get a corrected header.

Share this post

Link to post
Share on other sites
OK, making progress. But still not there. Here's the code; anyone with the Red Book will probably recognize it immediately (with a few different includes as I try to make it work)....

#include windows.h
#include GL/gl.h
#include GL/glut.h
#include GL/glaux.h

int main(int argc, char** argv)
auxInitDisplayMode (AUX_SINGLE | AUX_RGBA);
auxInitPosition (0, 0, 500, 500);
auxInitWindow (argv[0]);

glClearColor (0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);

// sleep(10); // Commented out for being an error during compiling

return 0; // Added to eliminate a warning

This is the error list now. I'm not linking any OpenGL .lib's.

LIBC.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Release/Test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Test.exe - 2 error(s), 0 warning(s)

Also, you say I can make my own glut file. I've seen programs on Nate Robin's page I can't compile because they require a bunch of DLL's. SGI says to use glut not glaux, even though some people seem to make there own.

Does OpenGL have a standard or something? Where do all these files come from? Isn't it a little unnecessary?


Edited by - 23yrold3yrold on February 13, 2001 7:28:00 PM

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Make a console application not a GUI app. You do not use GLUT so it is no reason to include or link to it.

If you got GLUT from Nate Robins and are using VC++ should you not have to change anything.

The reason it did not work from the beginning is that you include opengl.h and windows.h must be included before that. If you are using GLUT should you *not* include opengl.h but let GLUT do that.

I do not know what DLLs you mean. I think you should be able to run everything from Nate Robins site.

Share this post

Link to post
Share on other sites
The compiler is looking for the WinMain function. This is the standard entry point for "win32 GUI" applications your using main wich is the standard entry point for all other os''s I''ve ever programmed for and for "win32 counsel" applications! When you create the project you have to eather create it as a counsel app or use winmain

Share this post

Link to post
Share on other sites

  • 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!