LWJGL使用像素坐标代替OpenGL坐标

时间:2014-01-14 12:04:30

标签: java opengl lwjgl

因此,在尝试使用LWJGL在java中执行Hello World三角形时,我想知道为什么三角形没有出现。事实证明,它使用的坐标是像素,所以

    public void setupGL()
{

    glMatrixMode(GL11.GL_PROJECTION);

    glLoadIdentity();
    float ratio = frame.getWidth() / frame.getHeight();

    glOrtho(0, -ratio, 0, ratio, -1f, 1f);
    glViewport(0, 0, 800, 500);

    glMatrixMode(GL_MODELVIEW);
}


{glBegin(GL11.GL_TRIANGLES);
      {
        glColor3f(1.0f,0.0f,0.0f);
        glVertex3f(0.0f,0.0f,0.0f);

        glColor3f(0.0f,1.0f,0.0f);
        glVertex3f(5f,0.0f,0.0f);

        glColor3f(0.0f,0.0f,1.0f);
        glVertex3f(5f,5f,0.0f);
      }
      glEnd();}

产生 Image

(注意底部非常小的三角形)

如何将其转换为使用传统的GL坐标?

0 个答案:

没有答案