【发布时间】:2012-02-28 06:31:32
【问题描述】:
这个问题是关于 Android 的 OpenGL ES 1.x 编程。
我关注this tutorials 并在三星 Galaxy Ace 上测试了代码,但它有点滞后。 该教程的一些代码:
public void onDrawFrame(GL10 gl) {
// Clears the screen and depth buffer.
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
// Replace the current matrix with the identity matrix
gl.glLoadIdentity();
// Translates 10 units into the screen.
gl.glTranslatef(0, 0, -10);
// SQUARE A
// Save the current matrix.
gl.glPushMatrix();
// Rotate square A counter-clockwise.
gl.glRotatef(angle, 0, 0, 1);
// Draw square A.
square.draw(gl);
// Restore the last matrix.
gl.glPopMatrix();
// SQUARE B
// Save the current matrix
gl.glPushMatrix();
// Rotate square B before moving it, making it rotate around A.
gl.glRotatef(-angle, 0, 0, 1);
// Move square B.
gl.glTranslatef(2, 0, 0);
// Scale it to 50% of square A
gl.glScalef(.5f, .5f, .5f);
// Draw square B.
square.draw(gl);
// SQUARE C
// Save the current matrix
gl.glPushMatrix();
// Make the rotation around B
gl.glRotatef(-angle, 0, 0, 1);
gl.glTranslatef(2, 0, 0);
// Scale it to 50% of square B
gl.glScalef(.5f, .5f, .5f);
// Rotate around it's own center.
gl.glRotatef(angle*10, 0, 0, 1);
// Draw square C.
square.draw(gl);
// Restore to the matrix as it was before C.
gl.glPopMatrix();
// Restore to the matrix as it was before B.
gl.glPopMatrix();
// Increse the angle.
angle++;
}
- 这里的周部分是什么?
- 应该如何优化适用于 Android 的 OpenGL ES 程序?
- 我是否应该在大型图形项目中使用 NDK?
- 是否值得直接使用 OpenGL ES 2.0?
就我没有找到任何关于适用于 Android 的 OpenGL ES 1.x 编程的优秀而复杂的书籍而言,我向 Stackoverflow 的尊贵用户提出了这个问题。 将不胜感激。
【问题讨论】:
-
请注意,android 上的 openGL-es 在模拟器和调试模式下比在设备上正常运行时滞后得多
标签: android graphics opengl-es