因此,在尝试使用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();}
产生
(注意底部非常小的三角形)
如何将其转换为使用传统的GL坐标?