HUD scaling

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

HUD scaling

morello
I am trying to create a hud using the technique of drawing on a BufferedImage, then using the image as a texture on a rectangle. I render the rectangle in orthographic mode. The parts of the image which don't contain controls are transparent so the 3D world can be seen.

Well it works fine, but I can't work out how to scale things so the image exactly fills the screen. Ideally I would like the buffered image to be exactly the size of the window, so items are placed on the screen exactly as if they were using Java2D.

Here is my code:

gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -5.0f);
gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
gl.glOrtho(-1, 1, -1, 1, -1.0, 1.0);
getTexture(gl, 128, 128);
gl.glBegin(GL.GL_POLYGON);
gl.glTexCoord2d(0f, 0f);
gl.glVertex2f(-0.5f, -0.5f);
gl.glTexCoord2d(1, 0f);
gl.glVertex2f(-0.5f, 0.5f);
gl.glTexCoord2d(1, 1);
gl.glVertex2f(0.5f, 0.5f);
gl.glTexCoord2d(0f, 1);
gl.glVertex2f(0.5f, -0.5f);
gl.glEnd();

I am also finding that if I don't do a glTranslatef, or if the translation is too small (eg -4) the polygon is not visible at all.

Anyone have an example of how to do this?
Reply | Threaded
Open this post in threaded view
|

Re: HUD scaling

Demoscene Passivist
Administrator
Try using com.jogamp.opengl.util.awt.Overlay ... its made for such purpose :)
Reply | Threaded
Open this post in threaded view
|

Re: HUD scaling

morello
I am still using Jogl 1.1.1, is the Overlay componnet available for that? Where do I get it?

Failing that, is Jogl V2 ready to use yet? Last time I looked (last year) it didn't seem to be.
Reply | Threaded
Open this post in threaded view
|

Re: HUD scaling

Demoscene Passivist
Administrator
>I am still using Jogl 1.1.1, is the Overlay componnet available for that? Where do I get it?

As far as I remember it was already present back in the days of JOGL 1.1.1a

>Failing that, is Jogl V2 ready to use yet? Last time I looked (last year) it didn't seem to be.

I would recommend switching to the JOGL2 release candidate. Its quite stable.
Reply | Threaded
Open this post in threaded view
|

Re: HUD scaling

morello
Thanks, I will move over to a newer version when I get the chance.