在大多数Android设备上,如果我用Integers而不是Floats进行所有OpenGL顶点计算/渲染,我是否应该期望性能提升?
我最近从使用0:宽度,0:高度而不是-1:1,-1:1的OpenGL视口切换,所以如果需要,我可以将所有绘图计算/缓冲区转换为Ints而不是Floats为了表现.
例如,如果我在我的应用程序中执行以下许多类型的计算和渲染.
float x1 = someFloatCalculation(foo);
float x2 = someFloatCalculation(bar);
float y1 = someOtherFloatCalculation(foo);
float y2 = someOtherFloatCalculation(bar);
// the float buffer for the coordinates
FloatBuffer buf = makeFloatBuffer(new float[] { x1, y1, x2, y1, x1,
y2, x2, y2 });
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, buf);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
Run Code Online (Sandbox Code Playgroud)
可以通过改变类似的东西来加快速度
int x1 = someIntCalculation(foo);
int x2 = someIntCalculation(bar);
int y1 = someOtherIntCalculation(foo);
int y2 = someOtherIntCalculation(bar);
// the float buffer for the coordinates
IntBuffer buf = makeIntBuffer(new int[] { x1, y1, …Run Code Online (Sandbox Code Playgroud)