opengl in windows

Started by
5 comments, last by Raduprv 19 years, 3 months ago
Noob here, I am using Opengl on a pc laptop with windows xp. I can operate the tutorials. I am confused about which type of file to open. it seems that opening different types gives you different windows with different scripting already inserted for you. I have tried reproducing scripting i see in the red book (below) to make simple polygons, but it gives an error saying that glvoid was not declared #include <iostream.h> #include <stdlib.h> int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBegin(GL_TRIANGLES); glVertex3f( 0.0f, 1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f); glEnd(); system("PAUSE"); return 0; } cheers! sm
Advertisement
did you include gl/gl.h?
yes, it said i was denied permission.
sm
put #include <windows.h> before you include the gl header files
thanks for the replies
this is what it looks like, but is still giving me a no permission error...this does give ideas about where else to look for solutions though so thanks for the responses

#include <windows.h>
#include <iostream.h>
#include <stdlib.h>
#include <gl>
int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
system("PAUSE");
return 0;
}
Hate to rain on your parade here, but that is not even remotely close to what you need to do to make an OpenGL program.

Anyway though, make sure you type #include <gl/gl.h>. Just gl isn't good enough. And as for the GLvoid thing, just take it out. GLvoid is simply a typedef for void.

Now, none of the code examples in the Red Book will actually work as are. You have to create a window, bind an OpenGL context to it, set up the render state and message loop then add the rendering code.

You don't even have a main()/WinMain() function. You've given no evidence that you are using GLUT, SDL or Win32 at all here. If you are and you know how to do that, then sorry. But if not, then I highly suggest you read tutorials on how to write console C programs first, because your problems at the moment are highly suggesting that you haven't written any C programs before and just copy/pasted.

Not flaming here, but get the basics down before you jump into something as complicated as OpenGL.

-Auron
I think you should use SDL, because it simplifies things, and then your program will be easier to port on other OSes, provided that you don't make use of native Win32 functions (instead, replace them with SDL functions). SDL has it's own headers for OpenGL, which is useful for dealing with versions >1.1

This topic is closed to new replies.

Advertisement