GLfloat xrot;
void renderscene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(xrot,1.0f,0.0f,0.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glMatrixMode(GL_MODELVIEW);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,cords);
glDrawElements(GL_TRIANGLE_STRIP,648,GL_UNSIGNED_INT,corners);
glPopMatrix();
glutSwapBuffers();
}
//here is the main function that calls it
void main()
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("game engine console");
glutReshapeFunc(ChangeSize);
glutDisplayFunc(renderscene);
setuprc();
glutMainLoop();
}
but this doesnt work
opengl rotation question
ok according to opengl bible to rotate my screen along the x axis i do this
in what way does it not work?
are u increasing xrot each frame.
http://members.xoom.com/myBollux
are u increasing xrot each frame.
http://members.xoom.com/myBollux
Try taking out the glMatrixMode() function. I''m not sure if that will work, but you can always try.
Move the glMatrixMode to the line above glPushMatrix. You should set matrix mode first and not in the middle of code.
If you want to spin something do you have to increase xrot each frame. Put in xrot+=1.0; and check the result.
If you want to spin something do you have to increase xrot each frame. Put in xrot+=1.0; and check the result.
Not sure if you tried this or not, It was part of another suggestion. In the idle function, put a way for xrot to increase. like xrot += 0.3f; Then at the end of the idle function, post a redisplay. glutPostRedisplay();
That is correct.
When you do glRotatef( xrot, 1.0f, 0.0f, 0.0f );
If xrot is the same every time, it is not going to rotate. It is not a relative rotation but an absolute rotation along the x axis. So if I do glRotatef( 10.0f, 1.0f, 0.0f, 0.0f ); each time in renderscene it will be at exactly a 10 degree rotation every time, not 10 degrees per frame.
You could just put something like xrot+= 0.5f; at the end of renderscene() and it should rotate.
Seeya
Krippy
When you do glRotatef( xrot, 1.0f, 0.0f, 0.0f );
If xrot is the same every time, it is not going to rotate. It is not a relative rotation but an absolute rotation along the x axis. So if I do glRotatef( 10.0f, 1.0f, 0.0f, 0.0f ); each time in renderscene it will be at exactly a 10 degree rotation every time, not 10 degrees per frame.
You could just put something like xrot+= 0.5f; at the end of renderscene() and it should rotate.
Seeya
Krippy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement