Hello,
I apologize if this is a repeated post, I searched the net and the forums and found no one asking a similar question.
I am receiving poor performance when using glDrawArrays. All my drawing is for 2D. When I use immediate mode I receive approximately 90 FPS. When using glDrawArrays I receive < 15 FPS.
What I'm I doing wrong?
This code is invoked for each texture I want to draw:
/**
* Draws an Image.
*
* @param image
* @param x
* @param y
* @param width
* @param height
*/
private void drawImage0(LWJGLImage texture, float x, float y, int width, int height) {
glBindTexture(GL_TEXTURE_2D, texture.getTextureId());
// makes no gl calls
Rectangle bounds = applyFilters(texture, 0, 0, width, height);
if ( texture.isRepeating() ) {
GLState.textureRepeat();
}
else {
GLState.textureClamp();
}
FloatBuffer tex = BufferUtils.createFloatBuffer(4 * 2);
tex.put(texture.getTexX()).put(texture.getTexY()).
put(texture.getTexX()).put(texture.getHeight()).
put(texture.getWidth()).put(texture.getHeight()).
put(texture.getWidth()).put(texture.getTexY());
tex.flip();
FloatBuffer vertex = BufferUtils.createFloatBuffer(4 * 2);
vertex.put(x + bounds.getX()).put(y + bounds.getY()).
put(x + bounds.getX()).put(y + bounds.getHeight()).
put(x + bounds.getWidth()).put(y + bounds.getHeight()).
put(x + bounds.getWidth()).put(y + bounds.getY());
vertex.flip();
// glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, 0, tex);
glVertexPointer(2, 0, vertex);
glDrawArrays(GL_QUADS, 0, 4);
// glDisableClientState(GL_TEXTURE_COORD_ARRAY);
// glDisableClientState(GL_VERTEX_ARRAY);
// draw a quad textured to match the sprite
/*glBegin(GL_QUADS);
glTexCoord2f(texture.getTexX(), texture.getTexY());
glVertex2f(x + bounds.getX(), y + bounds.getY());
glTexCoord2f(texture.getTexX(), texture.getHeight());
glVertex2f(x + bounds.getX(), y + bounds.getHeight());
glTexCoord2f(texture.getWidth(), texture.getHeight());
glVertex2f(x + bounds.getWidth(), y + bounds.getHeight());
glTexCoord2f(texture.getWidth(), texture.getTexY());
glVertex2f(x + bounds.getWidth(), y + bounds.getY());
glEnd();*/
}