Hey
I am going to be making a game soon but before i do i'm going to make a few little different opengl apps to make sure i have the hang on it. Now that's where the problem starts, I have this little app that rotates a polygon with a white triangle practically in the middle of the polygon, so you can see the edges of the polygon disappearing behind the white triangle as it rotates. (I once had the keyboard controling it but that codes not on this computer :p ). But my main problem is I have never been able to get lighting and shadows to work. My opengl code is run after windows messages are handled ect and is in a constant loop untill the window is closed. The opengl code is as follows:
Now first this is my first real opengl object, is that the cleanest way to do things? Second, I have tried playing around with glEnable and glLighti but havn't been able to get it to work :confused: . So I'm probably doing it all wrong. Can anyone help out and let me know what code to use for shadowing, how to set it up and where i should put it, maybe even an example and I can learn from there. Thanks guys.Code:// OpenGL animation code goes here
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearDepth( -1 );
glClear( GL_COLOR_BUFFER_BIT );
glClear( GL_DEPTH_BUFFER_BIT );
glDepthRange( -5, 5);
glPushMatrix();
glRotatef( theta, 1.0f, 1.0f, 0.0f );
glEnable( GL_CULL_FACE );
glCullFace( GL_FRONT );
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_GEQUAL);
glBegin( GL_POLYGON );
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f, 0.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 0.87f, -0.5f, 0.0f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( -0.87f, -0.5f, 0.0f );
glColor3f( 1.0f, 1.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, -1.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 0.87f, -0.5f, 0.0f );
glEnd();
glBegin( GL_POLYGON );
glColor3f( 1.0f, 1.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, -1.0f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( -0.87f, -0.5f, 0.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 0.87f, -0.5f, 0.0f );
glEnd();
glPopMatrix();
glPushMatrix();
glMapGrid1f( 0, 0, 0 );
glDisable( GL_CULL_FACE );
glBegin( GL_POLYGON );
glColor3f( 1.0f, 1.0f, 1.0f ); glVertex3f( 0.0f, 1.0f, -0.1f );
glColor3f( 1.0f, 1.0f, 1.0f ); glVertex3f( 0.87f, -0.5f, -0.1f );
glColor3f( 1.0f, 1.0f, 1.0f ); glVertex3f( -0.87f, -0.5f, -0.1f );
glEnd();
glPopMatrix();
SwapBuffers( hDC );
theta += 1.0f;