这个问题是关于Android.的OpenGL es1.x编程
我遵循本教程并测试了三星Galaxy上的代码,它有点滞后。本教程的一些代码:
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++;
}至于我没有找到任何好的和复杂的书,关于OpenGL ES 1.x编程的安卓,我提出这个问题的尊敬的用户的斯塔克溢出。会很感激你的帮助。
发布于 2012-02-27 22:31:32
定义滞后?查看框架以获得更好的性能感觉可能会有所帮助。
但是,只要square.draw(gl)在做它所暗示的事情,那么这是一个非常简单的程序。这段代码的性能没有什么大问题。
不过,我觉得这更像是一个更大的项目的推测性问题。有些事情需要考虑的是,您将尝试实现什么样的图形效果。OpenGL es1.x对你来说是否足够强大?如果您需要编写自定义着色器代码,则必须使用ES 2.0。记住,2.0要求你把所有东西都写成一个着色器。它删除了许多1.0特性,并将这些特性提供给开发人员来实现和定制。因此,开发将更加复杂,更耗时。
作为一个警告,不要直接跳入NDK作为起点。所有这些OpenGL调用都是本机的。用Java语言编写Android应用程序要比用JNI编写C/C++要容易得多。
归根结底,早期优化是万恶之源。一旦您选择了您的技术,实现了一个解决方案,并度量了它的性能,那么您就可以担心优化代码了!
https://stackoverflow.com/questions/8029269
复制相似问题