为什么我的圆筒没有固体形状?它看起来像透明的另一面,我希望它是坚实的,只有在外面的颜色 这是我的源代码
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GL.glLoadIdentity();
GL.glTranslatef(0.0f, 0.0f, -50);
GL.glRotatef(this.xrot, 1.0f, 0.0f, 0.0f); //rotate searah x
GL.glRotatef(this.yrot, 0.0f, 1.0f, 0.0f); //rotate searah y
GL.glRotatef(this.zrot, 0.0f, 0.0f, 1.0f); //rotate searah z
GL.glBegin(GL.GL_POLYGON); //mulai gambar gl polygon
for (iogl = 0; (iogl <= 359); iogl++)
{
//Tabung
GL.glColor3f(1, 1, 1);
GL.glVertex3f(4 * (float)Math.Sin(Math.PI / 180 * iogl), 4 * (float)Math.Cos(Math.PI / 180 * iogl), 25);
GL.glVertex3f(4 * (float)Math.Sin(Math.PI / 180 * (iogl + 30)), 4 * (float)Math.Cos(Math.PI / 180 * (iogl + 30)), 25);
GL.glColor3f(1, 0, 0);
GL.glVertex3f(4 * (float)Math.Sin(Math.PI / 180 * iogl), 4 * (float)Math.Cos(Math.PI / 180 * iogl), 6);
GL.glVertex3f(4 * (float)Math.Sin(Math.PI / 180 * (iogl + 30)), 4 * (float)Math.Cos(Math.PI / 180 * (iogl + 30)), 6);
}
GL.glEnd();
this.xrot += this.xspeed; //tambah kcepatan searah x
this.yrot += this.yspeed; //tambah kcepatan searah y
}
}
答案 0 :(得分:2)
glEnable(GL_DEPTH_TEST)
)。