I’ve been searching through this forum and I can’t find anyone with the same problem as what I’m getting.
As soon as I try and render a texture on my HUD the renderer runs around 1.5 frames a second, compared to the 300+ that I am normally getting. I use the begin2D() and end2D() that I found elsewhere on this forum.
public void begin2D() {
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glOrtho(0.0f, getWidth(), getHeight(), 0.0f, -1.0f, 1.0f);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glDisable(GL.GL_LIGHTING);
}
public void end2D() {
gl.glEnable(GL.GL_LIGHTING);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPopMatrix();
}
The code I use to draw the HUD itself is as follows (extremely simple at the moment until I sort this problem out)
textureManager.bindTexture("hud");
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(0, 1);
gl.glVertex3f(0, 550, 0);
gl.glTexCoord2f(1, 1);
gl.glVertex3f(800, 550, 0);
gl.glTexCoord2f(1, 0);
gl.glVertex3f(800, 600, 0);
gl.glTexCoord2f(0, 0);
gl.glVertex3f(0, 600, 0);
gl.glEnd();
If I disable 2D texturing everything runs at normal speed, it is only when texturing is enabled everything slows down. But without the HUD texturing runs at normal speed as I have a rotating model I have loaded, which is fully textured. I did some debugging and found out it takes 0.2 seconds to render the HUD and on the gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); immediately after (on the next render cycle) it takes another 0.4 seconds. I have no idea why it is doing this and my the development of my application is pretty much at a stand still until I get this sorted.
I’m hoping someone else is already aware of this problem and knows the solution.
Thanks in advance,
Jargon