Rotating an object around a fixed point in opengl

后端 未结 4 358
我在风中等你
我在风中等你 2020-12-16 01:19

I have a problem with this openGL code:

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix(); // put current matrix on stack

//glTranslatef(0.0f, 0.         


        
4条回答
  •  情歌与酒
    2020-12-16 02:03

    Example of rotating an object around its centre along the z-axis:

    glPushMatrix();
    
    glTranslatef(250,250,0.0); // 3. Translate to the object's position.
    
    glRotatef(angle,0.0,0.0,1.0); // 2. Rotate the object.
    
    glTranslatef(-250,-250,0.0); // 1. Translate to the origin.
    
    // Draw the object
    glPopMatrix();
    

提交回复
热议问题