Textured HUD refreshing extremely slowly :(

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. :frowning:

I’m hoping someone else is already aware of this problem and knows the solution. :slight_smile:

Thanks in advance,
Jargon

I gotta ask: is there anything special about this texture? A texture that brings you from 300+ FPS to 1.5 must have some sort of voodoo magic associated with it :slight_smile:
Seriously, is there anything special about this HUD texture? (Is it a non-power-of-two texture and your card doesn’t support NPOT textures so you’ve got some sort of very-slow fix? Is it a really really large texture?)

In addition, what video card do you have? Also, does textureManager.bind(…) do anything apart from (what I’m assuming is) looking-up the texture ID mapped to the name ‘hud’ and binding that texture ID?

And since I don’t know what this begin2D() / end2D() thing is (sorry, I haven’t been through that many JOGL topics to know), I’m assuming they’re just methods run before and after the actual rendering loop? Or are you actually using them before and after the drawing of the HUD texture within the rendering loop? (because that might slow things down; there are a lot of GL calls in those methods)

Yeah, more questions rather than answers, but I can’t tell what could be going-on from your first post :frowning:

I’d guess at a non-power-of-two texture as well. In particular the FX5200 cards “support” NPOT textures (ie. don’t crash or complain if you load them) but don’t support them in hardware, so you get a hideously slow software fallback. Theres probably other cards which have similar behaviour.

Ugh I can’t believe I overlooked that :slight_smile:

It was a non-power of 2 problem. My renderer I am working on was shelved a long time ago and I have only recently continued work on it. So when I came around to making the HUD texture I totally overlooked it. So when I came to testing, all the old textures worked fine (because they were power of 2) and the HUD didn’t.

This leads me to another question, how does one go about making textures for a HUD without having them stretched or squished? If I have a toolbar aligned along the bottom of the screen about 50 pixels in height, do I make my image like normal then stretch it to some power of 2 so its distorted and let JOGL unstretch when applying it the quad?

Anyway, thanks for the help. I guess I can continue working on it now :smiley: Also, 1 last thing, is around 360 fps good/bad/average for having 1 textured model (quite a low polygon count) rendering? I thought it seemed a bit low for the simplicity of the scene. I am using the standard animator though, not sure if that has some fixed refresh limit, hmmm.

There’s no need to render your hud stretched into the texture, just render as normal and use the appropriate texture coordinates to get the bits you want. eg: If your GUI texture is, say, 512x512, and your toolbar is 100x50, just render the toolbar as normal into the texture, and then use texture coordinates ( 0, 0 ), ( 100/512, 0 ), ( 0, 50/512 ), ( 100/512, 50/512 ) on your quad.

As to your performance worries, it’s really difficult to say how a system will scale based on a single datapoint.