当我可以自己排列位置数学时,推动/弹出矩阵来转换形状的目的是什么?我可以理解使用上述矩阵做更困难的操作(例如旋转),但为什么要特别翻译?我为什么要使用glTranslate?
public void render()
{
positionX++;
GL.PushMatrix();
GL.Translate(positionX, positionY, 0);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.Begin(PrimitiveType.Quads);
GL.Vertex2(0, 0);
GL.Vertex2(0 + widthX, 0);
GL.Vertex2(0 + widthX, 0 + widthY);
GL.Vertex2(0, 0 + widthY);
GL.PopMatrix();
GL.End();
}
与
public void render()
{
positionX++;
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.Begin(PrimitiveType.Quads);
GL.Vertex2(positionX, positionY);
GL.Vertex2(positionX + widthX, positionY);
GL.Vertex2(positionX + widthX, positionY + widthY);
GL.Vertex2(positionX, positionY + widthY);
GL.End();
}
一般来说,矩阵的使用允许轻松地链接操作。不知道这是*的原因,或者它是否回答你的问题。 – BradleyDotNET 2014-12-01 22:38:15
你不应该;该函数与GL.Begin和GL.End函数一起被弃用 – 2014-12-01 22:40:47
在'glTranslatef'后面添加'glRotatef(45,0,0,1)',并运行程序。现在将'glRotatef'移动到'glTranslatef'之前,然后重新运行你的程序。 – 2014-12-01 22:43:19