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. The Blender | 7 * of the License, or (at your option) any later version. |
8 * Foundation also sells licenses for use in proprietary software under | |
9 * the Blender License. See http://www.blender.org/BL/ for information | |
10 * about this. | |
11 * | 8 * |
12 * 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, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
16 * | 13 * |
17 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
18 * along with this program; if not, write to the Free Software Foundation, | 15 * along with this program; if not, write to the Free Software Foundation, |
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 * | 17 * |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "IMB_imbuf.h" | 52 #include "IMB_imbuf.h" |
56 #include "IMB_imbuf_types.h" | 53 #include "IMB_imbuf_types.h" |
57 | 54 |
58 #include "BKE_bmfont.h" | 55 #include "BKE_bmfont.h" |
59 #include "BKE_global.h" | 56 #include "BKE_global.h" |
60 #include "BKE_image.h" | 57 #include "BKE_image.h" |
61 #include "BKE_main.h" | 58 #include "BKE_main.h" |
62 #include "BKE_material.h" | 59 #include "BKE_material.h" |
63 #include "BKE_node.h" | 60 #include "BKE_node.h" |
64 #include "BKE_object.h" | 61 #include "BKE_object.h" |
65 | 62 #include "BKE_scene.h" |
| 63 #include "BKE_DerivedMesh.h" |
66 | 64 |
67 #include "BLI_threads.h" | 65 #include "BLI_threads.h" |
68 #include "BLI_blenlib.h" | 66 #include "BLI_blenlib.h" |
69 | 67 |
70 #include "GPU_buffers.h" | 68 #include "GPU_buffers.h" |
71 #include "GPU_draw.h" | 69 #include "GPU_draw.h" |
72 #include "GPU_extensions.h" | 70 #include "GPU_extensions.h" |
73 #include "GPU_material.h" | 71 #include "GPU_material.h" |
74 | 72 |
75 #include "smoke_API.h" | 73 #include "smoke_API.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 &sizex, &sizey, &transx, &transy, &movex, &movey
, &advance); | 147 &sizex, &sizey, &transx, &transy, &movex, &movey
, &advance); |
150 | 148 |
151 uv[0][0] = (tface->uv[0][0] - centerx) * sizex + transx; | 149 uv[0][0] = (tface->uv[0][0] - centerx) * sizex + transx; |
152 uv[0][1] = (tface->uv[0][1] - centery) * sizey + transy; | 150 uv[0][1] = (tface->uv[0][1] - centery) * sizey + transy; |
153 uv[1][0] = (tface->uv[1][0] - centerx) * sizex + transx; | 151 uv[1][0] = (tface->uv[1][0] - centerx) * sizex + transx; |
154 uv[1][1] = (tface->uv[1][1] - centery) * sizey + transy; | 152 uv[1][1] = (tface->uv[1][1] - centery) * sizey + transy; |
155 uv[2][0] = (tface->uv[2][0] - centerx) * sizex + transx; | 153 uv[2][0] = (tface->uv[2][0] - centerx) * sizex + transx; |
156 uv[2][1] = (tface->uv[2][1] - centery) * sizey + transy; | 154 uv[2][1] = (tface->uv[2][1] - centery) * sizey + transy; |
157 ························ | 155 ························ |
158 glBegin(GL_POLYGON); | 156 glBegin(GL_POLYGON); |
159 » » » if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[0]); | 157 » » » if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[0])
; |
160 else glTexCoord2fv(uv[0]); | 158 else glTexCoord2fv(uv[0]); |
161 » » » if(col) gpu_mcol(col[0]); | 159 » » » if (col) gpu_mcol(col[0]); |
162 glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey,
v1[2]); | 160 glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey,
v1[2]); |
163 ························ | 161 ························ |
164 » » » if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[1]); | 162 » » » if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[1])
; |
165 else glTexCoord2fv(uv[1]); | 163 else glTexCoord2fv(uv[1]); |
166 » » » if(col) gpu_mcol(col[1]); | 164 » » » if (col) gpu_mcol(col[1]); |
167 glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey,
v2[2]); | 165 glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey,
v2[2]); |
168 | 166 |
169 » » » if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[2]); | 167 » » » if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[2])
; |
170 else glTexCoord2fv(uv[2]); | 168 else glTexCoord2fv(uv[2]); |
171 » » » if(col) gpu_mcol(col[2]); | 169 » » » if (col) gpu_mcol(col[2]); |
172 glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey,
v3[2]); | 170 glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey,
v3[2]); |
173 | 171 |
174 » » » if(v4) { | 172 » » » if (v4) { |
175 uv[3][0] = (tface->uv[3][0] - centerx) * sizex +
transx; | 173 uv[3][0] = (tface->uv[3][0] - centerx) * sizex +
transx; |
176 uv[3][1] = (tface->uv[3][1] - centery) * sizey +
transy; | 174 uv[3][1] = (tface->uv[3][1] - centery) * sizey +
transy; |
177 | 175 |
178 » » » » if(glattrib >= 0) glVertexAttrib2fvARB(glattrib,
uv[3]); | 176 » » » » if (glattrib >= 0) glVertexAttrib2fvARB(glattrib
, uv[3]); |
179 else glTexCoord2fv(uv[3]); | 177 else glTexCoord2fv(uv[3]); |
180 » » » » if(col) gpu_mcol(col[3]); | 178 » » » » if (col) gpu_mcol(col[3]); |
181 glVertex3f(sizex * v4[0] + movex, sizey * v4[1]
+ movey, v4[2]); | 179 glVertex3f(sizex * v4[0] + movex, sizey * v4[1]
+ movey, v4[2]); |
182 } | 180 } |
183 glEnd(); | 181 glEnd(); |
184 | 182 |
185 glTranslatef(advance, 0.0, 0.0); | 183 glTranslatef(advance, 0.0, 0.0); |
186 line_start -= advance; /* so we can go back to the start
of the line */ | 184 line_start -= advance; /* so we can go back to the start
of the line */ |
187 } | 185 } |
188 glPopMatrix(); | 186 glPopMatrix(); |
189 } | 187 } |
190 } | 188 } |
191 | 189 |
192 /* Checking powers of two for images since opengl 1.x requires it */ | 190 /* Checking powers of two for images since opengl 1.x requires it */ |
193 | 191 |
194 static int is_pow2(int num) | |
195 { | |
196 /* (n&(n-1)) zeros the least significant bit of n */ | |
197 return ((num)&(num-1))==0; | |
198 } | |
199 | |
200 static int smaller_pow2(int num) | |
201 { | |
202 while (!is_pow2(num)) | |
203 num= num&(num-1); | |
204 | |
205 return num;····· | |
206 } | |
207 | |
208 static int is_pow2_limit(int num) | 192 static int is_pow2_limit(int num) |
209 { | 193 { |
210 /* take texture clamping into account */ | 194 /* take texture clamping into account */ |
211 | 195 |
212 » /* XXX: texturepaint not global! | 196 » /* XXX: texturepaint not global! */ |
| 197 #if 0 |
213 if (G.f & G_TEXTUREPAINT) | 198 if (G.f & G_TEXTUREPAINT) |
214 return 1;*/ | 199 return 1;*/ |
| 200 #endif |
215 | 201 |
216 if (U.glreslimit != 0 && num > U.glreslimit) | 202 if (U.glreslimit != 0 && num > U.glreslimit) |
217 return 0; | 203 return 0; |
218 | 204 |
219 » return ((num)&(num-1))==0; | 205 » return is_power_of_2_i(num); |
220 } | 206 } |
221 | 207 |
222 static int smaller_pow2_limit(int num) | 208 static int smaller_pow2_limit(int num) |
223 { | 209 { |
224 » /* XXX: texturepaint not global! | 210 » /* XXX: texturepaint not global! */ |
| 211 #if 0 |
225 if (G.f & G_TEXTUREPAINT) | 212 if (G.f & G_TEXTUREPAINT) |
226 return 1;*/ | 213 return 1;*/ |
227 » | 214 #endif |
| 215 |
228 /* take texture clamping into account */ | 216 /* take texture clamping into account */ |
229 if (U.glreslimit != 0 && num > U.glreslimit) | 217 if (U.glreslimit != 0 && num > U.glreslimit) |
230 return U.glreslimit; | 218 return U.glreslimit; |
231 | 219 |
232 » return smaller_pow2(num); | 220 » return power_of_2_min_i(num); |
233 } | 221 } |
234 | 222 |
235 /* Current OpenGL state caching for GPU_set_tpage */ | 223 /* Current OpenGL state caching for GPU_set_tpage */ |
236 | 224 |
237 static struct GPUTextureState { | 225 static struct GPUTextureState { |
238 int curtile, tile; | 226 int curtile, tile; |
239 int curtilemode, tilemode; | 227 int curtilemode, tilemode; |
240 int curtileXRep, tileXRep; | 228 int curtileXRep, tileXRep; |
241 int curtileYRep, tileYRep; | 229 int curtileYRep, tileYRep; |
242 Image *ima, *curima; | 230 Image *ima, *curima; |
(...skipping 25 matching lines...) Expand all Loading... |
268 | 256 |
269 static int gpu_get_mipmap(void) | 257 static int gpu_get_mipmap(void) |
270 { | 258 { |
271 return GTS.domipmap; | 259 return GTS.domipmap; |
272 } | 260 } |
273 | 261 |
274 static GLenum gpu_get_mipmap_filter(int mag) | 262 static GLenum gpu_get_mipmap_filter(int mag) |
275 { | 263 { |
276 /* linearmipmap is off by default *when mipmapping is off, | 264 /* linearmipmap is off by default *when mipmapping is off, |
277 * use unfiltered display */ | 265 * use unfiltered display */ |
278 » if(mag) { | 266 » if (mag) { |
279 » » if(GTS.linearmipmap || GTS.domipmap) | 267 » » if (GTS.linearmipmap || GTS.domipmap) |
280 return GL_LINEAR; | 268 return GL_LINEAR; |
281 else | 269 else |
282 return GL_NEAREST; | 270 return GL_NEAREST; |
283 } | 271 } |
284 else { | 272 else { |
285 » » if(GTS.linearmipmap) | 273 » » if (GTS.linearmipmap) |
286 return GL_LINEAR_MIPMAP_LINEAR; | 274 return GL_LINEAR_MIPMAP_LINEAR; |
287 » » else if(GTS.domipmap) | 275 » » else if (GTS.domipmap) |
288 return GL_LINEAR_MIPMAP_NEAREST; | 276 return GL_LINEAR_MIPMAP_NEAREST; |
289 else | 277 else |
290 return GL_NEAREST; | 278 return GL_NEAREST; |
291 } | 279 } |
292 } | 280 } |
293 | 281 |
294 /* Anisotropic filtering settings */ | 282 /* Anisotropic filtering settings */ |
295 void GPU_set_anisotropic(float value) | 283 void GPU_set_anisotropic(float value) |
296 { | 284 { |
297 » if (GTS.anisotropic != value) | 285 » if (GTS.anisotropic != value) { |
298 » { | |
299 GPU_free_images(); | 286 GPU_free_images(); |
300 | 287 |
301 /* Clamp value to the maximum value the graphics card supports *
/ | 288 /* Clamp value to the maximum value the graphics card supports *
/ |
302 if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT) | 289 if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT) |
303 value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; | 290 value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; |
304 | 291 |
305 GTS.anisotropic = value; | 292 GTS.anisotropic = value; |
306 } | 293 } |
307 } | 294 } |
308 | 295 |
309 float GPU_get_anisotropic(void) | 296 float GPU_get_anisotropic(void) |
310 { | 297 { |
311 return GTS.anisotropic; | 298 return GTS.anisotropic; |
312 } | 299 } |
313 | 300 |
314 /* Set OpenGL state for an MTFace */ | 301 /* Set OpenGL state for an MTFace */ |
315 | 302 |
316 static void gpu_make_repbind(Image *ima) | 303 static void gpu_make_repbind(Image *ima) |
317 { | 304 { |
318 ImBuf *ibuf; | 305 ImBuf *ibuf; |
319 ········ | 306 ········ |
320 ibuf = BKE_image_get_ibuf(ima, NULL); | 307 ibuf = BKE_image_get_ibuf(ima, NULL); |
321 » if(ibuf==NULL) | 308 » if (ibuf==NULL) |
322 return; | 309 return; |
323 | 310 |
324 » if(ima->repbind) { | 311 » if (ima->repbind) { |
325 glDeleteTextures(ima->totbind, (GLuint *)ima->repbind); | 312 glDeleteTextures(ima->totbind, (GLuint *)ima->repbind); |
326 MEM_freeN(ima->repbind); | 313 MEM_freeN(ima->repbind); |
327 ima->repbind= NULL; | 314 ima->repbind= NULL; |
328 ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; | 315 ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; |
329 } | 316 } |
330 | 317 |
331 ima->totbind= ima->xrep*ima->yrep; | 318 ima->totbind= ima->xrep*ima->yrep; |
332 | 319 |
333 » if(ima->totbind>1) | 320 » if (ima->totbind>1) |
334 ima->repbind= MEM_callocN(sizeof(int)*ima->totbind, "repbind"); | 321 ima->repbind= MEM_callocN(sizeof(int)*ima->totbind, "repbind"); |
335 } | 322 } |
336 | 323 |
337 static void gpu_clear_tpage(void) | 324 static void gpu_clear_tpage(void) |
338 { | 325 { |
339 » if(GTS.lasttface==NULL) | 326 » if (GTS.lasttface==NULL) |
340 return; | 327 return; |
341 ········ | 328 ········ |
342 GTS.lasttface= NULL; | 329 GTS.lasttface= NULL; |
343 GTS.curtile= 0; | 330 GTS.curtile= 0; |
344 GTS.curima= NULL; | 331 GTS.curima= NULL; |
345 » if(GTS.curtilemode!=0) { | 332 » if (GTS.curtilemode!=0) { |
346 glMatrixMode(GL_TEXTURE); | 333 glMatrixMode(GL_TEXTURE); |
347 glLoadIdentity(); | 334 glLoadIdentity(); |
348 glMatrixMode(GL_MODELVIEW); | 335 glMatrixMode(GL_MODELVIEW); |
349 } | 336 } |
350 GTS.curtilemode= 0; | 337 GTS.curtilemode= 0; |
351 GTS.curtileXRep=0; | 338 GTS.curtileXRep=0; |
352 GTS.curtileYRep=0; | 339 GTS.curtileYRep=0; |
353 GTS.alphablend= -1; | 340 GTS.alphablend= -1; |
354 ········ | 341 ········ |
355 glDisable(GL_BLEND); | 342 glDisable(GL_BLEND); |
356 glDisable(GL_TEXTURE_2D); | 343 glDisable(GL_TEXTURE_2D); |
357 glDisable(GL_TEXTURE_GEN_S); | 344 glDisable(GL_TEXTURE_GEN_S); |
358 glDisable(GL_TEXTURE_GEN_T); | 345 glDisable(GL_TEXTURE_GEN_T); |
359 glDisable(GL_ALPHA_TEST); | 346 glDisable(GL_ALPHA_TEST); |
360 } | 347 } |
361 | 348 |
362 static void gpu_set_alpha_blend(GPUBlendMode alphablend) | 349 static void gpu_set_alpha_blend(GPUBlendMode alphablend) |
363 { | 350 { |
364 » if(alphablend == GPU_BLEND_SOLID) { | 351 » if (alphablend == GPU_BLEND_SOLID) { |
365 glDisable(GL_BLEND); | 352 glDisable(GL_BLEND); |
366 glDisable(GL_ALPHA_TEST); | 353 glDisable(GL_ALPHA_TEST); |
367 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 354 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
368 } | 355 } |
369 » else if(alphablend==GPU_BLEND_ADD) { | 356 » else if (alphablend==GPU_BLEND_ADD) { |
370 glEnable(GL_BLEND); | 357 glEnable(GL_BLEND); |
371 glBlendFunc(GL_ONE, GL_ONE); | 358 glBlendFunc(GL_ONE, GL_ONE); |
372 glDisable(GL_ALPHA_TEST); | 359 glDisable(GL_ALPHA_TEST); |
373 } | 360 } |
374 » else if(ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) { | 361 » else if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) { |
375 glEnable(GL_BLEND); | 362 glEnable(GL_BLEND); |
376 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 363 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
377 ················ | 364 ················ |
378 /* if U.glalphaclip == 1.0, some cards go bonkers... | 365 /* if U.glalphaclip == 1.0, some cards go bonkers... |
379 * turn off alpha test in this case */ | 366 * turn off alpha test in this case */ |
380 | 367 |
381 /* added after 2.45 to clip alpha */ | 368 /* added after 2.45 to clip alpha */ |
382 » » if(U.glalphaclip == 1.0f) { | 369 » » if (U.glalphaclip == 1.0f) { |
383 glDisable(GL_ALPHA_TEST); | 370 glDisable(GL_ALPHA_TEST); |
384 } | 371 } |
385 else { | 372 else { |
386 glEnable(GL_ALPHA_TEST); | 373 glEnable(GL_ALPHA_TEST); |
387 glAlphaFunc(GL_GREATER, U.glalphaclip); | 374 glAlphaFunc(GL_GREATER, U.glalphaclip); |
388 } | 375 } |
389 } | 376 } |
390 » else if(alphablend==GPU_BLEND_CLIP) { | 377 » else if (alphablend==GPU_BLEND_CLIP) { |
391 glDisable(GL_BLEND);· | 378 glDisable(GL_BLEND);· |
392 glEnable(GL_ALPHA_TEST); | 379 glEnable(GL_ALPHA_TEST); |
393 glAlphaFunc(GL_GREATER, 0.5f); | 380 glAlphaFunc(GL_GREATER, 0.5f); |
394 } | 381 } |
395 } | 382 } |
396 | 383 |
397 static void gpu_verify_alpha_blend(int alphablend) | 384 static void gpu_verify_alpha_blend(int alphablend) |
398 { | 385 { |
399 /* verify alpha blending modes */ | 386 /* verify alpha blending modes */ |
400 » if(GTS.alphablend == alphablend) | 387 » if (GTS.alphablend == alphablend) |
401 return; | 388 return; |
402 | 389 |
403 gpu_set_alpha_blend(alphablend); | 390 gpu_set_alpha_blend(alphablend); |
404 GTS.alphablend= alphablend; | 391 GTS.alphablend= alphablend; |
405 } | 392 } |
406 | 393 |
407 static void gpu_verify_reflection(Image *ima) | 394 static void gpu_verify_reflection(Image *ima) |
408 { | 395 { |
409 if (ima && (ima->flag & IMA_REFLECT)) { | 396 if (ima && (ima->flag & IMA_REFLECT)) { |
410 /* enable reflection mapping */ | 397 /* enable reflection mapping */ |
411 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); | 398 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); |
412 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); | 399 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); |
413 | 400 |
414 glEnable(GL_TEXTURE_GEN_S); | 401 glEnable(GL_TEXTURE_GEN_S); |
415 glEnable(GL_TEXTURE_GEN_T); | 402 glEnable(GL_TEXTURE_GEN_T); |
416 } | 403 } |
417 else { | 404 else { |
418 /* disable reflection mapping */ | 405 /* disable reflection mapping */ |
419 glDisable(GL_TEXTURE_GEN_S); | 406 glDisable(GL_TEXTURE_GEN_S); |
420 glDisable(GL_TEXTURE_GEN_T); | 407 glDisable(GL_TEXTURE_GEN_T); |
421 } | 408 } |
422 } | 409 } |
423 | 410 |
424 int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
mipmap) | 411 int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
mipmap) |
425 { | |
426 ImBuf *ibuf = NULL; | |
427 unsigned int *bind = NULL; | |
428 int rectw, recth, tpx=0, tpy=0, y; | 412 int rectw, recth, tpx=0, tpy=0, y; |
429 unsigned int *rectrow, *tilerectrow; | 413 unsigned int *rectrow, *tilerectrow; |
430 unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL; | 414 unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL; |
431 float *frectrow, *ftilerectrow, *ftilerect= NULL; | |
432 float *frect = NULL, *fscalerect = NULL; | |
433 float *color_corrected_frect = NULL; | |
434 short texwindx, texwindy, texwinsx, texwinsy; | 415 short texwindx, texwindy, texwinsx, texwinsy; |
435 /*flag to determine whether high resolution format is used*/ | |
436 int useHighPrecisionTex = FALSE; | |
437 | 416 |
438 /* initialize tile mode and number of repeats */ | 417 /* initialize tile mode and number of repeats */ |
439 GTS.ima = ima; | 418 GTS.ima = ima; |
440 GTS.tilemode= (ima && (ima->tpageflag & (IMA_TILES|IMA_TWINANIM))); | |
441 GTS.tileXRep = 0; | |
442 GTS.tileYRep = 0; | |
443 | |
444 /* setting current tile according to frame */ | |
445 if(ima && (ima->tpageflag & IMA_TWINANIM)) | |
446 GTS.tile= ima->lastframe; | |
447 else | |
448 GTS.tile= tftile; | |
449 | |
450 GTS.tile = MAX2(0, GTS.tile); | |
451 | |
452 if(ima) { | |
453 GTS.tileXRep = ima->xrep; | |
454 GTS.tileYRep = ima->yrep; | |
455 } | |
456 | |
457 /* if same image & tile, we're done */ | |
458 if(compare && ima == GTS.curima && GTS.curtile == GTS.tile && | |
459 GTS.tilemode == GTS.curtilemode && GTS.curtileXRep == GTS.tileXRep && | |
460 GTS.curtileYRep == GTS.tileYRep) | |
461 return (ima != NULL); | |
462 | |
463 /* if tiling mode or repeat changed, change texture matrix to fit */ | |
464 if(GTS.tilemode!=GTS.curtilemode || GTS.curtileXRep!=GTS.tileXRep || | |
465 GTS.curtileYRep != GTS.tileYRep) { | |
466 | |
467 glMatrixMode(GL_TEXTURE); | |
468 glLoadIdentity(); | |
469 | |
470 if(ima && (ima->tpageflag & IMA_TILES)) | |
471 glScalef(ima->xrep, ima->yrep, 1.0); | |
472 | |
473 glMatrixMode(GL_MODELVIEW); | |
474 } | |
475 | |
476 /* check if we have a valid image */ | |
477 if(ima==NULL || ima->ok==0) | |
478 return 0; | |
479 | |
480 /* check if we have a valid image buffer */ | |
481 ibuf= BKE_image_get_ibuf(ima, iuser); | |
482 | |
483 if(ibuf==NULL) | |
484 return 0; | |
485 | |
486 if (ibuf->rect_float){ | |
487 if(U.high_bit_depth_tex) | |
488 { | |
489 /*Use high precision textures. This is relatively harmle
ss because OpenGL gives us | |
490 a high precision format only if it is available*/ | |
491 useHighPrecisionTex = TRUE; | |
492 } | |
493 if(ibuf->rect==NULL){ | |
494 IMB_rect_from_float(ibuf); | |
495 } | |
496 | |
497 } | |
498 ················ | |
499 /* currently, tpage refresh is used by ima sequences */ | |
500 if(ima->tpageflag & IMA_TPAGE_REFRESH) { | |
501 GPU_free_image(ima); | |
502 ima->tpageflag &= ~IMA_TPAGE_REFRESH; | |
503 } | |
504 ········ | |
505 if(GTS.tilemode) { | |
506 /* tiled mode */ | |
507 if(ima->repbind==NULL) gpu_make_repbind(ima); | |
508 if(GTS.tile>=ima->totbind) GTS.tile= 0; | |
509 ················ | |
510 /* this happens when you change repeat buttons */ | |
511 if(ima->repbind) bind= &ima->repbind[GTS.tile]; | |
512 else bind= &ima->bindcode; | |
513 ················ | |
514 if(*bind==0) { | |
515 ························ | |
516 texwindx= ibuf->x/ima->xrep; | |
517 texwindy= ibuf->y/ima->yrep; | |
518 ························ | |
519 if(GTS.tile>=ima->xrep*ima->yrep) | |
520 GTS.tile= ima->xrep*ima->yrep-1; | |
521 ········ | |
522 texwinsy= GTS.tile / ima->xrep; | |
523 texwinsx= GTS.tile - texwinsy*ima->xrep; | |
524 ········ | |
525 texwinsx*= texwindx; | |
526 texwinsy*= texwindy; | |
527 ········ | |
528 tpx= texwindx; | |
529 tpy= texwindy; | |
530 | |
531 if(useHighPrecisionTex){ | |
532 /* We may also need a color corrected float imag
e. Dithering will not apply since it's high precision */ | |
533 if(ibuf->profile == IB_PROFILE_LINEAR_RGB){ | |
534 color_corrected_frect = MEM_mallocN(ibuf
->x*ibuf->y*sizeof(float)*4, "floar_buf_col_cor"); | |
535 IMB_float_color_corrected_from_float_rec
t(ibuf, color_corrected_frect); | |
536 frect= color_corrected_frect + texwinsy*
ibuf->x + texwinsx; | |
537 }else{ | |
538 frect= ibuf->rect_float + texwinsy*ibuf-
>x + texwinsx; | |
539 } | |
540 }else{ | |
541 rect= ibuf->rect + texwinsy*ibuf->x + texwinsx; | |
542 } | |
543 } | |
544 } | |
545 else { | |
546 /* regular image mode */ | |
547 bind= &ima->bindcode; | |
548 | |
549 if(*bind==0) { | |
550 tpx= ibuf->x; | |
551 tpy= ibuf->y; | |
552 rect= ibuf->rect; | |
553 if(useHighPrecisionTex){ | |
554 /* We may also need a color corrected float imag
e. Dithering will not apply since it's high precision */ | |
555 if(ibuf->profile == IB_PROFILE_LINEAR_RGB){ | |
556 frect = color_corrected_frect = MEM_mall
ocN(ibuf->x*ibuf->y*sizeof(float)*4, "floar_buf_col_cor"); | |
557 IMB_float_color_corrected_from_float_rec
t(ibuf, color_corrected_frect); | |
558 }else{ | |
559 frect= ibuf->rect_float; | |
560 } | |
561 } | |
562 } | |
563 } | |
564 | |
565 if(*bind != 0) { | |
566 /* enable opengl drawing with textures */ | |
567 glBindTexture(GL_TEXTURE_2D, *bind); | |
568 return *bind; | |
569 } | |
570 | |
571 rectw = tpx; | |
572 recth = tpy; | |
573 | |
574 /* for tiles, copy only part of image into buffer */ | |
575 if (GTS.tilemode) { | |
576 if(useHighPrecisionTex){ | |
577 ftilerect= MEM_mallocN(rectw*recth*sizeof(*ftilerect), "
tilerect"); | |
578 | |
579 for (y=0; y<recth; y++) { | |
580 frectrow= &frect[y*ibuf->x]; | |
581 ftilerectrow= &ftilerect[y*rectw]; | |
582 | |
583 memcpy(ftilerectrow, frectrow, tpx*sizeof(*frect
row)); | |
584 } | |
585 | |
586 frect= ftilerect; | |
587 }else{ | |
588 tilerect= MEM_mallocN(rectw*recth*sizeof(*tilerect), "ti
lerect"); | |
589 | |
590 for (y=0; y<recth; y++) { | |
591 rectrow= &rect[y*ibuf->x]; | |
592 tilerectrow= &tilerect[y*rectw]; | |
593 | |
594 memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow
)); | |
595 } | |
596 ························ | |
597 rect= tilerect; | |
598 } | |
599 } | |
600 | |
601 /* scale if not a power of two. This is not strictly necessary for newer········ | |
602 GPUs (OpenGL version >= 2.0)since they support non-power-of-two-textures
*/ | |
603 if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) { | |
604 rectw= smaller_pow2_limit(rectw); | |
605 recth= smaller_pow2_limit(recth); | |
606 ················ | |
607 if(useHighPrecisionTex) | |
608 { | |
609 fscalerect= MEM_mallocN(rectw*recth*sizeof(float)*4, "fs
calerect"); | |
610 gluScaleImage(GL_RGBA, tpx, tpy, GL_FLOAT, frect, rectw,
recth, GL_FLOAT, fscalerect); | |
611 MEM_freeN(frect); | |
612 frect = fscalerect; | |
613 fscalerect = NULL; | |
614 } | |
615 else | |
616 { | |
617 scalerect= MEM_mallocN(rectw*recth*sizeof(*scalerect), "
scalerect"); | |
618 gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect,
rectw, recth, GL_UNSIGNED_BYTE, scalerect); | |
619 rect= scalerect; | |
620 } | |
621 } | |
622 | |
623 /* create image */ | |
624 glGenTextures(1, (GLuint *)bind); | |
625 glBindTexture( GL_TEXTURE_2D, *bind); | |
626 | |
627 if (!(gpu_get_mipmap() && mipmap)) { | |
628 if(useHighPrecisionTex) | |
629 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth
, 0, GL_RGBA, GL_FLOAT, frect);················· | |
630 else | |
631 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RG
BA, GL_UNSIGNED_BYTE, rect); | |
632 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
; | |
633 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mi
pmap_filter(1)); | |
634 } | |
635 else { | |
636 if(useHighPrecisionTex) | |
637 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth
, GL_RGBA, GL_FLOAT, frect); | |
638 else | |
639 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA,
GL_UNSIGNED_BYTE, rect); | |
640 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mi
pmap_filter(0)); | |
641 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mi
pmap_filter(1)); | |
642 | |
643 ima->tpageflag |= IMA_MIPMAP_COMPLETE; | |
644 } | |
645 | |
646 if (GLEW_EXT_texture_filter_anisotropic) | |
647 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GP
U_get_anisotropic()); | |
648 /* set to modulate with vertex color */ | |
649 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |
650 ················ | |
651 /* clean up */ | |
652 if (tilerect) | |
653 MEM_freeN(tilerect); | |
654 if (ftilerect) | |
655 MEM_freeN(ftilerect); | |
656 if (scalerect) | |
657 MEM_freeN(scalerect); | |
658 if (fscalerect) | |
659 MEM_freeN(fscalerect); | |
660 if(color_corrected_frect) | |
661 MEM_freeN(color_corrected_frect); | |
662 return *bind; | |
663 } | |
664 | |
665 static void gpu_verify_repeat(Image *ima) | |
666 { | |
667 /* set either clamp or repeat in X/Y */ | |
668 if (ima->tpageflag & IMA_CLAMP_U) | |
669 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
670 else | |
671 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); | |
672 | |
673 if (ima->tpageflag & IMA_CLAMP_V) | |
674 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_ED
GE); | |
675 else | |
676 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); | |
677 } | |
678 | |
679 int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend) | |
680 { | |
681 Image *ima; | |
682 ········ | |
683 /* check if we need to clear the state */ | |
684 if(tface==NULL) { | |
685 gpu_clear_tpage(); | |
686 return 0; | |
687 } | |
688 | |
689 ima= tface->tpage; | |
690 GTS.lasttface= tface; | |
691 | |
692 gpu_verify_alpha_blend(alphablend); | |
693 gpu_verify_reflection(ima); | |
694 | |
695 if(GPU_verify_image(ima, NULL, tface->tile, 1, mipmap)) { | |
696 GTS.curtile= GTS.tile; | |
697 GTS.curima= GTS.ima; | |
698 GTS.curtilemode= GTS.tilemode; | |
699 GTS.curtileXRep = GTS.tileXRep; | |
700 GTS.curtileYRep = GTS.tileYRep; | |
701 | |
702 glEnable(GL_TEXTURE_2D); | |
703 } | |
704 else { | |
705 glDisable(GL_TEXTURE_2D); | |
706 ················ | |
707 GTS.curtile= 0; | |
708 GTS.curima= NULL; | |
709 GTS.curtilemode= 0; | |
710 GTS.curtileXRep = 0; | |
711 GTS.curtileYRep = 0; | |
712 | |
713 return 0; | |
714 } | |
715 ········ | |
716 gpu_verify_repeat(ima); | |
717 ········ | |
718 /* Did this get lost in the image recode? */ | |
719 /* tag_image_time(ima);*/ | |
720 | |
721 return 1; | |
722 } | |
723 | |
724 /* these two functions are called on entering and exiting texture paint mode, | |
725 temporary disabling/enabling mipmapping on all images for quick texture | |
726 updates with glTexSubImage2D. images that didn't change don't have to be | |
727 re-uploaded to OpenGL */ | |
728 void GPU_paint_set_mipmap(int mipmap) | |
729 { | |
730 Image* ima; | |
731 ········ | |
732 if(!GTS.domipmap) | |
733 return; | |
734 | |
735 if(mipmap) { | |
736 for(ima=G.main->image.first; ima; ima=ima->id.next) { | |
737 if(ima->bindcode) { | |
738 if(ima->tpageflag & IMA_MIPMAP_COMPLETE) { | |
739 glBindTexture(GL_TEXTURE_2D, ima->bindco
de); | |
740 glTexParameteri(GL_TEXTURE_2D, GL_TEXTUR
E_MIN_FILTER, gpu_get_mipmap_filter(0)); | |
741 glTexParameteri(GL_TEXTURE_2D, GL_TEXTUR
E_MAG_FILTER, gpu_get_mipmap_filter(1)); | |
742 } | |
743 else | |
744 GPU_free_image(ima); | |
745 } | |
746 } | |
747 | |
748 } | |
749 else { | |
750 for(ima=G.main->image.first; ima; ima=ima->id.next) { | |
751 if(ima->bindcode) { | |
752 glBindTexture(GL_TEXTURE_2D, ima->bindcode); | |
753 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FI
LTER, GL_LINEAR); | |
754 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FI
LTER, gpu_get_mipmap_filter(1)); | |
755 } | |
756 } | |
757 } | |
758 } | |
759 | |
760 void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) | |
761 { | |
762 ImBuf *ibuf; | |
763 ········ | |
764 ibuf = BKE_image_get_ibuf(ima, NULL); | |
765 ········ | |
766 if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !i
buf || | |
767 (!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) || | |
768 (w == 0) || (h == 0)) { | |
769 /* these cases require full reload still */ | |
770 GPU_free_image(ima); | |
771 } | |
772 else { | |
773 /* for the special case, we can do a partial update | |
774 * which is much quicker for painting */ | |
775 GLint row_length, skip_pixels, skip_rows; | |
776 | |
777 glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length); | |
778 glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels); | |
779 glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows); | |
780 | |
781 /* if color correction is needed, we must update the part that n
eeds updating. | |
782 * If using high bit depth textures, no dithering is needed, sam
e as on initialization */ | |
783 if (ibuf->rect_float && (!U.high_bit_depth_tex || (ibuf->profile
== IB_PROFILE_LINEAR_RGB))){ | |
784 float *buffer = (float *)MEM_mallocN(w*h*sizeof(float)*4
, "temp_texpaint_float_buf"); | |
785 IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h); | |
786 glBindTexture(GL_TEXTURE_2D, ima->bindcode); | |
787 glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, | |
788 GL_FLOAT, buffer); | |
789 MEM_freeN(buffer); | |
790 if(ima->tpageflag & IMA_MIPMAP_COMPLETE) | |
791 ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; | |
792 return; | |
793 } | |
794 | |
795 glBindTexture(GL_TEXTURE_2D, ima->bindcode); | |
796 | |
797 glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x); | |
798 glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); | |
799 glPixelStorei(GL_UNPACK_SKIP_ROWS, y); | |
800 | |
801 if (ibuf->rect_float){ | |
802 glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, | |
803 GL_FLOAT, ibuf->rect_float); | |
804 }else{ | |
805 glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, | |
806 GL_UNSIGNED_BYTE, ibuf->rect); | |
807 } | |
808 | |
809 glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); | |
810 glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); | |
811 glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); | |
812 | |
813 if(ima->tpageflag & IMA_MIPMAP_COMPLETE) | |
814 ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; | |
815 } | |
816 } | |
817 | |
818 void GPU_update_images_framechange(void) | |
819 { | |
820 Image *ima; | |
821 ········ | |
822 for(ima=G.main->image.first; ima; ima=ima->id.next) { | |
823 if(ima->tpageflag & IMA_TWINANIM) { | |
824 if(ima->twend >= ima->xrep*ima->yrep) | |
825 ima->twend= ima->xrep*ima->yrep-1; | |
826 ················ | |
827 /* check: is bindcode not in the array? free. (to do) */ | |
828 ························ | |
829 ima->lastframe++; | |
830 if(ima->lastframe > ima->twend) | |
831 ima->lastframe= ima->twsta; | |
832 } | |
833 } | |
834 } | |
835 | |
836 int GPU_update_image_time(Image *ima, double time) | |
837 { | |
838 int inc = 0; | |
839 float diff; | |
840 int newframe; | |
841 | |
842 if (!ima) | |
843 return 0; | |
844 | |
845 if (ima->lastupdate<0) | |
846 ima->lastupdate = 0; | |
847 | |
848 if (ima->lastupdate>time) | |
849 ima->lastupdate=(float)time; | |
850 | |
851 if(ima->tpageflag & IMA_TWINANIM) { | |
852 if(ima->twend >= ima->xrep*ima->yrep) ima->twend= ima->xrep*ima-
>yrep-1; | |
853 ················ | |
854 /* check: is the bindcode not in the array? Then free. (still to
do) */ | |
855 ················ | |
856 diff = (float)(time-ima->lastupdate); | |
857 inc = (int)(diff*(float)ima->animspeed); | |
858 | |
859 ima->lastupdate+=((float)inc/(float)ima->animspeed); | |
860 | |
861 newframe = ima->lastframe+inc; | |
862 | |
863 if(newframe > (int)ima->twend) { | |
864 if(ima->twend-ima->twsta != 0) | |
865 newframe = (int)ima->twsta-1 + (newframe-ima->tw
end)%(ima->twend-ima->twsta); | |
866 else | |
867 newframe = ima->twsta; | |
868 } | |
869 | |
870 ima->lastframe = newframe; | |
871 } | |
872 | |
873 return inc; | |
874 } | |
875 | |
876 | |
877 void GPU_free_smoke(SmokeModifierData *smd) | |
878 { | |
879 if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) | |
880 { | |
881 if(smd->domain->tex) | |
882 GPU_texture_free(smd->domain->tex); | |
883 smd->domain->tex = NULL; | |
884 | |
885 if(smd->domain->tex_shadow) | |
886 GPU_texture_free(smd->domain->tex_shadow); | |
887 smd->domain->tex_shadow = NULL; | |
888 } | |
889 } | |
890 | |
891 void GPU_create_smoke(SmokeModifierData *smd, int highres) | |
892 { | |
893 #ifdef WITH_SMOKE | |
894 if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && !highres) | |
895 smd->domain->tex = GPU_texture_create_3D(smd->domain->res[0], sm
d->domain->res[1], smd->domain->res[2], smoke_get_density(smd->domain->fluid)); | |
896 else if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && highre
s) | |
897 smd->domain->tex = GPU_texture_create_3D(smd->domain->res_wt[0],
smd->domain->res_wt[1], smd->domain->res_wt[2], smoke_turbulence_get_density(sm
d->domain->wt)); | |
898 | |
899 smd->domain->tex_shadow = GPU_texture_create_3D(smd->domain->res[0], smd
->domain->res[1], smd->domain->res[2], smd->domain->shadow); | |
900 #else // WITH_SMOKE | |
901 (void)highres; | |
902 smd->domain->tex= NULL; | |
903 smd->domain->tex_shadow= NULL; | |
904 #endif // WITH_SMOKE | |
905 } | |
906 | |
907 static ListBase image_free_queue = {NULL, NULL}; | |
908 | |
909 static void gpu_queue_image_for_free(Image *ima) | |
910 { | |
911 Image *cpy = MEM_dupallocN(ima); | |
912 | |
913 BLI_lock_thread(LOCK_OPENGL); | |
914 BLI_addtail(&image_free_queue, cpy); | |
915 BLI_unlock_thread(LOCK_OPENGL); | |
916 } | |
917 | |
918 void GPU_free_unused_buffers(void) | |
919 { | |
920 Image *ima; | |
921 | |
922 if(!BLI_thread_is_main()) | |
923 return; | |
924 | |
925 BLI_lock_thread(LOCK_OPENGL); | |
926 | |
927 /* images */ | |
928 for(ima=image_free_queue.first; ima; ima=ima->id.next) | |
929 GPU_free_image(ima); | |
930 | |
931 BLI_freelistN(&image_free_queue); | |
932 | |
933 /* vbo buffers */ | |
934 /* it's probably not necessary to free all buffers every frame */ | |
935 /* GPU_buffer_pool_free_unused(0); */ | |
936 | |
937 BLI_unlock_thread(LOCK_OPENGL); | |
938 } | |
939 | |
940 void GPU_free_image(Image *ima) | |
941 { | |
942 if(!BLI_thread_is_main()) { | |
943 gpu_queue_image_for_free(ima); | |
944 return; | |
945 } | |
946 | |
947 /* free regular image binding */ | |
948 if(ima->bindcode) { | |
949 glDeleteTextures(1, (GLuint *)&ima->bindcode); | |
950 ima->bindcode= 0; | |
951 ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; | |
952 } | |
953 | |
954 /* free glsl image binding */ | |
955 if(ima->gputexture) { | |
956 GPU_texture_free(ima->gputexture); | |
957 ima->gputexture= NULL; | |
958 } | |
959 | |
960 /* free repeated image binding */ | |
961 if(ima->repbind) { | |
962 glDeleteTextures(ima->totbind, (GLuint *)ima->repbind); | |
963 ········ | |
964 MEM_freeN(ima->repbind); | |
965 ima->repbind= NULL; | |
966 ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; | |
967 } | |
968 } | |
969 | |
970 void GPU_free_images(void) | |
971 { | |
972 Image* ima; | |
973 | |
974 if(G.main) | |
975 for(ima=G.main->image.first; ima; ima=ima->id.next) | |
976 GPU_free_image(ima); | |
977 } | |
978 | |
979 /* same as above but only free animated images */ | |
980 void GPU_free_images_anim(void) | |
981 { | |
982 Image* ima; | |
983 | |
984 if(G.main) | |
985 for(ima=G.main->image.first; ima; ima=ima->id.next) | |
986 if(ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) | |
987 GPU_free_image(ima); | |
988 } | |
989 | |
990 /* OpenGL Materials */ | |
991 | |
992 #define FIXEDMAT 8 | |
993 | |
994 /* OpenGL state caching for materials */ | |
995 | |
996 typedef struct GPUMaterialFixed { | |
997 float diff[4]; | |
998 float spec[4]; | |
999 int hard; | |
1000 } GPUMaterialFixed;· | |
1001 | |
1002 static struct GPUMaterialState { | |
1003 GPUMaterialFixed (*matbuf); | |
1004 GPUMaterialFixed matbuf_fixed[FIXEDMAT]; | |
1005 int totmat; | |
1006 | |
1007 Material **gmatbuf; | |
1008 Material *gmatbuf_fixed[FIXEDMAT]; | |
1009 Material *gboundmat; | |
1010 Object *gob; | |
1011 Scene *gscene; | |
1012 int glay; | |
1013 float (*gviewmat)[4]; | |
1014 float (*gviewinv)[4]; | |
1015 | |
1016 GPUBlendMode *alphablend; | |
1017 GPUBlendMode alphablend_fixed[FIXEDMAT]; | |
1018 int alphapass; | |
1019 | |
1020 int lastmatnr, lastretval; | |
1021 GPUBlendMode lastalphablend; | |
1022 } GMS = {NULL}; | |
1023 | |
1024 /* fixed function material, alpha handed by caller */ | |
1025 static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat,
const int gamma, const Object *ob) | |
1026 { | |
1027 if (bmat->mode & MA_SHLESS) { | |
1028 copy_v3_v3(smat->diff, &bmat->r); | |
1029 smat->diff[3]= 1.0; | |
1030 | |
1031 if(gamma) { | |
1032 linearrgb_to_srgb_v3_v3(smat->diff, smat->diff); | |
1033 }······· | |
1034 } | |
1035 else { | |
1036 mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit); | |
1037 smat->diff[3]= 1.0; /* caller may set this to bmat->alpha */ | |
1038 | |
1039 if(bmat->shade_flag & MA_OBCOLOR) | |
1040 mul_v3_v3(smat->diff, ob->col); | |
1041 ················ | |
1042 mul_v3_v3fl(smat->spec, &bmat->specr, bmat->spec); | |
1043 smat->spec[3]= 1.0; /* always 1 */ | |
1044 smat->hard= CLAMPIS(bmat->har, 0, 128); | |
1045 | |
1046 if(gamma) { | |
1047 linearrgb_to_srgb_v3_v3(smat->diff, smat->diff); | |
1048 linearrgb_to_srgb_v3_v3(smat->spec, smat->spec); | |
1049 }······· | |
1050 } | |
1051 } | |
1052 | |
1053 static Material *gpu_active_node_material(Material *ma) | |
1054 { | |
1055 if(ma && ma->use_nodes && ma->nodetree) { | |
1056 bNode *node= nodeGetActiveID(ma->nodetree, ID_MA); | |
1057 | |
1058 if(node) | |
1059 return (Material *)node->id; | |
1060 else | |
1061 return NULL; | |
1062 } | |
1063 | |
1064 return ma; | |
1065 } | |
1066 | |
1067 void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
bject *ob, int glsl, int *do_alpha_pass) | |
1068 { | |
1069 Material *ma; | |
1070 GPUMaterial *gpumat; | |
1071 GPUBlendMode alphablend; | |
1072 int a; | |
1073 int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; | |
1074 ········ | |
1075 /* initialize state */ | |
1076 memset(&GMS, 0, sizeof(GMS)); | |
1077 GMS.lastmatnr = -1; | |
1078 GMS.lastretval = -1; | |
1079 GMS.lastalphablend = GPU_BLEND_SOLID; | |
1080 | |
1081 GMS.gob = ob; | |
1082 GMS.gscene = scene; | |
1083 GMS.totmat= ob->totcol+1; /* materials start from 1, default material is
0 */ | |
1084 GMS.glay= v3d->lay; | |
1085 GMS.gviewmat= rv3d->viewmat; | |
1086 GMS.gviewinv= rv3d->viewinv; | |
1087 | |
1088 GMS.alphapass = (v3d && v3d->transp); | |
1089 if(do_alpha_pass) | |
1090 *do_alpha_pass = 0; | |
1091 ········ | |
1092 if(GMS.totmat > FIXEDMAT) { | |
1093 GMS.matbuf= MEM_callocN(sizeof(GPUMaterialFixed)*GMS.totmat, "GM
S.matbuf"); | |
1094 GMS.gmatbuf= MEM_callocN(sizeof(*GMS.gmatbuf)*GMS.totmat, "GMS.m
atbuf"); | |
1095 GMS.alphablend= MEM_callocN(sizeof(*GMS.alphablend)*GMS.totmat,
"GMS.matbuf"); | |
1096 } | |
1097 else { | |
1098 GMS.matbuf= GMS.matbuf_fixed; | |
1099 GMS.gmatbuf= GMS.gmatbuf_fixed; | |
1100 GMS.alphablend= GMS.alphablend_fixed; | |
1101 } | |
1102 | |
1103 /* no materials assigned? */ | |
1104 if(ob->totcol==0) { | |
1105 gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob); | |
1106 | |
1107 /* do material 1 too, for displists! */ | |
1108 memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed))
; | |
1109 | |
1110 if(glsl) { | |
1111 GMS.gmatbuf[0]= &defmaterial; | |
1112 GPU_material_from_blender(GMS.gscene, &defmaterial); | |
1113 } | |
1114 | |
1115 GMS.alphablend[0]= GPU_BLEND_SOLID; | |
1116 } | |
1117 ········ | |
1118 /* setup materials */ | |
1119 for(a=1; a<=ob->totcol; a++) { | |
1120 /* find a suitable material */ | |
1121 ma= give_current_material(ob, a); | |
1122 if(!glsl) ma= gpu_active_node_material(ma); | |
1123 if(ma==NULL) ma= &defmaterial; | |
1124 | |
1125 /* create glsl material if requested */ | |
1126 gpumat = (glsl)? GPU_material_from_blender(GMS.gscene, ma): NULL
; | |
1127 | |
1128 if(gpumat) { | |
1129 /* do glsl only if creating it succeed, else fallback */ | |
1130 GMS.gmatbuf[a]= ma; | |
1131 alphablend = GPU_material_alpha_blend(gpumat, ob->col); | |
1132 } | |
1133 else { | |
1134 /* fixed function opengl materials */ | |
1135 gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob); | |
1136 | |
1137 alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_B
LEND_ALPHA; | |
1138 if(do_alpha_pass && GMS.alphapass) | |
1139 GMS.matbuf[a].diff[3]= ma->alpha; | |
1140 else | |
1141 GMS.matbuf[a].diff[3]= 1.0f; | |
1142 } | |
1143 | |
1144 /* setting do_alpha_pass = 1 indicates this object needs to be | |
1145 * drawn in a second alpha pass for improved blending */ | |
1146 if(do_alpha_pass) { | |
1147 GMS.alphablend[a]= alphablend; | |
1148 if(ELEM3(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU
_BLEND_ALPHA_SORT) && !GMS.alphapass) | |
1149 *do_alpha_pass= 1; | |
1150 } | |
1151 } | |
1152 | |
1153 /* let's start with a clean state */ | |
1154 GPU_disable_material(); | |
1155 } | |
1156 | |
1157 int GPU_enable_material(int nr, void *attribs) | |
1158 { | |
1159 GPUVertexAttribs *gattribs = attribs; | |
1160 GPUMaterial *gpumat; | |
1161 GPUBlendMode alphablend; | |
1162 | |
1163 /* no GPU_begin_object_materials, use default material */ | |
1164 if(!GMS.matbuf) { | |
1165 float diff[4], spec[4]; | |
1166 | |
1167 memset(&GMS, 0, sizeof(GMS)); | |
1168 | |
1169 mul_v3_v3fl(diff, &defmaterial.r, defmaterial.ref + defmaterial.
emit); | |
1170 diff[3]= 1.0; | |
1171 | |
1172 mul_v3_v3fl(spec, &defmaterial.specr, defmaterial.spec); | |
1173 spec[3]= 1.0; | |
1174 | |
1175 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff); | |
1176 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); | |
1177 glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 35); /* blender def
ault */ | |
1178 | |
1179 return 0; | |
1180 } | |
1181 | |
1182 /* prevent index to use un-initialized array items */ | |
1183 if(nr>=GMS.totmat) | |
1184 nr= 0; | |
1185 | |
1186 if(gattribs) | |
1187 memset(gattribs, 0, sizeof(*gattribs)); | |
1188 | |
1189 /* keep current material */ | |
1190 if(nr==GMS.lastmatnr) | |
1191 return GMS.lastretval; | |
1192 | |
1193 /* unbind glsl material */ | |
1194 if(GMS.gboundmat) { | |
1195 if(GMS.alphapass) glDepthMask(0); | |
1196 GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gb
oundmat)); | |
1197 GMS.gboundmat= NULL; | |
1198 } | |
1199 | |
1200 /* draw materials with alpha in alpha pass */ | |
1201 GMS.lastmatnr = nr; | |
1202 GMS.lastretval = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLI
P); | |
1203 if(GMS.alphapass) | |
1204 GMS.lastretval = !GMS.lastretval; | |
1205 | |
1206 if(GMS.lastretval) { | |
1207 /* for alpha pass, use alpha blend */ | |
1208 alphablend = (GMS.alphapass)? GPU_BLEND_ALPHA: GPU_BLEND_SOLID; | |
1209 | |
1210 if(gattribs && GMS.gmatbuf[nr]) { | |
1211 /* bind glsl material and get attributes */ | |
1212 Material *mat = GMS.gmatbuf[nr]; | |
1213 | |
1214 gpumat = GPU_material_from_blender(GMS.gscene, mat); | |
1215 GPU_material_vertex_attributes(gpumat, gattribs); | |
1216 GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !
(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); | |
1217 GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.g
viewmat, GMS.gviewinv, GMS.gob->col); | |
1218 GMS.gboundmat= mat; | |
1219 | |
1220 /* for glsl use alpha blend mode, unless it's set to sol
id and | |
1221 we are already drawing in an alpha pass */ | |
1222 if(mat->game.alpha_blend != GPU_BLEND_SOLID) | |
1223 alphablend= mat->game.alpha_blend; | |
1224 | |
1225 if(GMS.alphapass) glDepthMask(1); | |
1226 } | |
1227 else { | |
1228 /* or do fixed function opengl material */ | |
1229 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, GMS.matbuf[n
r].diff); | |
1230 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, GMS.matbuf[
nr].spec); | |
1231 glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, GMS.matbuf[
nr].hard); | |
1232 } | |
1233 | |
1234 /* set (alpha) blending mode */ | |
1235 GPU_set_material_alpha_blend(alphablend); | |
1236 } | |
1237 | |
1238 return GMS.lastretval; | |
1239 } | |
1240 | |
1241 void GPU_set_material_alpha_blend(int alphablend) | |
1242 { | |
1243 if(GMS.lastalphablend == alphablend) | |
1244 return; | |
1245 ········ | |
1246 gpu_set_alpha_blend(alphablend); | |
1247 GMS.lastalphablend = alphablend; | |
1248 } | |
1249 | |
1250 int GPU_get_material_alpha_blend(void) | |
1251 { | |
1252 return GMS.lastalphablend; | |
1253 } | |
1254 | |
1255 void GPU_disable_material(void) | |
1256 { | |
1257 GMS.lastmatnr= -1; | |
1258 GMS.lastretval= 1; | |
1259 | |
1260 if(GMS.gboundmat) { | |
1261 if(GMS.alphapass) glDepthMask(0); | |
1262 GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gb
oundmat)); | |
1263 GMS.gboundmat= NULL; | |
1264 } | |
1265 | |
1266 GPU_set_material_alpha_blend(GPU_BLEND_SOLID); | |
1267 } | |
1268 | |
1269 void GPU_end_object_materials(void) | |
1270 { | |
1271 GPU_disable_material(); | |
1272 | |
1273 if(GMS.matbuf && GMS.matbuf != GMS.matbuf_fixed) { | |
1274 MEM_freeN(GMS.matbuf); | |
1275 MEM_freeN(GMS.gmatbuf); | |
1276 MEM_freeN(GMS.alphablend); | |
1277 } | |
1278 | |
1279 GMS.matbuf= NULL; | |
1280 GMS.gmatbuf= NULL; | |
1281 GMS.alphablend= NULL; | |
1282 | |
1283 /* resetting the texture matrix after the glScale needed for tiled textu
res */ | |
1284 if(GTS.tilemode) | |
1285 { | |
1286 glMatrixMode(GL_TEXTURE); | |
1287 glLoadIdentity(); | |
1288 glMatrixMode(GL_MODELVIEW); | |
1289 } | |
1290 } | |
1291 | |
1292 /* Lights */ | |
1293 | |
1294 int GPU_default_lights(void) | |
1295 { | |
1296 int a, count = 0; | |
1297 ········ | |
1298 /* initialize */ | |
1299 if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) { | |
1300 U.light[0].flag= 1; | |
1301 U.light[0].vec[0]= -0.3; U.light[0].vec[1]= 0.3; U.light[0].vec[
2]= 0.9; | |
1302 U.light[0].col[0]= 0.8; U.light[0].col[1]= 0.8; U.light[0].col[2
]= 0.8; | |
1303 U.light[0].spec[0]= 0.5; U.light[0].spec[1]= 0.5; U.light[0].spe
c[2]= 0.5; | |
1304 U.light[0].spec[3]= 1.0; | |
1305 ················ | |
1306 U.light[1].flag= 0; | |
1307 U.light[1].vec[0]= 0.5; U.light[1].vec[1]= 0.5; U.light[1].vec[2
]= 0.1; | |
1308 U.light[1].col[0]= 0.4; U.light[1].col[1]= 0.4; U.light[1].col[2
]= 0.8; | |
1309 U.light[1].spec[0]= 0.3; U.light[1].spec[1]= 0.3; U.light[1].spe
c[2]= 0.5; | |
1310 U.light[1].spec[3]= 1.0; | |
1311 ········ | |
1312 U.light[2].flag= 0; | |
1313 U.light[2].vec[0]= 0.3; U.light[2].vec[1]= -0.3; U.light[2].vec[
2]= -0.2; | |
1314 U.light[2].col[0]= 0.8; U.light[2].col[1]= 0.5; U.light[2].col[2
]= 0.4; | |
1315 U.light[2].spec[0]= 0.5; U.light[2].spec[1]= 0.4; U.light[2].spe
c[2]= 0.3; | |
1316 U.light[2].spec[3]= 1.0; | |
1317 } | |
1318 | |
1319 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); | |
1320 | |
1321 glLightfv(GL_LIGHT0, GL_POSITION, U.light[0].vec);· | |
1322 glLightfv(GL_LIGHT0, GL_DIFFUSE, U.light[0].col);· | |
1323 glLightfv(GL_LIGHT0, GL_SPECULAR, U.light[0].spec);· | |
1324 | |
1325 glLightfv(GL_LIGHT1, GL_POSITION, U.light[1].vec);· | |
1326 glLightfv(GL_LIGHT1, GL_DIFFUSE, U.light[1].col);· | |
1327 glLightfv(GL_LIGHT1, GL_SPECULAR, U.light[1].spec);· | |
1328 | |
1329 glLightfv(GL_LIGHT2, GL_POSITION, U.light[2].vec);· | |
1330 glLightfv(GL_LIGHT2, GL_DIFFUSE, U.light[2].col);· | |
1331 glLightfv(GL_LIGHT2, GL_SPECULAR, U.light[2].spec);· | |
1332 | |
1333 for(a=0; a<8; a++) { | |
1334 if(a<3) { | |
1335 if(U.light[a].flag) { | |
1336 glEnable(GL_LIGHT0+a); | |
1337 count++; | |
1338 } | |
1339 else | |
1340 glDisable(GL_LIGHT0+a); | |
1341 ························ | |
1342 // clear stuff from other opengl lamp usage | |
1343 glLightf(GL_LIGHT0+a, GL_SPOT_CUTOFF, 180.0); | |
1344 glLightf(GL_LIGHT0+a, GL_CONSTANT_ATTENUATION, 1.0); | |
1345 glLightf(GL_LIGHT0+a, GL_LINEAR_ATTENUATION, 0.0); | |
1346 } | |
1347 else | |
1348 glDisable(GL_LIGHT0+a); | |
1349 } | |
1350 ········ | |
1351 glDisable(GL_LIGHTING); | |
1352 | |
1353 glDisable(GL_COLOR_MATERIAL); | |
1354 | |
1355 return count; | |
1356 } | |
1357 | |
1358 int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4
], int ortho) | |
1359 { | |
1360 Base *base; | |
1361 Lamp *la; | |
1362 int count; | |
1363 float position[4], direction[4], energy[4]; | |
1364 ········ | |
1365 /* disable all lights */ | |
1366 for(count=0; count<8; count++) | |
1367 glDisable(GL_LIGHT0+count); | |
1368 ········ | |
1369 /* view direction for specular is not compute correct by default in | |
1370 * opengl, so we set the settings ourselfs */ | |
1371 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (ortho)? GL_FALSE: GL_TRUE); | |
1372 | |
1373 count= 0; | |
1374 ········ | |
1375 for(base=scene->base.first; base; base=base->next) { | |
1376 if(base->object->type!=OB_LAMP) | |
1377 continue; | |
1378 | |
1379 if(!(base->lay & lay) || !(base->lay & ob->lay)) | |
1380 continue; | |
1381 | |
1382 la= base->object->data; | |
1383 ················ | |
1384 /* setup lamp transform */ | |
1385 glPushMatrix(); | |
1386 glLoadMatrixf((float *)viewmat); | |
1387 ················ | |
1388 where_is_object_simul(scene, base->object); | |
1389 ················ | |
1390 if(la->type==LA_SUN) { | |
1391 /* sun lamp */ | |
1392 copy_v3_v3(direction, base->object->obmat[2]); | |
1393 direction[3]= 0.0; | |
1394 | |
1395 glLightfv(GL_LIGHT0+count, GL_POSITION, direction);· | |
1396 } | |
1397 else { | |
1398 /* other lamps with attenuation */ | |
1399 copy_v3_v3(position, base->object->obmat[3]); | |
1400 position[3]= 1.0f; | |
1401 | |
1402 glLightfv(GL_LIGHT0+count, GL_POSITION, position);· | |
1403 glLightf(GL_LIGHT0+count, GL_CONSTANT_ATTENUATION, 1.0); | |
1404 glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, la->att
1/la->dist); | |
1405 glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, la->
att2/(la->dist*la->dist)); | |
1406 ························ | |
1407 if(la->type==LA_SPOT) { | |
1408 /* spot lamp */ | |
1409 negate_v3_v3(direction, base->object->obmat[2]); | |
1410 glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, di
rection); | |
1411 glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->sp
otsize/2.0f); | |
1412 glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.
0f*la->spotblend); | |
1413 } | |
1414 else | |
1415 glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, 180.0)
; | |
1416 } | |
1417 ················ | |
1418 /* setup energy */ | |
1419 mul_v3_v3fl(energy, &la->r, la->energy); | |
1420 energy[3]= 1.0; | |
1421 | |
1422 glLightfv(GL_LIGHT0+count, GL_DIFFUSE, energy);· | |
1423 glLightfv(GL_LIGHT0+count, GL_SPECULAR, energy); | |
1424 glEnable(GL_LIGHT0+count); | |
1425 ················ | |
1426 glPopMatrix();·································· | |
1427 ················ | |
1428 count++; | |
1429 if(count==8) | |
1430 break; | |
1431 } | |
1432 | |
1433 return count; | |
1434 } | |
1435 | |
1436 /* Default OpenGL State */ | |
1437 | |
1438 void GPU_state_init(void) | |
1439 { | |
1440 /* also called when doing opengl rendering and in the game engine */ | |
1441 float mat_ambient[] = { 0.0, 0.0, 0.0, 0.0 }; | |
1442 float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; | |
1443 int a, x, y; | |
1444 GLubyte pat[32*32]; | |
1445 const GLubyte *patc= pat; | |
1446 ········ | |
1447 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); | |
1448 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular); | |
1449 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); | |
1450 glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 35); | |
1451 | |
1452 GPU_default_lights(); | |
1453 ········ | |
1454 glDepthFunc(GL_LEQUAL); | |
1455 /* scaling matrices */ | |
1456 glEnable(GL_NORMALIZE); | |
1457 | |
1458 glShadeModel(GL_FLAT); | |
1459 | |
1460 glDisable(GL_ALPHA_TEST); | |
1461 glDisable(GL_BLEND); | |
1462 glDisable(GL_DEPTH_TEST); | |
1463 glDisable(GL_FOG); | |
1464 glDisable(GL_LIGHTING); | |
1465 glDisable(GL_LOGIC_OP); | |
1466 glDisable(GL_STENCIL_TEST); | |
1467 glDisable(GL_TEXTURE_1D); | |
1468 glDisable(GL_TEXTURE_2D); | |
1469 | |
1470 /* default disabled, enable should be local per function */ | |
1471 glDisableClientState(GL_VERTEX_ARRAY); | |
1472 glDisableClientState(GL_NORMAL_ARRAY); | |
1473 glDisableClientState(GL_COLOR_ARRAY); | |
1474 glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |
1475 ········ | |
1476 glPixelTransferi(GL_MAP_COLOR, GL_FALSE); | |
1477 glPixelTransferi(GL_RED_SCALE, 1); | |
1478 glPixelTransferi(GL_RED_BIAS, 0); | |
1479 glPixelTransferi(GL_GREEN_SCALE, 1); | |
1480 glPixelTransferi(GL_GREEN_BIAS, 0); | |
1481 glPixelTransferi(GL_BLUE_SCALE, 1); | |
1482 glPixelTransferi(GL_BLUE_BIAS, 0); | |
1483 glPixelTransferi(GL_ALPHA_SCALE, 1); | |
1484 glPixelTransferi(GL_ALPHA_BIAS, 0); | |
1485 ········ | |
1486 glPixelTransferi(GL_DEPTH_BIAS, 0); | |
1487 glPixelTransferi(GL_DEPTH_SCALE, 1); | |
1488 glDepthRange(0.0, 1.0); | |
1489 ········ | |
1490 a= 0; | |
1491 for(x=0; x<32; x++) { | |
1492 for(y=0; y<4; y++) { | |
1493 if( (x) & 1) pat[a++]= 0x88; | |
1494 else pat[a++]= 0x22; | |
1495 } | |
1496 } | |
1497 ········ | |
1498 glPolygonStipple(patc); | |
1499 | |
1500 glMatrixMode(GL_TEXTURE); | |
1501 glLoadIdentity(); | |
1502 glMatrixMode(GL_MODELVIEW); | |
1503 | |
1504 glFrontFace(GL_CCW); | |
1505 glCullFace(GL_BACK); | |
1506 glDisable(GL_CULL_FACE); | |
1507 | |
1508 /* calling this makes drawing very slow when AA is not set up in ghost | |
1509 on Linux/NVIDIA. | |
1510 glDisable(GL_MULTISAMPLE); */ | |
1511 } | |
1512 | |
1513 /* debugging aid */ | |
1514 static void gpu_get_print(const char *name, GLenum type) | |
1515 { | |
1516 float value[16]; | |
1517 int a; | |
1518 ········ | |
1519 memset(value, 0, sizeof(value)); | |
1520 glGetFloatv(type, value); | |
1521 | |
1522 printf("%s: ", name); | |
1523 for(a=0; a<16; a++) | |
1524 printf("%.2f ", value[a]); | |
1525 printf("\n"); | |
1526 } | |
1527 | |
1528 void GPU_state_print(void) | |
1529 { | |
1530 gpu_get_print("GL_ACCUM_ALPHA_BITS", GL_ACCUM_ALPHA_BITS); | |
1531 gpu_get_print("GL_ACCUM_BLUE_BITS", GL_ACCUM_BLUE_BITS); | |
1532 gpu_get_print("GL_ACCUM_CLEAR_VALUE", GL_ACCUM_CLEAR_VALUE); | |
1533 gpu_get_print("GL_ACCUM_GREEN_BITS", GL_ACCUM_GREEN_BITS); | |
1534 gpu_get_print("GL_ACCUM_RED_BITS", GL_ACCUM_RED_BITS); | |
1535 gpu_get_print("GL_ACTIVE_TEXTURE", GL_ACTIVE_TEXTURE); | |
1536 gpu_get_print("GL_ALIASED_POINT_SIZE_RANGE", GL_ALIASED_POINT_SIZE_RANGE
); | |
1537 gpu_get_print("GL_ALIASED_LINE_WIDTH_RANGE", GL_ALIASED_LINE_WIDTH_RANGE
); | |
1538 gpu_get_print("GL_ALPHA_BIAS", GL_ALPHA_BIAS); | |
1539 gpu_get_print("GL_ALPHA_BITS", GL_ALPHA_BITS); | |
1540 gpu_get_print("GL_ALPHA_SCALE", GL_ALPHA_SCALE); | |
1541 gpu_get_print("GL_ALPHA_TEST", GL_ALPHA_TEST); | |
1542 gpu_get_print("GL_ALPHA_TEST_FUNC", GL_ALPHA_TEST_FUNC); | |
1543 gpu_get_print("GL_ALPHA_TEST_REF", GL_ALPHA_TEST_REF); | |
1544 gpu_get_print("GL_ARRAY_BUFFER_BINDING", GL_ARRAY_BUFFER_BINDING); | |
1545 gpu_get_print("GL_ATTRIB_STACK_DEPTH", GL_ATTRIB_STACK_DEPTH); | |
1546 gpu_get_print("GL_AUTO_NORMAL", GL_AUTO_NORMAL); | |
1547 gpu_get_print("GL_AUX_BUFFERS", GL_AUX_BUFFERS); | |
1548 gpu_get_print("GL_BLEND", GL_BLEND); | |
1549 gpu_get_print("GL_BLEND_COLOR", GL_BLEND_COLOR); | |
1550 gpu_get_print("GL_BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA); | |
1551 gpu_get_print("GL_BLEND_DST_RGB", GL_BLEND_DST_RGB); | |
1552 gpu_get_print("GL_BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB); | |
1553 gpu_get_print("GL_BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA); | |
1554 gpu_get_print("GL_BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA); | |
1555 gpu_get_print("GL_BLEND_SRC_RGB", GL_BLEND_SRC_RGB); | |
1556 gpu_get_print("GL_BLUE_BIAS", GL_BLUE_BIAS); | |
1557 gpu_get_print("GL_BLUE_BITS", GL_BLUE_BITS); | |
1558 gpu_get_print("GL_BLUE_SCALE", GL_BLUE_SCALE); | |
1559 gpu_get_print("GL_CLIENT_ACTIVE_TEXTURE", GL_CLIENT_ACTIVE_TEXTURE); | |
1560 gpu_get_print("GL_CLIENT_ATTRIB_STACK_DEPTH", GL_CLIENT_ATTRIB_STACK_DEP
TH); | |
1561 gpu_get_print("GL_CLIP_PLANE0", GL_CLIP_PLANE0); | |
1562 gpu_get_print("GL_COLOR_ARRAY", GL_COLOR_ARRAY); | |
1563 gpu_get_print("GL_COLOR_ARRAY_BUFFER_BINDING", GL_COLOR_ARRAY_BUFFER_BIN
DING); | |
1564 gpu_get_print("GL_COLOR_ARRAY_SIZE", GL_COLOR_ARRAY_SIZE); | |
1565 gpu_get_print("GL_COLOR_ARRAY_STRIDE", GL_COLOR_ARRAY_STRIDE); | |
1566 gpu_get_print("GL_COLOR_ARRAY_TYPE", GL_COLOR_ARRAY_TYPE); | |
1567 gpu_get_print("GL_COLOR_CLEAR_VALUE", GL_COLOR_CLEAR_VALUE); | |
1568 gpu_get_print("GL_COLOR_LOGIC_OP", GL_COLOR_LOGIC_OP); | |
1569 gpu_get_print("GL_COLOR_MATERIAL", GL_COLOR_MATERIAL); | |
1570 gpu_get_print("GL_COLOR_MATERIAL_FACE", GL_COLOR_MATERIAL_FACE); | |
1571 gpu_get_print("GL_COLOR_MATERIAL_PARAMETER", GL_COLOR_MATERIAL_PARAMETER
); | |
1572 gpu_get_print("GL_COLOR_MATRIX", GL_COLOR_MATRIX); | |
1573 gpu_get_print("GL_COLOR_MATRIX_STACK_DEPTH", GL_COLOR_MATRIX_STACK_DEPTH
); | |
1574 gpu_get_print("GL_COLOR_SUM", GL_COLOR_SUM); | |
1575 gpu_get_print("GL_COLOR_TABLE", GL_COLOR_TABLE); | |
1576 gpu_get_print("GL_COLOR_WRITEMASK", GL_COLOR_WRITEMASK); | |
1577 gpu_get_print("GL_COMPRESSED_TEXTURE_FORMATS", GL_COMPRESSED_TEXTURE_FOR
MATS); | |
1578 gpu_get_print("GL_CONVOLUTION_1D", GL_CONVOLUTION_1D); | |
1579 gpu_get_print("GL_CONVOLUTION_2D", GL_CONVOLUTION_2D); | |
1580 gpu_get_print("GL_CULL_FACE", GL_CULL_FACE); | |
1581 gpu_get_print("GL_CULL_FACE_MODE", GL_CULL_FACE_MODE); | |
1582 gpu_get_print("GL_CURRENT_COLOR", GL_CURRENT_COLOR); | |
1583 gpu_get_print("GL_CURRENT_FOG_COORD", GL_CURRENT_FOG_COORD); | |
1584 gpu_get_print("GL_CURRENT_INDEX", GL_CURRENT_INDEX); | |
1585 gpu_get_print("GL_CURRENT_NORMAL", GL_CURRENT_NORMAL); | |
1586 gpu_get_print("GL_CURRENT_PROGRAM", GL_CURRENT_PROGRAM); | |
1587 gpu_get_print("GL_CURRENT_RASTER_COLOR", GL_CURRENT_RASTER_COLOR); | |
1588 gpu_get_print("GL_CURRENT_RASTER_DISTANCE", GL_CURRENT_RASTER_DISTANCE); | |
1589 gpu_get_print("GL_CURRENT_RASTER_INDEX", GL_CURRENT_RASTER_INDEX); | |
1590 gpu_get_print("GL_CURRENT_RASTER_POSITION", GL_CURRENT_RASTER_POSITION); | |
1591 gpu_get_print("GL_CURRENT_RASTER_POSITION_VALID", GL_CURRENT_RASTER_POSI
TION_VALID); | |
1592 gpu_get_print("GL_CURRENT_RASTER_SECONDARY_COLOR", GL_CURRENT_RASTER_SEC
ONDARY_COLOR); | |
1593 gpu_get_print("GL_CURRENT_RASTER_TEXTURE_COORDS", GL_CURRENT_RASTER_TEXT
URE_COORDS); | |
1594 gpu_get_print("GL_CURRENT_SECONDARY_COLOR", GL_CURRENT_SECONDARY_COLOR); | |
1595 gpu_get_print("GL_CURRENT_TEXTURE_COORDS", GL_CURRENT_TEXTURE_COORDS); | |
1596 gpu_get_print("GL_DEPTH_BIAS", GL_DEPTH_BIAS); | |
1597 gpu_get_print("GL_DEPTH_BITS", GL_DEPTH_BITS); | |
1598 gpu_get_print("GL_DEPTH_CLEAR_VALUE", GL_DEPTH_CLEAR_VALUE); | |
1599 gpu_get_print("GL_DEPTH_FUNC", GL_DEPTH_FUNC); | |
1600 gpu_get_print("GL_DEPTH_RANGE", GL_DEPTH_RANGE); | |
1601 gpu_get_print("GL_DEPTH_SCALE", GL_DEPTH_SCALE); | |
1602 gpu_get_print("GL_DEPTH_TEST", GL_DEPTH_TEST); | |
1603 gpu_get_print("GL_DEPTH_WRITEMASK", GL_DEPTH_WRITEMASK); | |
1604 gpu_get_print("GL_DITHER", GL_DITHER); | |
1605 gpu_get_print("GL_DOUBLEBUFFER", GL_DOUBLEBUFFER); | |
1606 gpu_get_print("GL_DRAW_BUFFER", GL_DRAW_BUFFER); | |
1607 gpu_get_print("GL_DRAW_BUFFER0", GL_DRAW_BUFFER0); | |
1608 gpu_get_print("GL_EDGE_FLAG", GL_EDGE_FLAG); | |
1609 gpu_get_print("GL_EDGE_FLAG_ARRAY", GL_EDGE_FLAG_ARRAY); | |
1610 gpu_get_print("GL_EDGE_FLAG_ARRAY_BUFFER_BINDING", GL_EDGE_FLAG_ARRAY_BU
FFER_BINDING); | |
1611 gpu_get_print("GL_EDGE_FLAG_ARRAY_STRIDE", GL_EDGE_FLAG_ARRAY_STRIDE); | |
1612 gpu_get_print("GL_ELEMENT_ARRAY_BUFFER_BINDING", GL_ELEMENT_ARRAY_BUFFER
_BINDING); | |
1613 gpu_get_print("GL_FEEDBACK_BUFFER_SIZE", GL_FEEDBACK_BUFFER_SIZE); | |
1614 gpu_get_print("GL_FEEDBACK_BUFFER_TYPE", GL_FEEDBACK_BUFFER_TYPE); | |
1615 gpu_get_print("GL_FOG", GL_FOG); | |
1616 gpu_get_print("GL_FOG_COORD_ARRAY", GL_FOG_COORD_ARRAY); | |
1617 gpu_get_print("GL_FOG_COORD_ARRAY_BUFFER_BINDING", GL_FOG_COORD_ARRAY_BU
FFER_BINDING); | |
1618 gpu_get_print("GL_FOG_COORD_ARRAY_STRIDE", GL_FOG_COORD_ARRAY_STRIDE); | |
1619 gpu_get_print("GL_FOG_COORD_ARRAY_TYPE", GL_FOG_COORD_ARRAY_TYPE); | |
1620 gpu_get_print("GL_FOG_COORD_SRC", GL_FOG_COORD_SRC); | |
1621 gpu_get_print("GL_FOG_COLOR", GL_FOG_COLOR); | |
1622 gpu_get_print("GL_FOG_DENSITY", GL_FOG_DENSITY); | |
1623 gpu_get_print("GL_FOG_END", GL_FOG_END); | |
1624 gpu_get_print("GL_FOG_HINT", GL_FOG_HINT); | |
1625 gpu_get_print("GL_FOG_INDEX", GL_FOG_INDEX); | |
1626 gpu_get_print("GL_FOG_MODE", GL_FOG_MODE); | |
1627 gpu_get_print("GL_FOG_START", GL_FOG_START); | |
1628 gpu_get_print("GL_FRAGMENT_SHADER_DERIVATIVE_HINT", GL_FRAGMENT_SHADER_D
ERIVATIVE_HINT); | |
1629 gpu_get_print("GL_FRONT_FACE", GL_FRONT_FACE); | |
1630 gpu_get_print("GL_GENERATE_MIPMAP_HINT", GL_GENERATE_MIPMAP_HINT); | |
1631 gpu_get_print("GL_GREEN_BIAS", GL_GREEN_BIAS); | |
1632 gpu_get_print("GL_GREEN_BITS", GL_GREEN_BITS); | |
1633 gpu_get_print("GL_GREEN_SCALE", GL_GREEN_SCALE); | |
1634 gpu_get_print("GL_HISTOGRAM", GL_HISTOGRAM); | |
1635 gpu_get_print("GL_INDEX_ARRAY", GL_INDEX_ARRAY); | |
1636 gpu_get_print("GL_INDEX_ARRAY_BUFFER_BINDING", GL_INDEX_ARRAY_BUFFER_BIN
DING); | |
1637 gpu_get_print("GL_INDEX_ARRAY_STRIDE", GL_INDEX_ARRAY_STRIDE); | |
1638 gpu_get_print("GL_INDEX_ARRAY_TYPE", GL_INDEX_ARRAY_TYPE); | |
1639 gpu_get_print("GL_INDEX_BITS", GL_INDEX_BITS); | |
1640 gpu_get_print("GL_INDEX_CLEAR_VALUE", GL_INDEX_CLEAR_VALUE); | |
1641 gpu_get_print("GL_INDEX_LOGIC_OP", GL_INDEX_LOGIC_OP); | |
1642 gpu_get_print("GL_INDEX_MODE", GL_INDEX_MODE); | |
1643 gpu_get_print("GL_INDEX_OFFSET", GL_INDEX_OFFSET); | |
1644 gpu_get_print("GL_INDEX_SHIFT", GL_INDEX_SHIFT); | |
1645 gpu_get_print("GL_INDEX_WRITEMASK", GL_INDEX_WRITEMASK); | |
1646 gpu_get_print("GL_LIGHT0", GL_LIGHT0); | |
1647 gpu_get_print("GL_LIGHTING", GL_LIGHTING); | |
1648 gpu_get_print("GL_LIGHT_MODEL_AMBIENT", GL_LIGHT_MODEL_AMBIENT); | |
1649 gpu_get_print("GL_LIGHT_MODEL_COLOR_CONTROL", GL_LIGHT_MODEL_COLOR_CONTR
OL); | |
1650 gpu_get_print("GL_LIGHT_MODEL_LOCAL_VIEWER", GL_LIGHT_MODEL_LOCAL_VIEWER
); | |
1651 gpu_get_print("GL_LIGHT_MODEL_TWO_SIDE", GL_LIGHT_MODEL_TWO_SIDE); | |
1652 gpu_get_print("GL_LINE_SMOOTH", GL_LINE_SMOOTH); | |
1653 gpu_get_print("GL_LINE_SMOOTH_HINT", GL_LINE_SMOOTH_HINT); | |
1654 gpu_get_print("GL_LINE_STIPPLE", GL_LINE_STIPPLE); | |
1655 gpu_get_print("GL_LINE_STIPPLE_PATTERN", GL_LINE_STIPPLE_PATTERN); | |
1656 gpu_get_print("GL_LINE_STIPPLE_REPEAT", GL_LINE_STIPPLE_REPEAT); | |
1657 gpu_get_print("GL_LINE_WIDTH", GL_LINE_WIDTH); | |
1658 gpu_get_print("GL_LINE_WIDTH_GRANULARITY", GL_LINE_WIDTH_GRANULARITY); | |
1659 gpu_get_print("GL_LINE_WIDTH_RANGE", GL_LINE_WIDTH_RANGE); | |
1660 gpu_get_print("GL_LIST_BASE", GL_LIST_BASE); | |
1661 gpu_get_print("GL_LIST_INDEX", GL_LIST_INDEX); | |
1662 gpu_get_print("GL_LIST_MODE", GL_LIST_MODE); | |
1663 gpu_get_print("GL_LOGIC_OP_MODE", GL_LOGIC_OP_MODE); | |
1664 gpu_get_print("GL_MAP1_COLOR_4", GL_MAP1_COLOR_4); | |
1665 gpu_get_print("GL_MAP1_GRID_DOMAIN", GL_MAP1_GRID_DOMAIN); | |
1666 gpu_get_print("GL_MAP1_GRID_SEGMENTS", GL_MAP1_GRID_SEGMENTS); | |
1667 gpu_get_print("GL_MAP1_INDEX", GL_MAP1_INDEX); | |
1668 gpu_get_print("GL_MAP1_NORMAL", GL_MAP1_NORMAL); | |
1669 gpu_get_print("GL_MAP1_TEXTURE_COORD_1", GL_MAP1_TEXTURE_COORD_1); | |
1670 gpu_get_print("GL_MAP1_TEXTURE_COORD_2", GL_MAP1_TEXTURE_COORD_2); | |
1671 gpu_get_print("GL_MAP1_TEXTURE_COORD_3", GL_MAP1_TEXTURE_COORD_3); | |
1672 gpu_get_print("GL_MAP1_TEXTURE_COORD_4", GL_MAP1_TEXTURE_COORD_4); | |
1673 gpu_get_print("GL_MAP1_VERTEX_3", GL_MAP1_VERTEX_3); | |
1674 gpu_get_print("GL_MAP1_VERTEX_4", GL_MAP1_VERTEX_4); | |
1675 gpu_get_print("GL_MAP2_COLOR_4", GL_MAP2_COLOR_4); | |
1676 gpu_get_print("GL_MAP2_GRID_DOMAIN", GL_MAP2_GRID_DOMAIN); | |
1677 gpu_get_print("GL_MAP2_GRID_SEGMENTS", GL_MAP2_GRID_SEGMENTS); | |
1678 gpu_get_print("GL_MAP2_INDEX", GL_MAP2_INDEX); | |
1679 gpu_get_print("GL_MAP2_NORMAL", GL_MAP2_NORMAL); | |
1680 gpu_get_print("GL_MAP2_TEXTURE_COORD_1", GL_MAP2_TEXTURE_COORD_1); | |
1681 gpu_get_print("GL_MAP2_TEXTURE_COORD_2", GL_MAP2_TEXTURE_COORD_2); | |
1682 gpu_get_print("GL_MAP2_TEXTURE_COORD_3", GL_MAP2_TEXTURE_COORD_3); | |
1683 gpu_get_print("GL_MAP2_TEXTURE_COORD_4", GL_MAP2_TEXTURE_COORD_4); | |
1684 gpu_get_print("GL_MAP2_VERTEX_3", GL_MAP2_VERTEX_3); | |
1685 gpu_get_print("GL_MAP2_VERTEX_4", GL_MAP2_VERTEX_4); | |
1686 gpu_get_print("GL_MAP_COLOR", GL_MAP_COLOR); | |
1687 gpu_get_print("GL_MAP_STENCIL", GL_MAP_STENCIL); | |
1688 gpu_get_print("GL_MATRIX_MODE", GL_MATRIX_MODE); | |
1689 gpu_get_print("GL_MAX_3D_TEXTURE_SIZE", GL_MAX_3D_TEXTURE_SIZE); | |
1690 gpu_get_print("GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GL_MAX_CLIENT_ATTRIB_S
TACK_DEPTH); | |
1691 gpu_get_print("GL_MAX_ATTRIB_STACK_DEPTH", GL_MAX_ATTRIB_STACK_DEPTH); | |
1692 gpu_get_print("GL_MAX_CLIP_PLANES", GL_MAX_CLIP_PLANES); | |
1693 gpu_get_print("GL_MAX_COLOR_MATRIX_STACK_DEPTH", GL_MAX_COLOR_MATRIX_STA
CK_DEPTH); | |
1694 gpu_get_print("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS", GL_MAX_COMBINED_TEX
TURE_IMAGE_UNITS); | |
1695 gpu_get_print("GL_MAX_CUBE_MAP_TEXTURE_SIZE", GL_MAX_CUBE_MAP_TEXTURE_SI
ZE); | |
1696 gpu_get_print("GL_MAX_DRAW_BUFFERS", GL_MAX_DRAW_BUFFERS); | |
1697 gpu_get_print("GL_MAX_ELEMENTS_INDICES", GL_MAX_ELEMENTS_INDICES); | |
1698 gpu_get_print("GL_MAX_ELEMENTS_VERTICES", GL_MAX_ELEMENTS_VERTICES); | |
1699 gpu_get_print("GL_MAX_EVAL_ORDER", GL_MAX_EVAL_ORDER); | |
1700 gpu_get_print("GL_MAX_FRAGMENT_UNIFORM_COMPONENTS", GL_MAX_FRAGMENT_UNIF
ORM_COMPONENTS); | |
1701 gpu_get_print("GL_MAX_LIGHTS", GL_MAX_LIGHTS); | |
1702 gpu_get_print("GL_MAX_LIST_NESTING", GL_MAX_LIST_NESTING); | |
1703 gpu_get_print("GL_MAX_MODELVIEW_STACK_DEPTH", GL_MAX_MODELVIEW_STACK_DEP
TH); | |
1704 gpu_get_print("GL_MAX_NAME_STACK_DEPTH", GL_MAX_NAME_STACK_DEPTH); | |
1705 gpu_get_print("GL_MAX_PIXEL_MAP_TABLE", GL_MAX_PIXEL_MAP_TABLE); | |
1706 gpu_get_print("GL_MAX_PROJECTION_STACK_DEPTH", GL_MAX_PROJECTION_STACK_D
EPTH); | |
1707 gpu_get_print("GL_MAX_TEXTURE_COORDS", GL_MAX_TEXTURE_COORDS); | |
1708 gpu_get_print("GL_MAX_TEXTURE_IMAGE_UNITS", GL_MAX_TEXTURE_IMAGE_UNITS); | |
1709 gpu_get_print("GL_MAX_TEXTURE_LOD_BIAS", GL_MAX_TEXTURE_LOD_BIAS); | |
1710 gpu_get_print("GL_MAX_TEXTURE_SIZE", GL_MAX_TEXTURE_SIZE); | |
1711 gpu_get_print("GL_MAX_TEXTURE_STACK_DEPTH", GL_MAX_TEXTURE_STACK_DEPTH); | |
1712 gpu_get_print("GL_MAX_TEXTURE_UNITS", GL_MAX_TEXTURE_UNITS); | |
1713 gpu_get_print("GL_MAX_VARYING_FLOATS", GL_MAX_VARYING_FLOATS); | |
1714 gpu_get_print("GL_MAX_VERTEX_ATTRIBS", GL_MAX_VERTEX_ATTRIBS); | |
1715 gpu_get_print("GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS", GL_MAX_VERTEX_TEXTURE
_IMAGE_UNITS); | |
1716 gpu_get_print("GL_MAX_VERTEX_UNIFORM_COMPONENTS", GL_MAX_VERTEX_UNIFORM_
COMPONENTS); | |
1717 gpu_get_print("GL_MAX_VIEWPORT_DIMS", GL_MAX_VIEWPORT_DIMS); | |
1718 gpu_get_print("GL_MINMAX", GL_MINMAX); | |
1719 gpu_get_print("GL_MODELVIEW_MATRIX", GL_MODELVIEW_MATRIX); | |
1720 gpu_get_print("GL_MODELVIEW_STACK_DEPTH", GL_MODELVIEW_STACK_DEPTH); | |
1721 gpu_get_print("GL_NAME_STACK_DEPTH", GL_NAME_STACK_DEPTH); | |
1722 gpu_get_print("GL_NORMAL_ARRAY", GL_NORMAL_ARRAY); | |
1723 gpu_get_print("GL_NORMAL_ARRAY_BUFFER_BINDING", GL_NORMAL_ARRAY_BUFFER_B
INDING); | |
1724 gpu_get_print("GL_NORMAL_ARRAY_STRIDE", GL_NORMAL_ARRAY_STRIDE); | |
1725 gpu_get_print("GL_NORMAL_ARRAY_TYPE", GL_NORMAL_ARRAY_TYPE); | |
1726 gpu_get_print("GL_NORMALIZE", GL_NORMALIZE); | |
1727 gpu_get_print("GL_NUM_COMPRESSED_TEXTURE_FORMATS", GL_NUM_COMPRESSED_TEX
TURE_FORMATS); | |
1728 gpu_get_print("GL_PACK_ALIGNMENT", GL_PACK_ALIGNMENT); | |
1729 gpu_get_print("GL_PACK_IMAGE_HEIGHT", GL_PACK_IMAGE_HEIGHT); | |
1730 gpu_get_print("GL_PACK_LSB_FIRST", GL_PACK_LSB_FIRST); | |
1731 gpu_get_print("GL_PACK_ROW_LENGTH", GL_PACK_ROW_LENGTH); | |
1732 gpu_get_print("GL_PACK_SKIP_IMAGES", GL_PACK_SKIP_IMAGES); | |
1733 gpu_get_print("GL_PACK_SKIP_PIXELS", GL_PACK_SKIP_PIXELS); | |
1734 gpu_get_print("GL_PACK_SKIP_ROWS", GL_PACK_SKIP_ROWS); | |
1735 gpu_get_print("GL_PACK_SWAP_BYTES", GL_PACK_SWAP_BYTES); | |
1736 gpu_get_print("GL_PERSPECTIVE_CORRECTION_HINT", GL_PERSPECTIVE_CORRECTIO
N_HINT); | |
1737 gpu_get_print("GL_PIXEL_MAP_A_TO_A_SIZE", GL_PIXEL_MAP_A_TO_A_SIZE); | |
1738 gpu_get_print("GL_PIXEL_MAP_B_TO_B_SIZE", GL_PIXEL_MAP_B_TO_B_SIZE); | |
1739 gpu_get_print("GL_PIXEL_MAP_G_TO_G_SIZE", GL_PIXEL_MAP_G_TO_G_SIZE); | |
1740 gpu_get_print("GL_PIXEL_MAP_I_TO_A_SIZE", GL_PIXEL_MAP_I_TO_A_SIZE); | |
1741 gpu_get_print("GL_PIXEL_MAP_I_TO_B_SIZE", GL_PIXEL_MAP_I_TO_B_SIZE); | |
1742 gpu_get_print("GL_PIXEL_MAP_I_TO_G_SIZE", GL_PIXEL_MAP_I_TO_G_SIZE); | |
1743 gpu_get_print("GL_PIXEL_MAP_I_TO_I_SIZE", GL_PIXEL_MAP_I_TO_I_SIZE); | |
1744 gpu_get_print("GL_PIXEL_MAP_I_TO_R_SIZE", GL_PIXEL_MAP_I_TO_R_SIZE); | |
1745 gpu_get_print("GL_PIXEL_MAP_R_TO_R_SIZE", GL_PIXEL_MAP_R_TO_R_SIZE); | |
1746 gpu_get_print("GL_PIXEL_MAP_S_TO_S_SIZE", GL_PIXEL_MAP_S_TO_S_SIZE); | |
1747 gpu_get_print("GL_PIXEL_PACK_BUFFER_BINDING", GL_PIXEL_PACK_BUFFER_BINDI
NG); | |
1748 gpu_get_print("GL_PIXEL_UNPACK_BUFFER_BINDING", GL_PIXEL_UNPACK_BUFFER_B
INDING); | |
1749 gpu_get_print("GL_POINT_DISTANCE_ATTENUATION", GL_POINT_DISTANCE_ATTENUA
TION); | |
1750 gpu_get_print("GL_POINT_FADE_THRESHOLD_SIZE", GL_POINT_FADE_THRESHOLD_SI
ZE); | |
1751 gpu_get_print("GL_POINT_SIZE", GL_POINT_SIZE); | |
1752 gpu_get_print("GL_POINT_SIZE_GRANULARITY", GL_POINT_SIZE_GRANULARITY); | |
1753 gpu_get_print("GL_POINT_SIZE_MAX", GL_POINT_SIZE_MAX); | |
1754 gpu_get_print("GL_POINT_SIZE_MIN", GL_POINT_SIZE_MIN); | |
1755 gpu_get_print("GL_POINT_SIZE_RANGE", GL_POINT_SIZE_RANGE); | |
1756 gpu_get_print("GL_POINT_SMOOTH", GL_POINT_SMOOTH); | |
1757 gpu_get_print("GL_POINT_SMOOTH_HINT", GL_POINT_SMOOTH_HINT); | |
1758 gpu_get_print("GL_POINT_SPRITE", GL_POINT_SPRITE); | |
1759 gpu_get_print("GL_POLYGON_MODE", GL_POLYGON_MODE); | |
1760 gpu_get_print("GL_POLYGON_OFFSET_FACTOR", GL_POLYGON_OFFSET_FACTOR); | |
1761 gpu_get_print("GL_POLYGON_OFFSET_UNITS", GL_POLYGON_OFFSET_UNITS); | |
1762 gpu_get_print("GL_POLYGON_OFFSET_FILL", GL_POLYGON_OFFSET_FILL); | |
1763 gpu_get_print("GL_POLYGON_OFFSET_LINE", GL_POLYGON_OFFSET_LINE); | |
1764 gpu_get_print("GL_POLYGON_OFFSET_POINT", GL_POLYGON_OFFSET_POINT); | |
1765 gpu_get_print("GL_POLYGON_SMOOTH", GL_POLYGON_SMOOTH); | |
1766 gpu_get_print("GL_POLYGON_SMOOTH_HINT", GL_POLYGON_SMOOTH_HINT); | |
1767 gpu_get_print("GL_POLYGON_STIPPLE", GL_POLYGON_STIPPLE); | |
1768 gpu_get_print("GL_POST_COLOR_MATRIX_COLOR_TABLE", GL_POST_COLOR_MATRIX_C
OLOR_TABLE); | |
1769 gpu_get_print("GL_POST_COLOR_MATRIX_RED_BIAS", GL_POST_COLOR_MATRIX_RED_
BIAS); | |
1770 gpu_get_print("GL_POST_COLOR_MATRIX_GREEN_BIAS", GL_POST_COLOR_MATRIX_GR
EEN_BIAS); | |
1771 gpu_get_print("GL_POST_COLOR_MATRIX_BLUE_BIAS", GL_POST_COLOR_MATRIX_BLU
E_BIAS); | |
1772 gpu_get_print("GL_POST_COLOR_MATRIX_ALPHA_BIAS", GL_POST_COLOR_MATRIX_AL
PHA_BIAS); | |
1773 gpu_get_print("GL_POST_COLOR_MATRIX_RED_SCALE", GL_POST_COLOR_MATRIX_RED
_SCALE); | |
1774 gpu_get_print("GL_POST_COLOR_MATRIX_GREEN_SCALE", GL_POST_COLOR_MATRIX_G
REEN_SCALE); | |
1775 gpu_get_print("GL_POST_COLOR_MATRIX_BLUE_SCALE", GL_POST_COLOR_MATRIX_BL
UE_SCALE); | |
1776 gpu_get_print("GL_POST_COLOR_MATRIX_ALPHA_SCALE", GL_POST_COLOR_MATRIX_A
LPHA_SCALE); | |
1777 gpu_get_print("GL_POST_CONVOLUTION_COLOR_TABLE", GL_POST_CONVOLUTION_COL
OR_TABLE); | |
1778 gpu_get_print("GL_POST_CONVOLUTION_RED_BIAS", GL_POST_CONVOLUTION_RED_BI
AS); | |
1779 gpu_get_print("GL_POST_CONVOLUTION_GREEN_BIAS", GL_POST_CONVOLUTION_GREE
N_BIAS); | |
1780 gpu_get_print("GL_POST_CONVOLUTION_BLUE_BIAS", GL_POST_CONVOLUTION_BLUE_
BIAS); | |
1781 gpu_get_print("GL_POST_CONVOLUTION_ALPHA_BIAS", GL_POST_CONVOLUTION_ALPH
A_BIAS); | |
1782 gpu_get_print("GL_POST_CONVOLUTION_RED_SCALE", GL_POST_CONVOLUTION_RED_S
CALE); | |
1783 gpu_get_print("GL_POST_CONVOLUTION_GREEN_SCALE", GL_POST_CONVOLUTION_GRE
EN_SCALE); | |
1784 gpu_get_print("GL_POST_CONVOLUTION_BLUE_SCALE", GL_POST_CONVOLUTION_BLUE
_SCALE); | |
1785 gpu_get_print("GL_POST_CONVOLUTION_ALPHA_SCALE", GL_POST_CONVOLUTION_ALP
HA_SCALE); | |
1786 gpu_get_print("GL_PROJECTION_MATRIX", GL_PROJECTION_MATRIX); | |
1787 gpu_get_print("GL_PROJECTION_STACK_DEPTH", GL_PROJECTION_STACK_DEPTH); | |
1788 gpu_get_print("GL_READ_BUFFER", GL_READ_BUFFER); | |
1789 gpu_get_print("GL_RED_BIAS", GL_RED_BIAS); | |
1790 gpu_get_print("GL_RED_BITS", GL_RED_BITS); | |
1791 gpu_get_print("GL_RED_SCALE", GL_RED_SCALE); | |
1792 gpu_get_print("GL_RENDER_MODE", GL_RENDER_MODE); | |
1793 gpu_get_print("GL_RESCALE_NORMAL", GL_RESCALE_NORMAL); | |
1794 gpu_get_print("GL_RGBA_MODE", GL_RGBA_MODE); | |
1795 gpu_get_print("GL_SAMPLE_BUFFERS", GL_SAMPLE_BUFFERS); | |
1796 gpu_get_print("GL_SAMPLE_COVERAGE_VALUE", GL_SAMPLE_COVERAGE_VALUE); | |
1797 gpu_get_print("GL_SAMPLE_COVERAGE_INVERT", GL_SAMPLE_COVERAGE_INVERT); | |
1798 gpu_get_print("GL_SAMPLES", GL_SAMPLES); | |
1799 gpu_get_print("GL_SCISSOR_BOX", GL_SCISSOR_BOX); | |
1800 gpu_get_print("GL_SCISSOR_TEST", GL_SCISSOR_TEST); | |
1801 gpu_get_print("GL_SECONDARY_COLOR_ARRAY", GL_SECONDARY_COLOR_ARRAY); | |
1802 gpu_get_print("GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING", GL_SECONDARY_CO
LOR_ARRAY_BUFFER_BINDING); | |
1803 gpu_get_print("GL_SECONDARY_COLOR_ARRAY_SIZE", GL_SECONDARY_COLOR_ARRAY_
SIZE); | |
1804 gpu_get_print("GL_SECONDARY_COLOR_ARRAY_STRIDE", GL_SECONDARY_COLOR_ARRA
Y_STRIDE); | |
1805 gpu_get_print("GL_SECONDARY_COLOR_ARRAY_TYPE", GL_SECONDARY_COLOR_ARRAY_
TYPE); | |
1806 gpu_get_print("GL_SELECTION_BUFFER_SIZE", GL_SELECTION_BUFFER_SIZE); | |
1807 gpu_get_print("GL_SEPARABLE_2D", GL_SEPARABLE_2D); | |
1808 gpu_get_print("GL_SHADE_MODEL", GL_SHADE_MODEL); | |
1809 gpu_get_print("GL_SMOOTH_LINE_WIDTH_RANGE", GL_SMOOTH_LINE_WIDTH_RANGE); | |
1810 gpu_get_print("GL_SMOOTH_LINE_WIDTH_GRANULARITY", GL_SMOOTH_LINE_WIDTH_G
RANULARITY); | |
1811 gpu_get_print("GL_SMOOTH_POINT_SIZE_RANGE", GL_SMOOTH_POINT_SIZE_RANGE); | |
1812 gpu_get_print("GL_SMOOTH_POINT_SIZE_GRANULARITY", GL_SMOOTH_POINT_SIZE_G
RANULARITY); | |
1813 gpu_get_print("GL_STENCIL_BACK_FAIL", GL_STENCIL_BACK_FAIL); | |
1814 gpu_get_print("GL_STENCIL_BACK_FUNC", GL_STENCIL_BACK_FUNC); | |
1815 gpu_get_print("GL_STENCIL_BACK_PASS_DEPTH_FAIL", GL_STENCIL_BACK_PASS_DE
PTH_FAIL); | |
1816 gpu_get_print("GL_STENCIL_BACK_PASS_DEPTH_PASS", GL_STENCIL_BACK_PASS_DE
PTH_PASS); | |
1817 gpu_get_print("GL_STENCIL_BACK_REF", GL_STENCIL_BACK_REF); | |
1818 gpu_get_print("GL_STENCIL_BACK_VALUE_MASK", GL_STENCIL_BACK_VALUE_MASK); | |
1819 gpu_get_print("GL_STENCIL_BACK_WRITEMASK", GL_STENCIL_BACK_WRITEMASK); | |
1820 gpu_get_print("GL_STENCIL_BITS", GL_STENCIL_BITS); | |
1821 gpu_get_print("GL_STENCIL_CLEAR_VALUE", GL_STENCIL_CLEAR_VALUE); | |
1822 gpu_get_print("GL_STENCIL_FAIL", GL_STENCIL_FAIL); | |
1823 gpu_get_print("GL_STENCIL_FUNC", GL_STENCIL_FUNC); | |
1824 gpu_get_print("GL_STENCIL_PASS_DEPTH_FAIL", GL_STENCIL_PASS_DEPTH_FAIL); | |
1825 gpu_get_print("GL_STENCIL_PASS_DEPTH_PASS", GL_STENCIL_PASS_DEPTH_PASS); | |
1826 gpu_get_print("GL_STENCIL_REF", GL_STENCIL_REF); | |
1827 gpu_get_print("GL_STENCIL_TEST", GL_STENCIL_TEST); | |
1828 gpu_get_print("GL_STENCIL_VALUE_MASK", GL_STENCIL_VALUE_MASK); | |
1829 gpu_get_print("GL_STENCIL_WRITEMASK", GL_STENCIL_WRITEMASK); | |
1830 gpu_get_print("GL_STEREO", GL_STEREO); | |
1831 gpu_get_print("GL_SUBPIXEL_BITS", GL_SUBPIXEL_BITS); | |
1832 gpu_get_print("GL_TEXTURE_1D", GL_TEXTURE_1D); | |
1833 gpu_get_print("GL_TEXTURE_BINDING_1D", GL_TEXTURE_BINDING_1D); | |
1834 gpu_get_print("GL_TEXTURE_2D", GL_TEXTURE_2D); | |
1835 gpu_get_print("GL_TEXTURE_BINDING_2D", GL_TEXTURE_BINDING_2D); | |
1836 gpu_get_print("GL_TEXTURE_3D", GL_TEXTURE_3D); | |
1837 gpu_get_print("GL_TEXTURE_BINDING_3D", GL_TEXTURE_BINDING_3D); | |
1838 gpu_get_print("GL_TEXTURE_BINDING_CUBE_MAP", GL_TEXTURE_BINDING_CUBE_MAP
); | |
1839 gpu_get_print("GL_TEXTURE_COMPRESSION_HINT", GL_TEXTURE_COMPRESSION_HINT
); | |
1840 gpu_get_print("GL_TEXTURE_COORD_ARRAY", GL_TEXTURE_COORD_ARRAY); | |
1841 gpu_get_print("GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING", GL_TEXTURE_COORD_
ARRAY_BUFFER_BINDING); | |
1842 gpu_get_print("GL_TEXTURE_COORD_ARRAY_SIZE", GL_TEXTURE_COORD_ARRAY_SIZE
); | |
1843 gpu_get_print("GL_TEXTURE_COORD_ARRAY_STRIDE", GL_TEXTURE_COORD_ARRAY_ST
RIDE); | |
1844 gpu_get_print("GL_TEXTURE_COORD_ARRAY_TYPE", GL_TEXTURE_COORD_ARRAY_TYPE
); | |
1845 gpu_get_print("GL_TEXTURE_CUBE_MAP", GL_TEXTURE_CUBE_MAP); | |
1846 gpu_get_print("GL_TEXTURE_GEN_Q", GL_TEXTURE_GEN_Q); | |
1847 gpu_get_print("GL_TEXTURE_GEN_R", GL_TEXTURE_GEN_R); | |
1848 gpu_get_print("GL_TEXTURE_GEN_S", GL_TEXTURE_GEN_S); | |
1849 gpu_get_print("GL_TEXTURE_GEN_T", GL_TEXTURE_GEN_T); | |
1850 gpu_get_print("GL_TEXTURE_MATRIX", GL_TEXTURE_MATRIX); | |
1851 gpu_get_print("GL_TEXTURE_STACK_DEPTH", GL_TEXTURE_STACK_DEPTH); | |
1852 gpu_get_print("GL_TRANSPOSE_COLOR_MATRIX", GL_TRANSPOSE_COLOR_MATRIX); | |
1853 gpu_get_print("GL_TRANSPOSE_MODELVIEW_MATRIX", GL_TRANSPOSE_MODELVIEW_MA
TRIX); | |
1854 gpu_get_print("GL_TRANSPOSE_PROJECTION_MATRIX", GL_TRANSPOSE_PROJECTION_
MATRIX); | |
1855 gpu_get_print("GL_TRANSPOSE_TEXTURE_MATRIX", GL_TRANSPOSE_TEXTURE_MATRIX
); | |
1856 gpu_get_print("GL_UNPACK_ALIGNMENT", GL_UNPACK_ALIGNMENT); | |
1857 gpu_get_print("GL_UNPACK_IMAGE_HEIGHT", GL_UNPACK_IMAGE_HEIGHT); | |
1858 gpu_get_print("GL_UNPACK_LSB_FIRST", GL_UNPACK_LSB_FIRST); | |
1859 gpu_get_print("GL_UNPACK_ROW_LENGTH", GL_UNPACK_ROW_LENGTH); | |
1860 gpu_get_print("GL_UNPACK_SKIP_IMAGES", GL_UNPACK_SKIP_IMAGES); | |
1861 gpu_get_print("GL_UNPACK_SKIP_PIXELS", GL_UNPACK_SKIP_PIXELS); | |
1862 gpu_get_print("GL_UNPACK_SKIP_ROWS", GL_UNPACK_SKIP_ROWS); | |
1863 gpu_get_print("GL_UNPACK_SWAP_BYTES", GL_UNPACK_SWAP_BYTES); | |
1864 gpu_get_print("GL_VERTEX_ARRAY", GL_VERTEX_ARRAY); | |
1865 gpu_get_print("GL_VERTEX_ARRAY_BUFFER_BINDING", GL_VERTEX_ARRAY_BUFFER_B
INDING); | |
1866 gpu_get_print("GL_VERTEX_ARRAY_SIZE", GL_VERTEX_ARRAY_SIZE); | |
1867 gpu_get_print("GL_VERTEX_ARRAY_STRIDE", GL_VERTEX_ARRAY_STRIDE); | |
1868 gpu_get_print("GL_VERTEX_ARRAY_TYPE", GL_VERTEX_ARRAY_TYPE); | |
1869 gpu_get_print("GL_VERTEX_PROGRAM_POINT_SIZE", GL_VERTEX_PROGRAM_POINT_SI
ZE); | |
1870 gpu_get_print("GL_VERTEX_PROGRAM_TWO_SIDE", GL_VERTEX_PROGRAM_TWO_SIDE); | |
1871 gpu_get_print("GL_VIEWPORT", GL_VIEWPORT); | |
1872 gpu_get_print("GL_ZOOM_X", GL_ZOOM_X); | |
1873 gpu_get_print("GL_ZOOM_Y", GL_ZOOM_Y); | |
1874 } | |
1875 | |
LEFT | RIGHT |