1

由于各种原因,我喜欢让 openGL 使用像素以外的坐标,这可以通过以下方式轻松设置:

Display.setDisplayMode(new DisplayMode(800, 600));
GLU.gluOrtho2D(0f,32f,0f,24f);

然而,现在我已经开始尝试将 Nifty GUI 集成到我的应用程序中,这种坐标比例正在引起问题。也就是说,Nifty 似乎认为 openGL 使用像素作为单位,因此将一切渲染为巨大。有没有什么办法解决这一问题?

4

2 回答 2

2

为什么不只是按照 NiftyGUI 想要的方式(像素坐标)做事,而只是在渲染 NiftyGUI 时。这表示:

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.
于 2012-11-15T21:17:27.700 回答
1

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.

于 2012-11-15T21:16:03.363 回答