LEFT | RIGHT |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 glDisableClientState(GL_NORMAL_ARRAY); | 111 glDisableClientState(GL_NORMAL_ARRAY); |
112 if (!wireframe) { | 112 if (!wireframe) { |
113 glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 113 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
114 glDisableClientState(GL_COLOR_ARRAY); | 114 glDisableClientState(GL_COLOR_ARRAY); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 void RAS_StorageVA::IndexPrimitivesMulti(class RAS_MeshSlot& ms) | 118 void RAS_StorageVA::IndexPrimitivesMulti(class RAS_MeshSlot& ms) |
119 { | 119 { |
120 static const GLsizei stride = sizeof(RAS_TexVert); | 120 static const GLsizei stride = sizeof(RAS_TexVert); |
121 » bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME; | 121 » bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_col
or_array; |
122 RAS_MeshSlot::iterator it; | 122 RAS_MeshSlot::iterator it; |
123 GLenum drawmode; | 123 GLenum drawmode; |
124 | 124 |
125 if (!wireframe) | 125 if (!wireframe) |
126 EnableTextures(true); | 126 EnableTextures(true); |
127 glEnableClientState(GL_VERTEX_ARRAY); | 127 glEnableClientState(GL_VERTEX_ARRAY); |
128 glEnableClientState(GL_NORMAL_ARRAY); | 128 glEnableClientState(GL_NORMAL_ARRAY); |
129 | 129 |
130 // use glDrawElements to draw each vertexarray | 130 // use glDrawElements to draw each vertexarray |
131 for (ms.begin(it); !ms.end(it); ms.next(it)) { | 131 for (ms.begin(it); !ms.end(it); ms.next(it)) { |
132 if (it.totindex == 0) | 132 if (it.totindex == 0) |
133 continue; | 133 continue; |
134 | 134 |
135 // drawing mode | 135 // drawing mode |
136 if (it.array->m_type == RAS_DisplayArray::TRIANGLE) | 136 if (it.array->m_type == RAS_DisplayArray::TRIANGLE) |
137 drawmode = GL_TRIANGLES; | 137 drawmode = GL_TRIANGLES; |
138 else if (it.array->m_type == RAS_DisplayArray::QUAD) | 138 else if (it.array->m_type == RAS_DisplayArray::QUAD) |
139 drawmode = GL_QUADS; | 139 drawmode = GL_QUADS; |
140 else | 140 else |
141 drawmode = GL_LINES; | 141 drawmode = GL_LINES; |
142 | 142 |
143 // colors | 143 // colors |
144 if (drawmode != GL_LINES && !wireframe) { | 144 if (drawmode != GL_LINES && !wireframe) { |
145 if (ms.m_bObjectColor) { | 145 if (ms.m_bObjectColor) { |
146 const MT_Vector4& rgba = ms.m_RGBAcolor; | 146 const MT_Vector4& rgba = ms.m_RGBAcolor; |
147 | 147 |
148 glDisableClientState(GL_COLOR_ARRAY); | 148 glDisableClientState(GL_COLOR_ARRAY); |
149 glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); | 149 glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); |
| 150 use_color_array = false; |
150 } | 151 } |
151 else { | 152 else { |
152 glColor4f(0.0f, 0.0f, 0.0f, 1.0f); | 153 glColor4f(0.0f, 0.0f, 0.0f, 1.0f); |
153 glEnableClientState(GL_COLOR_ARRAY); | 154 glEnableClientState(GL_COLOR_ARRAY); |
| 155 use_color_array = true; |
154 } | 156 } |
155 } | 157 } |
156 else | 158 else |
157 glColor4f(0.0f, 0.0f, 0.0f, 1.0f); | 159 glColor4f(0.0f, 0.0f, 0.0f, 1.0f); |
158 | 160 |
159 glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ()); | 161 glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ()); |
160 glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal()); | 162 glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal()); |
| 163 |
161 if (!wireframe) { | 164 if (!wireframe) { |
162 TexCoordPtr(it.vertex); | 165 TexCoordPtr(it.vertex); |
163 » » » if (glIsEnabled(GL_COLOR_ARRAY)) | 166 » » » if (use_color_array) |
164 glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.v
ertex->getRGBA()); | 167 glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.v
ertex->getRGBA()); |
165 } | 168 } |
166 | 169 |
167 // here the actual drawing takes places | 170 // here the actual drawing takes places |
168 glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.inde
x); | 171 glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.inde
x); |
169 } | 172 } |
170 ········ | 173 ········ |
171 glDisableClientState(GL_VERTEX_ARRAY); | 174 glDisableClientState(GL_VERTEX_ARRAY); |
172 glDisableClientState(GL_NORMAL_ARRAY); | 175 glDisableClientState(GL_NORMAL_ARRAY); |
173 if (!wireframe) { | 176 if (!wireframe) { |
174 glDisableClientState(GL_COLOR_ARRAY); | 177 glDisableClientState(GL_COLOR_ARRAY); |
175 EnableTextures(false); | 178 EnableTextures(false); |
176 } | 179 } |
177 } | 180 } |
178 | 181 |
179 void RAS_StorageVA::TexCoordPtr(const RAS_TexVert *tv) | 182 void RAS_StorageVA::TexCoordPtr(const RAS_TexVert *tv) |
180 { | 183 { |
181 /* note: this function must closely match EnableTextures to enable/disab
le | 184 /* note: this function must closely match EnableTextures to enable/disab
le |
182 * the right arrays, otherwise coordinate and attribute pointers from ot
her | 185 * the right arrays, otherwise coordinate and attribute pointers from ot
her |
183 * materials can still be used and cause crashes */ | 186 * materials can still be used and cause crashes */ |
184 int unit; | 187 int unit; |
185 | 188 |
186 if (GLEW_ARB_multitexture) | 189 if (GLEW_ARB_multitexture) |
187 { | 190 { |
188 for (unit = 0; unit < *m_texco_num; unit++) | 191 for (unit = 0; unit < *m_texco_num; unit++) |
189 { | 192 { |
190 glClientActiveTextureARB(GL_TEXTURE0_ARB+unit); | 193 glClientActiveTextureARB(GL_TEXTURE0_ARB+unit); |
191 » » » switch (m_texco[unit]) | 194 » » » switch (m_texco[unit]) { |
192 » » » { | |
193 case RAS_IRasterizer::RAS_TEXCO_ORCO: | 195 case RAS_IRasterizer::RAS_TEXCO_ORCO: |
194 case RAS_IRasterizer::RAS_TEXCO_GLOB: | 196 case RAS_IRasterizer::RAS_TEXCO_GLOB: |
195 glTexCoordPointer(3, GL_FLOAT, sizeof(RA
S_TexVert),tv->getXYZ()); | 197 glTexCoordPointer(3, GL_FLOAT, sizeof(RA
S_TexVert),tv->getXYZ()); |
196 break; | 198 break; |
197 case RAS_IRasterizer::RAS_TEXCO_UV: | 199 case RAS_IRasterizer::RAS_TEXCO_UV: |
198 glTexCoordPointer(2, GL_FLOAT, sizeof(RA
S_TexVert),tv->getUV(unit)); | 200 glTexCoordPointer(2, GL_FLOAT, sizeof(RA
S_TexVert),tv->getUV(unit)); |
199 break; | 201 break; |
200 case RAS_IRasterizer::RAS_TEXCO_NORM: | 202 case RAS_IRasterizer::RAS_TEXCO_NORM: |
201 glTexCoordPointer(3, GL_FLOAT, sizeof(RA
S_TexVert),tv->getNormal()); | 203 glTexCoordPointer(3, GL_FLOAT, sizeof(RA
S_TexVert),tv->getNormal()); |
202 break; | 204 break; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 texco = m_last_texco; | 262 texco = m_last_texco; |
261 texco_num = m_last_texco_num; | 263 texco_num = m_last_texco_num; |
262 attrib = m_last_attrib; | 264 attrib = m_last_attrib; |
263 attrib_num = m_last_attrib_num; | 265 attrib_num = m_last_attrib_num; |
264 } | 266 } |
265 | 267 |
266 if (GLEW_ARB_multitexture) { | 268 if (GLEW_ARB_multitexture) { |
267 for (unit = 0; unit < texco_num; unit++) { | 269 for (unit = 0; unit < texco_num; unit++) { |
268 glClientActiveTextureARB(GL_TEXTURE0_ARB + unit); | 270 glClientActiveTextureARB(GL_TEXTURE0_ARB + unit); |
269 | 271 |
270 » » » switch (texco[unit]) | 272 » » » switch (texco[unit]) { |
271 » » » { | |
272 case RAS_IRasterizer::RAS_TEXCO_ORCO: | 273 case RAS_IRasterizer::RAS_TEXCO_ORCO: |
273 case RAS_IRasterizer::RAS_TEXCO_GLOB: | 274 case RAS_IRasterizer::RAS_TEXCO_GLOB: |
274 case RAS_IRasterizer::RAS_TEXCO_UV: | 275 case RAS_IRasterizer::RAS_TEXCO_UV: |
275 case RAS_IRasterizer::RAS_TEXCO_NORM: | 276 case RAS_IRasterizer::RAS_TEXCO_NORM: |
276 case RAS_IRasterizer::RAS_TEXTANGENT: | 277 case RAS_IRasterizer::RAS_TEXTANGENT: |
277 if (enable) glEnableClientState(GL_TEXTU
RE_COORD_ARRAY); | 278 if (enable) glEnableClientState(GL_TEXTU
RE_COORD_ARRAY); |
278 else glDisableClientState(GL_TEXTURE_COO
RD_ARRAY); | 279 else glDisableClientState(GL_TEXTURE_COO
RD_ARRAY); |
279 break; | 280 break; |
280 default: | 281 default: |
281 glDisableClientState(GL_TEXTURE_COORD_AR
RAY); | 282 glDisableClientState(GL_TEXTURE_COORD_AR
RAY); |
(...skipping 28 matching lines...) Expand all Loading... |
310 } | 311 } |
311 } | 312 } |
312 } | 313 } |
313 | 314 |
314 if (!enable) { | 315 if (!enable) { |
315 m_last_texco_num = 0; | 316 m_last_texco_num = 0; |
316 m_last_attrib_num = 0; | 317 m_last_attrib_num = 0; |
317 } | 318 } |
318 } | 319 } |
319 | 320 |
LEFT | RIGHT |