我使用Tao Framework,但使用时出现问题 glLoadIdentity()
,我正在gluDisk
成功将图片加载到a,我可以看到图片,然后当我尝试使用gluLookAt
已加载的图片更改相机的位置时gluDisk
消失了,而是,我看到的只是一种颜色,提醒我加载的图片的背景颜色,在使用调试后我看到它是因为glLoadIdentity()
功能而发生的。
这是重绘磁盘的函数:
Gl.glClearColor(0F, 0F, 0F, 1.0F);
while (true)
{
world.drawWorld();
Application.DoEvents();
Thread.Sleep(20);
}
这是我更改外观的代码:
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glMatrixMode(Gl.GL_MODELVIEW); //Switch to the drawing perspective
Gl.glLoadIdentity();
switch (Convert.ToInt32(e.KeyChar))
{
//down arrow
case 76:
rotAngle -= 0.5f;
rotY -= 0.1f;
//rotX = 0;
break;
//up arrow
case 82:
rotAngle += 0.5f;
rotY += 0.1f;
//rotX = 0;
break;
// left arrow
case 85:
rotAngle -= 0.5f;
//rotY = 0;
rotX -= 0.1f;
break;
//right arrow
case 68:
rotAngle += 0.5f;
//rotY = 0;
rotX += 0.1f;
break;
case 'a':
xMove -= 1;
Glu.gluLookAt(xMove, yMove, zMove, xMove + 2, yMove + 2, zMove + 2, 0, 1, 0);
break;
case 'd':
xMove += 1;
Glu.gluLookAt(xMove, yMove, zMove, xMove + 2, yMove + 2, zMove + 2, 0, 1, 0);
break;
case 'w':
yMove +=1;
Glu.gluLookAt(xMove, yMove, zMove, xMove + 2, yMove + 2, zMove + 2, 0, 1, 0);
break;
case 's':
yMove -= 1;
Glu.gluLookAt(xMove, yMove, zMove, xMove + 2, yMove + 2, zMove + 2, 0, 1, 0);
break;
case 'z':
zMove += 1F;
Glu.gluLookAt(xMove, yMove, zMove, 0, 0, 0, 0, 1, 0);
break;
case 'x':
zMove -= 1F;
Glu.gluLookAt(xMove, yMove, zMove, 0, 0, 0, 0, 1, 0);
break;
case '0':
//zMove -= 1F;
Glu.gluLookAt(1, 1, 1, 0, 0, 0, 0, 1, 0);
break;
这是我的绘图代码:
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
Gl.glEnable(Gl.GL_TEXTURE_2D);
LoadTexture();
Glu.GLUquadric qobj = Glu.gluNewQuadric();
Glu.gluQuadricTexture(qobj, Gl.GL_TRUE);
//Glut.glutSetCursor(Glut.GLUT_CURSOR_NONE);
Gl.glPushMatrix();
Gl.glRotatef(80f, 1.0f, 0.0f, 0.0f);
Glu.gluDisk (qobj,0, 800, 900, 300);
Gl.glPopMatrix();