public override void Render(World world, Faces faces, RenderSettings settings) { base.Render(world, faces, settings); GL.glDisable(GL.GL_BLEND); GL.glEnable(GL.GL_COLOR_MATERIAL); if (settings.Textures) { GL.glEnable(GL.GL_TEXTURE_2D); } else { GL.glDisable(GL.GL_TEXTURE_2D); } if (settings.ZBuffer) { GL.glEnable(GL.GL_DEPTH_TEST); } else { GL.glDisable(GL.GL_DEPTH_TEST); } GL.glPolygonMode(GL.GL_FRONT_AND_BACK, (settings.Wireframe) ? GL.GL_LINE : GL.GL_FILL); Color clr = Color.White; Vector3D light = world.Light; foreach (Face face in faces) { int vertexCount = face.Points.Count; Vector3DCollection worldCoords = face.Points; Vector3DCollection textureCoords = null; Vector3D normal = face.Normal; if (settings.FaceColors) { clr = face.Color; } bool texture = (settings.Textures && face.IsTexture); if (settings.Textures) { if (texture) { GL.glEnable(GL.GL_TEXTURE_2D); GL.glBindTexture(GL.Texture.Texture2D, face.Texture.OpenGLHandle); textureCoords = face.TextureCoords; } else { GL.glDisable(GL.GL_TEXTURE_2D); } } GL.glBegin(GL.Primative.Polygon); bool vertexNormals = face.IsVertexNormals; for (int index = 0; index < vertexCount; index++) { Vector3D worldCoord = worldCoords[index]; if (vertexNormals) { normal = face.VertexNormals[index]; } RenderUtils.glColor_PhongIllumination(clr, worldCoord, normal, light, Color.White, light, 30); if (texture) { RenderUtils.glTexture(textureCoords[index]); } RenderUtils.glVertex(worldCoord); } GL.glEnd(); } }