• Advertisement

Archived

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

Getting this code to work .....

This topic is 6213 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
Advertisement
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.


Chris

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
run.
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)


http://members.xoom.com/myBollux

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);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();

// 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?


Chris


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
i noticed u said vc4 u might haveto recompile the glut librarys to work for vc4 as the standard ones were prolly built for vc6.

pain in the ass but thats life in the m$ world. count yourself lucky u might of been using d3d7 and wanted to add a feature from d3d8, that''s much worse. a recompile aint good enuf, in such a case u would have to goback + physically change a lot of the already working d3d7 stuff to make it compatible with d3d8. i sympathise with all the poor bastards who have had to do it

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
That code WAS for a console app (since many have told me to do that; I already have). How exactly do I recompile glut? Also, I''ve gotten it down to one error now....

Linking...
C:\MSDEV\LIB\glut32.lib : fatal error LNK1106: invalid file or disk full:
cannot seek to 0x39d522ff
Error executing link.exe.
Test.exe - 1 error(s), 0 warning(s)

Not sure what that means though....might recompiling fix it?


Chris

Share this post


Link to post
Share on other sites
>>C:\MSDEV\LIB\glut32.lib : fatal error LNK1106: invalid file or disk full:
cannot seek to 0x39d522ff
<<
this error means u need the glut librarys compiled with vc4. you''ll prolly have to compile them yourself unless u can find someone else thats already done it.
NONE of the other suggestions will work eg linking with this + that , console app etc . the only way to fix its is to have the right dll''s (the ones made for vc + not vc5/6)

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The code that was posted does not use glut but glaux.

Share this post


Link to post
Share on other sites
the gl.h has some things used in wich arent defined in itselfs like APIENTRY and such.. it is defined in the windows.h

so, you have to include windows.h first, and after it gl.h.. and not the other way around, else its not yet defined in gl.h (thats my cent to the story)

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
Well, thanks for your help everyone. I figure I''m just going to stick to learning through NeHe''s tutorials and MFC. I wanted glut because the setup is nice and simple plus half the source code out there uses it, and I can worry about learning OpenGL and not bother with half my code being initialization. I don''t know how to re-compile glut, so if someone can spell it out for me or just ppoint me to a VC++ 4.0 version, great. If not, no biggie. I''ll get by. Thanks, everyone.


Chris

Share this post


Link to post
Share on other sites

  • Advertisement