Newbiw needs help with OpenGL

Hello. I recently started learing OpenGl I was going through the book and I got stuck on the first code.
this is the Code from the book:

#include <GL/gl.h>
#include <GL/glu.h>
main() {
InitializeAWindowPlease();
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
UpdateTheWindowAndCheckForEvents();
}

but when i compile it i get the following 3 errors:

\gl\gl.h(1152) : error C2144: syntax error : missing ‘;’ before type ‘void’

\gl\gl.h(1152) : error C2501: ‘WINGDIAPI’ : missing storage-class or type specifiers

\gl\gl.h(1152) : fatal error C1004: unexpected end of file found

Whats Wrong?
Please Help

I’m not quite sure, but try
#include <GL/glut.h>
as well.
-Andrew

Oh wait…
I just took a closer look at the errors, and what I just said shouldn’t help at all. Sorry!
-Andrew

Hi,

Are you sure that header files are copy to the GL directory? The way to test it shown as below.

If using Visual C++
Try to right click your mouse on that <GL/gl.h> and select open document<GL/gl.h>. The files are in that directory if the gl.h file is opened.

Yes the header files are all there in my Include folder?

#include <windows.h> // NOTE: this comes BEFORE gl.h
#include <GL/gl.h>

What compiler are you using?
Also are you compiling as a C program or a C++ program?

I added the #include <windows.h> at the beginning, now I m getting 2 different errors. Im getting these errors now.

error C2065: ‘InitializeAWindowPlease’ : undeclared identifier

error C2065: ‘UpdateTheWindowAndCheckForEvents’ : undeclared identifier

Im Compiling it as a C++ progrgam

Ksingh30:

error C2065: ‘InitializeAWindowPlease’ : undeclared identifier

error C2065: ‘UpdateTheWindowAndCheckForEvents’ : undeclared identifier

These are notes from the book, you need to actually “Initialize a window” and “Update and check for events” in the window.

Loop at page 24, I"m guessing your using the RedBook, Example 1-3. Here they are using GLUT (dont forget to include this) to create a window and update it.

Creation = inside main()
glutInitWindowSize() //init window
glutWindowPosition() //position window
and finally
glutCreateWindow() //create the window

updating is handled by the reshape() function.

Hi,

Try on this website to get some simple examples. That will help u to built up your opengl foundation.
http://myopendemo.hypermart.net

Don’t take this the wrong way, but if you are getting confused by pseudo-code, it probably means you should get a decent grasp of C++ before trying to jump into OpenGL. Trying to jump right into OpenGL is like learning to read by trying to read War & Peace as your first book.