I’m new to openGL and there are alot of helpful tutorials out there. I have been following the tutorial to create rotating 3D polygon. My question is, how can you use the keyboard to toggle the polygon rotation between different axis during runtime?
I tried to call glRotatef( ) in the keyboard function with different case statements, but that doesn’t seem to work. I might be missing something here.
Suppose the general code is something like this:
void Display (void)
glBegin ( GL_Polygon )
//vertices goes here
void keyboard ( unsigned char key, int x, int y )
glRotatef ( 5.0f, 0.0f, 0.0f, 0.1f );
glRotatef ( 5.0f, 0.0f, 0.1f, 0.0f );
glRotatef ( 5.0f, 0.1f, 0.0f, 0.0f );
void main ( int argc, char** argv )
//other glut window functions goes here
Any suggestion will be appreciated. Thank You!