Skip to main content
gamedev.net
🔒 Locked

*really* basic OpenGL problem

Started by Fredric Mar 14, 2000 at 6:55 PM 14 replies 850+ views
Original Post
Fredric
Fredric
I copied the following piece of code from OpenGL Super Bible, but when I compile it, it brings up two errors! #include #include // Console I/O functions #include // OpenGL functions #include // AUX Library functions void main(void) { // These are the AUX functions to set up the window auxInitDisplayMode(AUX_SINGLE / AUX_RGBA); auxInitPosition(100,100,250,250); auxInitWindow("My first OpenGL Program"); // These are the OpenGL functions that do something in the window glClearColor(0.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glFlush(); // Stop and wait for a keypress cprintf("Press any key to close the Window\n"); getch(); } I thought I could catcht the first error- cprintf? Is that correct? When I bump off the c, the number of errors is reduced to one, but why would the author put a c in front of printf? Anyhow, the other error I can''t find. What''s wrong with this? The following libraries are include: opengl32.lib glaux.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib can anyone please please help me with this? If this book is going to be full of errors, I''m gonna be upset... Programming::~Fredric(const Annoy_Ance)
3D Math- The type of mathematics that'll put hair on your chest!
SiCrane
SiCrane
It might help if you posted the second error.

Also, I thought cprintf was a valid function. I might be thinking UNIX though. You might try _cprintf instead.
SiCrane
SiCrane
Then how do you know there are two errors?
Fredric
Fredric
*sigh* because the compiler SAYS SO!!! Aren''t you a programmer?!?

Programming::~Fredric(const Annoy_Ance)
3D Math- The type of mathematics that'll put hair on your chest!
SiCrane
SiCrane
Ok, when *my* compiler says there are two errors, it tells me what they are. e.g. Line 2: misplaced semicolon ( or something like that. What errors are your compilers telling you?

btw. You might want to delete some of those duplicate posts.
gmcbay
gmcbay
How did you create the project? You are using Visual C++ I assume? You need to be sure that whatever compiler you are using knows you are trying to compile a console app. In Visual C++ this is just a matter of picking console app within the create project wizard.

cprintf and getch only make sense within the context of a console app, and your mysterious second error when cprintf is removed is probably a linking error due to the fact that the linker is looking for a WinMain and not finding one.
Fredric
Fredric
So, how do I change that, and make everything work? It''s already a console application.

Programming::~Fredric(const Annoy_Ance)
3D Math- The type of mathematics that'll put hair on your chest!
gmcbay
gmcbay
I believe that''s just due to this message board''s weird handling of the greater than and less than symbols. It thinks he is trying to do some HTML stuff.

In any case, what process did you go about in creating the project? Or did you import it from the book sample?

Fredric
Fredric
I have all the right ingludes, trust me.

To have make the app I went into VC++ and chose to make a Win32 Console App (the one with the window with the windows logo inside it). I included ALL the right stuff...
It''s for UNIX? What the hell? Then what book should I buy? I need a book that assumes that the person knows ONLY C++, and nothing else.
3D Math- The type of mathematics that'll put hair on your chest!
Spellbound
Spellbound
The OpenGL Super Bible is in fact for OpenGL on Windows NT and Windows 95/98. (At least the book at ITKnowledge that I tipped you about. )

If you posted the exact error messages that you compiler gives you it would be easier to help you.
Fredric
Fredric
This is what i get after I type in the source code and try to build it...

--------------------Configuration: SmallestPossible - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/SmallestPossible.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

SmallestPossible.exe - 2 error(s), 0 warning(s)

I hope this helps

Programming::~Fredric(const Annoy_Ance)
3D Math- The type of mathematics that'll put hair on your chest!
Spellbound
Spellbound
The AP above is right. But just to clarify things, when you started your project you chose the "Win32 Application" type, you should have chosen "Win32 Console Application".
Fredric
Fredric
Are you serious? that was it?!? Lemme try it...

OH SWEET... OH YES, IT WORKED!!!!!! Thanks!!!! Geez.. I can''t believe it was THAT simple!!!! Thankyou so so so so so so so so so so very much!

Programming::~Fredric(const Annoy_Ance)
3D Math- The type of mathematics that'll put hair on your chest!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.