Sign in to follow this  

opengl in windows

This topic is 4730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this