2011-01-20 72 views

回答

1

假設你有一個名爲GL的OpenGL ES GL10對象,在你的OnDraw或類似:

// Push matrix so we can pop later 
    gl.glPushMatrix(); 

    // Translate to the center of your cube 
    // Or to whatever xyz point you want 
    glTranslatef(centreX, centreY, 0); 

    // rotation = degrees to rotate 
    // x,y,z are unit vectors for rotation to take place 
    // I.E x=0.0 y=0.0 z=0.0 would rotate around the z-axis 
    gl.glRotatef(rotation, x, y, z); 


    // CUBE DRAWING FUNCTION HERE 


    // Popmatrix so we undo translation and rotation for 
    // rest of opengl calls 
    gl.glPopMatrix(); 

我建議在看the android ports of the nehe opengl tutorials因爲他們輝煌的導遊與Android開始的OpenGL。

+0

在Z軸上,它的工作,它在立方體的中心上旋轉,但是在x,y軸上它不起作用。這樣,中心不是指向立方體的中心,而是其他任何位於中心的位置。 – lacas 2011-01-21 09:05:43

相關問題