Reputation: 4436
For various reasons, I like having openGL to use coordinates other than pixels, which is easily set via:
Display.setDisplayMode(new DisplayMode(800, 600));
GLU.gluOrtho2D(0f,32f,0f,24f);
However, now that I've begun trying to integrate Nifty GUI into my application, this corrdinate scale is causing problems. Namely, Nifty seems to think openGL is using pixels as units, and thus renders everything gigantic. Is there anyway to fix this?
Upvotes: 1
Views: 267
Reputation: 474236
Why not just do things the way NiftyGUI wants (pixel coordinates), but only while NiftyGUI is being rendered. This means:
gl.glMatrixMode(gl.GL_PROJECTION_MATRIX);
GLU.gluOrtho2D(0f,32f,0f,24f);
//Render my stuff
gl.glMatrixMode(gl.GL_PROJECTION_MATRIX);
gl.glLoadIdentity();
GLU.gluOrtho2D(0f,width,0f,height);
//Render with NiftyGUI.
Upvotes: 2
Reputation: 162297
You made the classic OpenGL newbie mistake: One time state setting.
OpenGL is not initialized. You re-set every state as you go and as you need it. Do in your case it's completely in order to set the projection matrix to a pixel mapping ortho projection whenever needed and to something else when using Nifty.
Upvotes: 1