我有一个很奇怪的问题。请看这些截图:
该对象的代码:
void prostopadloscian(float x, float y, float z, float red, float green, float blue)
{
glBegin(GL_QUADS);
glColor3f(red, green, blue);
glNormal3f(-x,-y,-z);
glVertex3f(-x,-y,-z);
glNormal3f(x,-y,-z);
glVertex3f(x,-y,-z);
glNormal3f(x,-y,z);
glVertex3f(x,-y,z);
glNormal3f(-x,-y,z);
glVertex3f(-x,-y,z);
glNormal3f(-x,y,-z);
glVertex3f(-x,y,-z);
glNormal3f(x,y,-z);
glVertex3f(x,y,-z);
glNormal3f(x,y,z);
glVertex3f(x,y,z);
glNormal3f(-x,y,z);
glVertex3f(-x,y,z);
glNormal3f(-x,y,z);
glVertex3f(-x,y,z);
glNormal3f(-x,-y,z);
glVertex3f(-x,-y,z);
glNormal3f(-x,-y,-z);
glVertex3f(-x,-y,-z);
glNormal3f(-x,y,-z);
glVertex3f(-x,y,-z);
glNormal3f(-x,-y,-z);
glVertex3f(-x,-y,-z);
glNormal3f(x,-y,-z);
glVertex3f(x,-y,-z);
glNormal3f(x,y,-z);
glVertex3f(x,y,-z);
glNormal3f(-x,y,-z);
glVertex3f(-x,y,-z);
glNormal3f(x,y,z);
glVertex3f(x,y,z);
glNormal3f(x,-y,z);
glVertex3f(x,-y,z);
glNormal3f(x,-y,-z);
glVertex3f(x,-y,-z);
glNormal3f(x,y,-z);
glVertex3f(x,y,-z);
glNormal3f(-x,y,z);
glVertex3f(-x,y,z);
glNormal3f(-x,-y,z);
glVertex3f(-x,-y,z);
glNormal3f(-x,-y,-z);
glVertex3f(-x,-y,-z);
glNormal3f(-x,y,-z);
glVertex3f(-x,y,-z);
glEnd();
}
void bed()
{
glPushMatrix();
glTranslatef(-1.6, 0, 4.6);
prostopadloscian(0.2, 0.25, 0.2, 0.35, 0.16, 0.14);
glPopMatrix();
glPushMatrix();
glTranslatef(1.6, 0, 4.6);
prostopadloscian(0.2, 0.25, 0.2, 0.35, 0.16, 0.14);
glPopMatrix();
glPushMatrix();
glTranslatef(-1.6, 0, -4.6);
prostopadloscian(0.2, 0.25, 0.2, 0.35, 0.16, 0.14);
glPopMatrix();
glPushMatrix();
glTranslatef(1.6, 0, -4.6);
prostopadloscian(0.2, 0.25, 0.2, 0.35, 0.16, 0.14);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0, 0.55, 0.0);
prostopadloscian(2,0.3,5,0.85,0.85,0.95);
glPopMatrix();
}
我的display()函数从
开始glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0, 1.0, 1.0, 1.0);
glEnable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);
glLoadIdentity();
如何摆脱这种难看的效果?
答案 0 :(得分:2)
glNormal
电话。)答案 1 :(得分:1)
如果这种影响是间歇性的,我会认为Z战斗可能正在发生。您是否尝试使用glPolygonOffset绘制桌面?