Is it possible to rotate an object around its own axis and not around the base coordinate's axis?

后端 未结 4 1437
难免孤独
难免孤独 2020-12-02 13:49

I am following the OpenGL es rotation examples from google to rotate a simple square (not a cube) on my Android App, for example this code:

gl.glRotatef(xro         


        
4条回答
  •  广开言路
    2020-12-02 14:26

    Try adding

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    

    before the render code for a single cube that's being rotated, and then

    glPopMatrix();
    

    after the rendering is done. It will give you an extra view matrix to work with without affecting your primary modelview matrix.

    Essentially what this does is create a new modelview camera, render, then destroy it.

提交回复
热议问题