2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 #include "BSP_MeshDrawer.h"
30 #include "BSP_TMesh.h"
32 #if defined(WIN32) || defined(__APPLE__)
40 #else // defined(WIN32) || defined(__APPLE__)
43 #endif // defined(WIN32) || defined(__APPLE__)
57 if (render_mode == e_none) return;
59 // decompose polygons into triangles.
61 glEnable(GL_LIGHTING);
64 if (render_mode == e_wireframe || render_mode == e_wireframe_shaded) {
66 glColor3f(0.0, 0.0, 0.0);
68 if (render_mode == e_wireframe) {
69 glDisable(GL_LIGHTING);
71 glEnable(GL_LIGHTING);
74 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
76 glEnable(GL_POLYGON_OFFSET_FILL);
77 glPolygonOffset(1.0,1.0);
79 glBegin(GL_TRIANGLES);
83 glColor3f(1.0, 1.0, 1.0);
84 glDisable(GL_LIGHTING);
85 glDisable(GL_POLYGON_OFFSET_FILL);
86 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
88 glBegin(GL_TRIANGLES);
91 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
94 glEnable(GL_LIGHTING);
96 glBegin(GL_TRIANGLES);
111 const vector<BSP_TVertex> & verts = mesh.VertexSet();
112 const vector<BSP_TFace> &faces = mesh.FaceSet();
114 // just draw the edges for now.
116 vector<BSP_TVertex>::const_iterator vertex_it = verts.begin();
119 vector<BSP_TFace>::const_iterator faces_it = faces.begin();
120 vector<BSP_TFace>::const_iterator faces_end = faces.end();
122 for (;faces_it != faces_end; ++faces_it ){
125 faces_it->m_normal.x(),
126 faces_it->m_normal.y(),
127 faces_it->m_normal.z()
131 verts[faces_it->m_verts[0]].m_pos.x(),
132 verts[faces_it->m_verts[0]].m_pos.y(),
133 verts[faces_it->m_verts[0]].m_pos.z()
136 verts[faces_it->m_verts[1]].m_pos.x(),
137 verts[faces_it->m_verts[1]].m_pos.y(),
138 verts[faces_it->m_verts[1]].m_pos.z()
141 verts[faces_it->m_verts[2]].m_pos.x(),
142 verts[faces_it->m_verts[2]].m_pos.y(),
143 verts[faces_it->m_verts[2]].m_pos.z()