Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

omegasyphon

OpenGL opengl rotation question

This topic is 6249 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

ok according to opengl bible to rotate my screen along the x axis i do this
  

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

Share this post


Link to post
Share on other sites
Advertisement
in what way does it not work?
are u increasing xrot each frame.

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
Try taking out the glMatrixMode() function. I''m not sure if that will work, but you can always try.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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();

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!