Having the same problem. I'm rendering a textured quad as background which is placed at 0.0f, 0.0f, -8.0f. The quad is covering exactly the whole screen and I get 15fps. Same quad with same texture rendered at 0.0f, 0.0f, -16.0f gives 35fps. I don't get it, what's the problem? One quad rendered in front of the camera is slower, than rendering 50 quads in the distance.
Here's the code executed at initialization:
- Code: Select all
float x = 5.5f;
float y = 3.3f;
float vertex[] = new float[] {
-x, y, 0,
x, y, 0,
-x,-y, 0,
x,-y, 0
};
float texel[] = new float[] {
0, 0,
1, 0,
0, 1,
1, 1
};
ByteBuffer vb = ByteBuffer.allocateDirect(vertex.length * 4);
vb.order(ByteOrder.nativeOrder());
vertexBuffer = vb.asFloatBuffer();
vertexBuffer.put(vertex);
vertexBuffer.position(0);
ByteBuffer tb = ByteBuffer.allocateDirect(texel.length * 4);
tb.order(ByteOrder.nativeOrder());
texelBuffer = tb.asFloatBuffer();
texelBuffer.put(texel);
texelBuffer.position(0);
And this one renders it on screen:
- Code: Select all
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -18.0f);
gl.glDisable(GL10.GL_BLEND);
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glBindTexture(GL10.GL_TEXTURE_2D, globals.scnTextures[1]);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texelBuffer);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertex.length / 3);
EDIT: 40fps same background quad without texture.
This is how i generate textures:
- Code: Select all
gl.glBindTexture(GL10.GL_TEXTURE_2D, tx);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
bmp is a 8bit image.