【发布时间】:2014-02-21 13:38:32
【问题描述】:
我的代码不能正常工作。
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
// Here I translate the camera so that the point 0/0 will be at the
//bottom left of the screen
gl.glTranslatef(CameraX, CameraY, CameraZ);
// then I draw the object to rotate like many threads here said:
gl.glPushMatrix();
// translate to the middlepoint of object
gl.glTranslatef(object.getPosX() + object.getWidth()/2, object.getPosY() + object.getHeight()/2, 0);
// rotate
gl.glRotatef(30, 0, 0, 1);
object.draw(gl);
gl.glPopMatrix();
问题是它没有绕中心旋转。它仅将对象的坐标转换到给定点,然后围绕坐标旋转。这是为什么呢?
【问题讨论】: