public void BuildDecalMesh(DMesh dm) { GL.PushMatrix(); GL.DeleteLists(GL_DECAL, 1); GL.NewList(GL_DECAL, ListMode.Compile); int tex_id = -1; { GL.Color3(Color.White); for (int i = 0; i < dm.polygon.Count; i++) { if (dm.polygon[i].flags == (int)FaceFlags.NO_COLLIDE) { if (editor.m_vis_type == VisibilityType.NO_RENDER || editor.m_vis_type == VisibilityType.NORMAL_ONLY) { continue; } GL.Color3(Color.LightYellow); } else if (dm.polygon[i].flags == (int)FaceFlags.NO_RENDER) { if (editor.m_vis_type == VisibilityType.NO_COLLIDE || editor.m_vis_type == VisibilityType.NORMAL_ONLY) { continue; } GL.Color3(Color.LightPink); } else if (dm.polygon[i].flags == (int)FaceFlags.NO_COLLIDE + (int)FaceFlags.NO_RENDER) { // This is a pointless face GL.Color3(Color.DarkRed); } else { GL.Color3(dm.GetPolyColor(dm.polygon[i])); } if (dm.m_tex_gl_id == null || dm.polygon[i].tex_index >= dm.m_tex_gl_id.Count) { // Set nothing, "invalid" texture GL.BindTexture(TextureTarget.Texture2D, -1); } else if (dm.polygon[i].tex_index < 0 || dm.m_tex_gl_id[dm.polygon[i].tex_index] < 0) { GL.BindTexture(TextureTarget.Texture2D, -1); } else if (tex_id != dm.m_tex_gl_id[dm.polygon[i].tex_index]) { tex_id = dm.m_tex_gl_id[dm.polygon[i].tex_index]; GL.BindTexture(TextureTarget.Texture2D, tex_id); } GL.Begin(PrimitiveType.Polygon); CreatePolygon(dm.polygon[i], dm); GL.End(); } } GL.EndList(); GL.PopMatrix(); }