Advertisement

Getting this code to work .....

Started by February 12, 2001 05:55 PM
14 comments, last by 23yrold3yrold 23 years, 9 months ago
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

Jesus saves ... the rest of you take 2d4 fire damage.

try linking the libraries.

HHSDrum@yahoo.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
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

Jesus saves ... the rest of you take 2d4 fire damage.

You need to include and link GLUT as well.
Cheers.
Protozone
So link glut32.lib as well? OK .........


Nope, same errors. Lots of WINGDIAPI complaints and "type void unexpected" .....


Chris

Jesus saves ... the rest of you take 2d4 fire damage.

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
Advertisement
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.
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

Jesus saves ... the rest of you take 2d4 fire damage.

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.

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
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]

This topic is closed to new replies.

Advertisement