*really* basic OpenGL problem

Started by
14 comments, last by Fredric 24 years, 1 month ago
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!
Advertisement
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.
Then how do you know there are two errors?
*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!
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.
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.
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!
Um, this is probably obvious, but according to your code you haven''t actually specified anything to include after the #include calls.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

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?

One thing you should be aware of... that book is based on opengl for unix. Another note, its no where near a ''super bible''. That aside look under the gamedev.net programers section and then opengl section. There you will see a articual entilled "Example of the Minimal Win32 & OpenGL program". Note the program does make one mistake, arguments to the call ReleaseDC was switched. Add Opengl32.lib and glu32.lib to your project settings and this program should compile without any problems.

This topic is closed to new replies.

Advertisement