PDA

View Full Version : Newbiw needs help with OpenGL



Ksingh30
10-29-2003, 02:30 PM
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

Andrewinator
10-29-2003, 04:13 PM
I'm not quite sure, but try
#include <GL/glut.h>
as well.
-Andrew

Andrewinator
10-29-2003, 04:15 PM
Oh wait...
I just took a closer look at the errors, and what I just said shouldn't help at all. Sorry!
-Andrew

cwc36
10-29-2003, 04:49 PM
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.

Ksingh30
10-29-2003, 06:54 PM
Yes the header files are all there in my Include folder?

Deiussum
10-30-2003, 05:17 AM
#include <windows.h> // NOTE: this comes BEFORE gl.h
#include <GL/gl.h>

nexusone
10-30-2003, 05:21 AM
What compiler are you using?
Also are you compiling as a C program or a C++ program?

Ksingh30
10-30-2003, 02:12 PM
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

Ksingh30
10-30-2003, 02:14 PM
Im Compiling it as a C++ progrgam

Susano
10-30-2003, 02:32 PM
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.

cwc36
10-30-2003, 05:53 PM
Hi,

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

Deiussum
10-31-2003, 05:15 AM
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.