I'm drawing many tiles on the screen and it's causing much lag. I can't draw all tiles in one glBegin, because they are using different translations.
This is my drawing code:
public static void drawTexture(Texture texture, Vector2f position, Vector2f translation, Vector2f origin, Vector2f scale, float rotation, Color color, FlipState flipState)
{
texture.setTextureFilter(GL11.GL_NEAREST);
float xFlip = (flipState == FlipState.Both || flipState == FlipState.Horizontal) ? -1 : 1;
float yFlip = (flipState == FlipState.Both || flipState == FlipState.Vertical) ? -1 : 1;
color.bind();
texture.bind();
GL11.glTranslatef(position.x, position.y, 0);
GL11.glTranslatef(-translation.x, -translation.y, 0);
GL11.glRotated(rotation, 0f, 0f, 1f);
GL11.glScalef(scale.x, scale.y, 1);
GL11.glScalef(xFlip, yFlip, 1);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(0, 0);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(texture.getTextureWidth(), 0);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(texture.getTextureWidth(), texture.getTextureHeight());
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(0, texture.getTextureHeight());
GL11.glEnd();
GL11.glLoadIdentity();
}
Is it possible to make this drawing faster? I'm drawing the tiles in a loop. I tried putting glBegin before the loop, but it didn't translate correctly.