Blender V2.61 - r43446

gpu_draw.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2005 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): Brecht Van Lommel.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #include <string.h>
00034 
00035 #include "GL/glew.h"
00036 
00037 #include "BLI_math.h"
00038 #include "BLI_utildefines.h"
00039 
00040 #include "DNA_lamp_types.h"
00041 #include "DNA_material_types.h"
00042 #include "DNA_meshdata_types.h"
00043 #include "DNA_modifier_types.h"
00044 #include "DNA_node_types.h"
00045 #include "DNA_object_types.h"
00046 #include "DNA_scene_types.h"
00047 #include "DNA_smoke_types.h"
00048 #include "DNA_view3d_types.h"
00049 
00050 #include "MEM_guardedalloc.h"
00051 
00052 #include "IMB_imbuf.h"
00053 #include "IMB_imbuf_types.h"
00054 
00055 #include "BKE_bmfont.h"
00056 #include "BKE_global.h"
00057 #include "BKE_image.h"
00058 #include "BKE_main.h"
00059 #include "BKE_material.h"
00060 #include "BKE_node.h"
00061 #include "BKE_object.h"
00062 #include "BKE_scene.h"
00063 #include "BKE_DerivedMesh.h"
00064 
00065 #include "BLI_threads.h"
00066 #include "BLI_blenlib.h"
00067 
00068 #include "GPU_buffers.h"
00069 #include "GPU_draw.h"
00070 #include "GPU_extensions.h"
00071 #include "GPU_material.h"
00072 
00073 #include "smoke_API.h"
00074 
00075 extern Material defmaterial; /* from material.c */
00076 
00077 /* These are some obscure rendering functions shared between the
00078  * game engine and the blender, in this module to avoid duplicaten
00079  * and abstract them away from the rest a bit */
00080 
00081 /* Text Rendering */
00082 
00083 static void gpu_mcol(unsigned int ucol)
00084 {
00085     /* mcol order is swapped */
00086     char *cp= (char *)&ucol;
00087     glColor3ub(cp[3], cp[2], cp[1]);
00088 }
00089 
00090 void GPU_render_text(MTFace *tface, int mode,
00091     const char *textstr, int textlen, unsigned int *col,
00092     float *v1, float *v2, float *v3, float *v4, int glattrib)
00093 {
00094     if ((mode & GEMAT_TEXT) && (textlen>0) && tface->tpage) {
00095         Image* ima = (Image*)tface->tpage;
00096         int index, character;
00097         float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
00098         float advance_tab;
00099         
00100         /* multiline */
00101         float line_start= 0.0f, line_height;
00102         
00103         if (v4)
00104             line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - MIN4(v1[1], v2[1], v3[1], v4[2]);
00105         else
00106             line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], v2[1], v3[1]);
00107         line_height *= 1.2f; /* could be an option? */
00108         /* end multiline */
00109 
00110         
00111         /* color has been set */
00112         if (tface->mode & TF_OBCOL)
00113             col= NULL;
00114         else if (!col)
00115             glColor3f(1.0f, 1.0f, 1.0f);
00116 
00117         glPushMatrix();
00118         
00119         /* get the tab width */
00120         matrixGlyph((ImBuf *)ima->ibufs.first, ' ', & centerx, &centery,
00121             &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
00122         
00123         advance_tab= advance * 4; /* tab width could also be an option */
00124         
00125         
00126         for (index = 0; index < textlen; index++) {
00127             float uv[4][2];
00128 
00129             // lets calculate offset stuff
00130             character = textstr[index];
00131             
00132             if (character=='\n') {
00133                 glTranslatef(line_start, -line_height, 0.0);
00134                 line_start = 0.0f;
00135                 continue;
00136             }
00137             else if (character=='\t') {
00138                 glTranslatef(advance_tab, 0.0, 0.0);
00139                 line_start -= advance_tab; /* so we can go back to the start of the line */
00140                 continue;
00141                 
00142             }
00143             
00144             // space starts at offset 1
00145             // character = character - ' ' + 1;
00146             matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, &centery,
00147                 &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
00148 
00149             uv[0][0] = (tface->uv[0][0] - centerx) * sizex + transx;
00150             uv[0][1] = (tface->uv[0][1] - centery) * sizey + transy;
00151             uv[1][0] = (tface->uv[1][0] - centerx) * sizex + transx;
00152             uv[1][1] = (tface->uv[1][1] - centery) * sizey + transy;
00153             uv[2][0] = (tface->uv[2][0] - centerx) * sizex + transx;
00154             uv[2][1] = (tface->uv[2][1] - centery) * sizey + transy;
00155             
00156             glBegin(GL_POLYGON);
00157             if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[0]);
00158             else glTexCoord2fv(uv[0]);
00159             if(col) gpu_mcol(col[0]);
00160             glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
00161             
00162             if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[1]);
00163             else glTexCoord2fv(uv[1]);
00164             if(col) gpu_mcol(col[1]);
00165             glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
00166 
00167             if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[2]);
00168             else glTexCoord2fv(uv[2]);
00169             if(col) gpu_mcol(col[2]);
00170             glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
00171 
00172             if(v4) {
00173                 uv[3][0] = (tface->uv[3][0] - centerx) * sizex + transx;
00174                 uv[3][1] = (tface->uv[3][1] - centery) * sizey + transy;
00175 
00176                 if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[3]);
00177                 else glTexCoord2fv(uv[3]);
00178                 if(col) gpu_mcol(col[3]);
00179                 glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
00180             }
00181             glEnd();
00182 
00183             glTranslatef(advance, 0.0, 0.0);
00184             line_start -= advance; /* so we can go back to the start of the line */
00185         }
00186         glPopMatrix();
00187     }
00188 }
00189 
00190 /* Checking powers of two for images since opengl 1.x requires it */
00191 
00192 static int is_pow2_limit(int num)
00193 {
00194     /* take texture clamping into account */
00195 
00196     /* XXX: texturepaint not global!
00197     if (G.f & G_TEXTUREPAINT)
00198         return 1;*/
00199 
00200     if (U.glreslimit != 0 && num > U.glreslimit)
00201         return 0;
00202 
00203     return is_power_of_2_i(num);
00204 }
00205 
00206 static int smaller_pow2_limit(int num)
00207 {
00208     /* XXX: texturepaint not global!
00209     if (G.f & G_TEXTUREPAINT)
00210         return 1;*/
00211     
00212     /* take texture clamping into account */
00213     if (U.glreslimit != 0 && num > U.glreslimit)
00214         return U.glreslimit;
00215 
00216     return power_of_2_min_i(num);
00217 }
00218 
00219 /* Current OpenGL state caching for GPU_set_tpage */
00220 
00221 static struct GPUTextureState {
00222     int curtile, tile;
00223     int curtilemode, tilemode;
00224     int curtileXRep, tileXRep;
00225     int curtileYRep, tileYRep;
00226     Image *ima, *curima;
00227 
00228     int domipmap, linearmipmap;
00229 
00230     int alphablend;
00231     float anisotropic;
00232     MTFace *lasttface;
00233 } GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, 1.f, NULL};
00234 
00235 /* Mipmap settings */
00236 
00237 void GPU_set_mipmap(int mipmap)
00238 {
00239     if (GTS.domipmap != (mipmap != 0)) {
00240         GPU_free_images();
00241         GTS.domipmap = mipmap != 0;
00242     }
00243 }
00244 
00245 void GPU_set_linear_mipmap(int linear)
00246 {
00247     if (GTS.linearmipmap != (linear != 0)) {
00248         GPU_free_images();
00249         GTS.linearmipmap = linear != 0;
00250     }
00251 }
00252 
00253 static int gpu_get_mipmap(void)
00254 {
00255     return GTS.domipmap;
00256 }
00257 
00258 static GLenum gpu_get_mipmap_filter(int mag)
00259 {
00260     /* linearmipmap is off by default *when mipmapping is off,
00261      * use unfiltered display */
00262     if(mag) {
00263         if(GTS.linearmipmap || GTS.domipmap)
00264             return GL_LINEAR;
00265         else
00266             return GL_NEAREST;
00267     }
00268     else {
00269         if(GTS.linearmipmap)
00270             return GL_LINEAR_MIPMAP_LINEAR;
00271         else if(GTS.domipmap)
00272             return GL_LINEAR_MIPMAP_NEAREST;
00273         else
00274             return GL_NEAREST;
00275     }
00276 }
00277 
00278 /* Anisotropic filtering settings */
00279 void GPU_set_anisotropic(float value)
00280 {
00281     if (GTS.anisotropic != value)
00282     {
00283         GPU_free_images();
00284 
00285         /* Clamp value to the maximum value the graphics card supports */
00286         if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
00287             value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT;
00288 
00289         GTS.anisotropic = value;
00290     }
00291 }
00292 
00293 float GPU_get_anisotropic(void)
00294 {
00295     return GTS.anisotropic;
00296 }
00297 
00298 /* Set OpenGL state for an MTFace */
00299 
00300 static void gpu_make_repbind(Image *ima)
00301 {
00302     ImBuf *ibuf;
00303     
00304     ibuf = BKE_image_get_ibuf(ima, NULL);
00305     if(ibuf==NULL)
00306         return;
00307 
00308     if(ima->repbind) {
00309         glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
00310         MEM_freeN(ima->repbind);
00311         ima->repbind= NULL;
00312         ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
00313     }
00314 
00315     ima->totbind= ima->xrep*ima->yrep;
00316 
00317     if(ima->totbind>1)
00318         ima->repbind= MEM_callocN(sizeof(int)*ima->totbind, "repbind");
00319 }
00320 
00321 static void gpu_clear_tpage(void)
00322 {
00323     if(GTS.lasttface==NULL)
00324         return;
00325     
00326     GTS.lasttface= NULL;
00327     GTS.curtile= 0;
00328     GTS.curima= NULL;
00329     if(GTS.curtilemode!=0) {
00330         glMatrixMode(GL_TEXTURE);
00331         glLoadIdentity();
00332         glMatrixMode(GL_MODELVIEW);
00333     }
00334     GTS.curtilemode= 0;
00335     GTS.curtileXRep=0;
00336     GTS.curtileYRep=0;
00337     GTS.alphablend= -1;
00338     
00339     glDisable(GL_BLEND);
00340     glDisable(GL_TEXTURE_2D);
00341     glDisable(GL_TEXTURE_GEN_S);
00342     glDisable(GL_TEXTURE_GEN_T);
00343     glDisable(GL_ALPHA_TEST);
00344 }
00345 
00346 static void gpu_set_alpha_blend(GPUBlendMode alphablend)
00347 {
00348     if(alphablend == GPU_BLEND_SOLID) {
00349         glDisable(GL_BLEND);
00350         glDisable(GL_ALPHA_TEST);
00351         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00352     }
00353     else if(alphablend==GPU_BLEND_ADD) {
00354         glEnable(GL_BLEND);
00355         glBlendFunc(GL_ONE, GL_ONE);
00356         glDisable(GL_ALPHA_TEST);
00357     }
00358     else if(ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) {
00359         glEnable(GL_BLEND);
00360         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00361         
00362         /* if U.glalphaclip == 1.0, some cards go bonkers...
00363          * turn off alpha test in this case */
00364 
00365         /* added after 2.45 to clip alpha */
00366         if(U.glalphaclip == 1.0f) {
00367             glDisable(GL_ALPHA_TEST);
00368         }
00369         else {
00370             glEnable(GL_ALPHA_TEST);
00371             glAlphaFunc(GL_GREATER, U.glalphaclip);
00372         }
00373     }
00374     else if(alphablend==GPU_BLEND_CLIP) {
00375         glDisable(GL_BLEND); 
00376         glEnable(GL_ALPHA_TEST);
00377         glAlphaFunc(GL_GREATER, 0.5f);
00378     }
00379 }
00380 
00381 static void gpu_verify_alpha_blend(int alphablend)
00382 {
00383     /* verify alpha blending modes */
00384     if(GTS.alphablend == alphablend)
00385         return;
00386 
00387     gpu_set_alpha_blend(alphablend);
00388     GTS.alphablend= alphablend;
00389 }
00390 
00391 static void gpu_verify_reflection(Image *ima)
00392 {
00393     if (ima && (ima->flag & IMA_REFLECT)) {
00394         /* enable reflection mapping */
00395         glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
00396         glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
00397 
00398         glEnable(GL_TEXTURE_GEN_S);
00399         glEnable(GL_TEXTURE_GEN_T);
00400     }
00401     else {
00402         /* disable reflection mapping */
00403         glDisable(GL_TEXTURE_GEN_S);
00404         glDisable(GL_TEXTURE_GEN_T);
00405     }
00406 }
00407 
00408 int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap)
00409 {
00410     ImBuf *ibuf = NULL;
00411     unsigned int *bind = NULL;
00412     int rectw, recth, tpx=0, tpy=0, y;
00413     unsigned int *rectrow, *tilerectrow;
00414     unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL;
00415     short texwindx, texwindy, texwinsx, texwinsy;
00416 
00417     /* initialize tile mode and number of repeats */
00418     GTS.ima = ima;
00419     GTS.tilemode= (ima && (ima->tpageflag & (IMA_TILES|IMA_TWINANIM)));
00420     GTS.tileXRep = 0;
00421     GTS.tileYRep = 0;
00422 
00423     /* setting current tile according to frame */
00424     if(ima && (ima->tpageflag & IMA_TWINANIM))
00425         GTS.tile= ima->lastframe;
00426     else
00427         GTS.tile= tftile;
00428 
00429     GTS.tile = MAX2(0, GTS.tile);
00430 
00431     if(ima) {
00432         GTS.tileXRep = ima->xrep;
00433         GTS.tileYRep = ima->yrep;
00434     }
00435 
00436     /* if same image & tile, we're done */
00437     if(compare && ima == GTS.curima && GTS.curtile == GTS.tile &&
00438        GTS.tilemode == GTS.curtilemode && GTS.curtileXRep == GTS.tileXRep &&
00439        GTS.curtileYRep == GTS.tileYRep)
00440         return (ima != NULL);
00441 
00442     /* if tiling mode or repeat changed, change texture matrix to fit */
00443     if(GTS.tilemode!=GTS.curtilemode || GTS.curtileXRep!=GTS.tileXRep ||
00444        GTS.curtileYRep != GTS.tileYRep) {
00445 
00446         glMatrixMode(GL_TEXTURE);
00447         glLoadIdentity();
00448 
00449         if(ima && (ima->tpageflag & IMA_TILES))
00450             glScalef(ima->xrep, ima->yrep, 1.0);
00451 
00452         glMatrixMode(GL_MODELVIEW);
00453     }
00454 
00455     /* check if we have a valid image */
00456     if(ima==NULL || ima->ok==0)
00457         return 0;
00458 
00459     /* check if we have a valid image buffer */
00460     ibuf= BKE_image_get_ibuf(ima, iuser);
00461 
00462     if(ibuf==NULL)
00463         return 0;
00464 
00465     /* ensure we have a char buffer and not only float */
00466     if ((ibuf->rect==NULL) && ibuf->rect_float)
00467         IMB_rect_from_float(ibuf);
00468 
00469     /* currently, tpage refresh is used by ima sequences */
00470     if(ima->tpageflag & IMA_TPAGE_REFRESH) {
00471         GPU_free_image(ima);
00472         ima->tpageflag &= ~IMA_TPAGE_REFRESH;
00473     }
00474     
00475     if(GTS.tilemode) {
00476         /* tiled mode */
00477         if(ima->repbind==NULL) gpu_make_repbind(ima);
00478         if(GTS.tile>=ima->totbind) GTS.tile= 0;
00479         
00480         /* this happens when you change repeat buttons */
00481         if(ima->repbind) bind= &ima->repbind[GTS.tile];
00482         else bind= &ima->bindcode;
00483         
00484         if(*bind==0) {
00485             
00486             texwindx= ibuf->x/ima->xrep;
00487             texwindy= ibuf->y/ima->yrep;
00488             
00489             if(GTS.tile>=ima->xrep*ima->yrep)
00490                 GTS.tile= ima->xrep*ima->yrep-1;
00491     
00492             texwinsy= GTS.tile / ima->xrep;
00493             texwinsx= GTS.tile - texwinsy*ima->xrep;
00494     
00495             texwinsx*= texwindx;
00496             texwinsy*= texwindy;
00497     
00498             tpx= texwindx;
00499             tpy= texwindy;
00500 
00501             rect= ibuf->rect + texwinsy*ibuf->x + texwinsx;
00502         }
00503     }
00504     else {
00505         /* regular image mode */
00506         bind= &ima->bindcode;
00507         
00508         if(*bind==0) {
00509             tpx= ibuf->x;
00510             tpy= ibuf->y;
00511             rect= ibuf->rect;
00512         }
00513     }
00514 
00515     if(*bind != 0) {
00516         /* enable opengl drawing with textures */
00517         glBindTexture(GL_TEXTURE_2D, *bind);
00518         return *bind;
00519     }
00520 
00521     rectw = tpx;
00522     recth = tpy;
00523 
00524     /* for tiles, copy only part of image into buffer */
00525     if (GTS.tilemode) {
00526         tilerect= MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect");
00527 
00528         for (y=0; y<recth; y++) {
00529             rectrow= &rect[y*ibuf->x];
00530             tilerectrow= &tilerect[y*rectw];
00531                 
00532             memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow));
00533         }
00534             
00535         rect= tilerect;
00536     }
00537 
00538     /* scale if not a power of two */
00539     if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) {
00540         rectw= smaller_pow2_limit(rectw);
00541         recth= smaller_pow2_limit(recth);
00542         
00543         scalerect= MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect");
00544         gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect);
00545         rect= scalerect;
00546     }
00547 
00548     /* create image */
00549     glGenTextures(1, (GLuint *)bind);
00550     glBindTexture( GL_TEXTURE_2D, *bind);
00551 
00552     if (!(gpu_get_mipmap() && mipmap)) {
00553         glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA,  rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
00554         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
00555         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
00556     }
00557     else {
00558         gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
00559         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
00560         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
00561 
00562         ima->tpageflag |= IMA_MIPMAP_COMPLETE;
00563     }
00564 
00565     if (GLEW_EXT_texture_filter_anisotropic)
00566         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
00567     /* set to modulate with vertex color */
00568     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
00569         
00570     /* clean up */
00571     if (tilerect)
00572         MEM_freeN(tilerect);
00573     if (scalerect)
00574         MEM_freeN(scalerect);
00575 
00576     return *bind;
00577 }
00578 
00579 static void gpu_verify_repeat(Image *ima)
00580 {
00581     /* set either clamp or repeat in X/Y */
00582     if (ima->tpageflag & IMA_CLAMP_U)
00583         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
00584     else
00585         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
00586 
00587     if (ima->tpageflag & IMA_CLAMP_V)
00588         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
00589     else
00590         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
00591 }
00592 
00593 int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend)
00594 {
00595     Image *ima;
00596     
00597     /* check if we need to clear the state */
00598     if(tface==NULL) {
00599         gpu_clear_tpage();
00600         return 0;
00601     }
00602 
00603     ima= tface->tpage;
00604     GTS.lasttface= tface;
00605 
00606     gpu_verify_alpha_blend(alphablend);
00607     gpu_verify_reflection(ima);
00608 
00609     if(GPU_verify_image(ima, NULL, tface->tile, 1, mipmap)) {
00610         GTS.curtile= GTS.tile;
00611         GTS.curima= GTS.ima;
00612         GTS.curtilemode= GTS.tilemode;
00613         GTS.curtileXRep = GTS.tileXRep;
00614         GTS.curtileYRep = GTS.tileYRep;
00615 
00616         glEnable(GL_TEXTURE_2D);
00617     }
00618     else {
00619         glDisable(GL_TEXTURE_2D);
00620         
00621         GTS.curtile= 0;
00622         GTS.curima= NULL;
00623         GTS.curtilemode= 0;
00624         GTS.curtileXRep = 0;
00625         GTS.curtileYRep = 0;
00626 
00627         return 0;
00628     }
00629     
00630     gpu_verify_repeat(ima);
00631     
00632     /* Did this get lost in the image recode? */
00633     /* tag_image_time(ima);*/
00634 
00635     return 1;
00636 }
00637 
00638 /* these two functions are called on entering and exiting texture paint mode,
00639    temporary disabling/enabling mipmapping on all images for quick texture
00640    updates with glTexSubImage2D. images that didn't change don't have to be
00641    re-uploaded to OpenGL */
00642 void GPU_paint_set_mipmap(int mipmap)
00643 {
00644     Image* ima;
00645     
00646     if(!GTS.domipmap)
00647         return;
00648 
00649     if(mipmap) {
00650         for(ima=G.main->image.first; ima; ima=ima->id.next) {
00651             if(ima->bindcode) {
00652                 if(ima->tpageflag & IMA_MIPMAP_COMPLETE) {
00653                     glBindTexture(GL_TEXTURE_2D, ima->bindcode);
00654                     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
00655                     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
00656                 }
00657                 else
00658                     GPU_free_image(ima);
00659             }
00660         }
00661 
00662     }
00663     else {
00664         for(ima=G.main->image.first; ima; ima=ima->id.next) {
00665             if(ima->bindcode) {
00666                 glBindTexture(GL_TEXTURE_2D, ima->bindcode);
00667                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
00668                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
00669             }
00670         }
00671     }
00672 }
00673 
00674 void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
00675 {
00676     ImBuf *ibuf;
00677     
00678     ibuf = BKE_image_get_ibuf(ima, NULL);
00679     
00680     if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !ibuf ||
00681         (!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) ||
00682         (w == 0) || (h == 0)) {
00683         /* these cases require full reload still */
00684         GPU_free_image(ima);
00685     }
00686     else {
00687         /* for the special case, we can do a partial update
00688          * which is much quicker for painting */
00689         GLint row_length, skip_pixels, skip_rows;
00690 
00691         glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length);
00692         glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels);
00693         glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows);
00694 
00695         if (ibuf->rect_float){
00696             /*This case needs a whole new buffer*/
00697             if(ibuf->rect==NULL) {
00698                 IMB_rect_from_float(ibuf);
00699             }
00700             else {
00701                 /* Do partial drawing. 'buffer' holds only the changed part. Needed for color corrected result */
00702                 float *buffer = (float *)MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf");
00703                 IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h);
00704                 glBindTexture(GL_TEXTURE_2D, ima->bindcode);
00705                 glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
00706                     GL_FLOAT, buffer);
00707                 MEM_freeN(buffer);
00708                 if(ima->tpageflag & IMA_MIPMAP_COMPLETE)
00709                     ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
00710                 return;
00711             }
00712         }
00713         
00714         glBindTexture(GL_TEXTURE_2D, ima->bindcode);
00715 
00716         glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x);
00717         glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
00718         glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
00719 
00720         glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
00721             GL_UNSIGNED_BYTE, ibuf->rect);
00722 
00723         glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
00724         glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
00725         glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
00726 
00727         if(ima->tpageflag & IMA_MIPMAP_COMPLETE)
00728             ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
00729     }
00730 }
00731 
00732 void GPU_update_images_framechange(void)
00733 {
00734     Image *ima;
00735     
00736     for(ima=G.main->image.first; ima; ima=ima->id.next) {
00737         if(ima->tpageflag & IMA_TWINANIM) {
00738             if(ima->twend >= ima->xrep*ima->yrep)
00739                 ima->twend= ima->xrep*ima->yrep-1;
00740         
00741             /* check: is bindcode not in the array? free. (to do) */
00742             
00743             ima->lastframe++;
00744             if(ima->lastframe > ima->twend)
00745                 ima->lastframe= ima->twsta;
00746         }
00747     }
00748 }
00749 
00750 int GPU_update_image_time(Image *ima, double time)
00751 {
00752     int inc = 0;
00753     float   diff;
00754     int newframe;
00755 
00756     if (!ima)
00757         return 0;
00758 
00759     if (ima->lastupdate<0)
00760         ima->lastupdate = 0;
00761 
00762     if (ima->lastupdate > (float)time)
00763         ima->lastupdate=(float)time;
00764 
00765     if(ima->tpageflag & IMA_TWINANIM) {
00766         if(ima->twend >= ima->xrep*ima->yrep) ima->twend= ima->xrep*ima->yrep-1;
00767         
00768         /* check: is the bindcode not in the array? Then free. (still to do) */
00769         
00770         diff = (float)((float)time - ima->lastupdate);
00771         inc = (int)(diff*(float)ima->animspeed);
00772 
00773         ima->lastupdate+=((float)inc/(float)ima->animspeed);
00774 
00775         newframe = ima->lastframe+inc;
00776 
00777         if(newframe > (int)ima->twend) {
00778             if(ima->twend-ima->twsta != 0)
00779                 newframe = (int)ima->twsta-1 + (newframe-ima->twend)%(ima->twend-ima->twsta);
00780             else
00781                 newframe = ima->twsta;
00782         }
00783 
00784         ima->lastframe = newframe;
00785     }
00786 
00787     return inc;
00788 }
00789 
00790 
00791 void GPU_free_smoke(SmokeModifierData *smd)
00792 {
00793     if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain)
00794     {
00795         if(smd->domain->tex)
00796             GPU_texture_free(smd->domain->tex);
00797         smd->domain->tex = NULL;
00798 
00799         if(smd->domain->tex_shadow)
00800             GPU_texture_free(smd->domain->tex_shadow);
00801         smd->domain->tex_shadow = NULL;
00802     }
00803 }
00804 
00805 void GPU_create_smoke(SmokeModifierData *smd, int highres)
00806 {
00807 #ifdef WITH_SMOKE
00808     if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && !highres)
00809         smd->domain->tex = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smoke_get_density(smd->domain->fluid));
00810     else if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && highres)
00811         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(smd->domain->wt));
00812 
00813     smd->domain->tex_shadow = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smd->domain->shadow);
00814 #else // WITH_SMOKE
00815     (void)highres;
00816     smd->domain->tex= NULL;
00817     smd->domain->tex_shadow= NULL;
00818 #endif // WITH_SMOKE
00819 }
00820 
00821 static ListBase image_free_queue = {NULL, NULL};
00822 
00823 static void gpu_queue_image_for_free(Image *ima)
00824 {
00825     Image *cpy = MEM_dupallocN(ima);
00826 
00827     BLI_lock_thread(LOCK_OPENGL);
00828     BLI_addtail(&image_free_queue, cpy);
00829     BLI_unlock_thread(LOCK_OPENGL);
00830 }
00831 
00832 void GPU_free_unused_buffers(void)
00833 {
00834     Image *ima;
00835 
00836     if(!BLI_thread_is_main())
00837         return;
00838 
00839     BLI_lock_thread(LOCK_OPENGL);
00840 
00841     /* images */
00842     for(ima=image_free_queue.first; ima; ima=ima->id.next)
00843         GPU_free_image(ima);
00844 
00845     BLI_freelistN(&image_free_queue);
00846 
00847     /* vbo buffers */
00848     /* it's probably not necessary to free all buffers every frame */
00849     /* GPU_buffer_pool_free_unused(0); */
00850 
00851     BLI_unlock_thread(LOCK_OPENGL);
00852 }
00853 
00854 void GPU_free_image(Image *ima)
00855 {
00856     if(!BLI_thread_is_main()) {
00857         gpu_queue_image_for_free(ima);
00858         return;
00859     }
00860 
00861     /* free regular image binding */
00862     if(ima->bindcode) {
00863         glDeleteTextures(1, (GLuint *)&ima->bindcode);
00864         ima->bindcode= 0;
00865         ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
00866     }
00867 
00868     /* free glsl image binding */
00869     if(ima->gputexture) {
00870         GPU_texture_free(ima->gputexture);
00871         ima->gputexture= NULL;
00872     }
00873 
00874     /* free repeated image binding */
00875     if(ima->repbind) {
00876         glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
00877     
00878         MEM_freeN(ima->repbind);
00879         ima->repbind= NULL;
00880         ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
00881     }
00882 }
00883 
00884 void GPU_free_images(void)
00885 {
00886     Image* ima;
00887 
00888     if(G.main)
00889         for(ima=G.main->image.first; ima; ima=ima->id.next)
00890             GPU_free_image(ima);
00891 }
00892 
00893 /* same as above but only free animated images */
00894 void GPU_free_images_anim(void)
00895 {
00896     Image* ima;
00897 
00898     if(G.main)
00899         for(ima=G.main->image.first; ima; ima=ima->id.next)
00900             if(ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
00901                 GPU_free_image(ima);
00902 }
00903 
00904 /* OpenGL Materials */
00905 
00906 #define FIXEDMAT    8
00907 
00908 /* OpenGL state caching for materials */
00909 
00910 typedef struct GPUMaterialFixed {
00911     float diff[4];
00912     float spec[4];
00913     int hard;
00914 } GPUMaterialFixed; 
00915 
00916 static struct GPUMaterialState {
00917     GPUMaterialFixed (*matbuf);
00918     GPUMaterialFixed matbuf_fixed[FIXEDMAT];
00919     int totmat;
00920 
00921     Material **gmatbuf;
00922     Material *gmatbuf_fixed[FIXEDMAT];
00923     Material *gboundmat;
00924     Object *gob;
00925     Scene *gscene;
00926     int glay;
00927     float (*gviewmat)[4];
00928     float (*gviewinv)[4];
00929 
00930     GPUBlendMode *alphablend;
00931     GPUBlendMode alphablend_fixed[FIXEDMAT];
00932     int use_alpha_pass, is_alpha_pass;
00933 
00934     int lastmatnr, lastretval;
00935     GPUBlendMode lastalphablend;
00936 } GMS = {NULL};
00937 
00938 /* fixed function material, alpha handed by caller */
00939 static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob, const int new_shading_nodes)
00940 {
00941     if(new_shading_nodes || bmat->mode & MA_SHLESS) {
00942         copy_v3_v3(smat->diff, &bmat->r);
00943         smat->diff[3]= 1.0;
00944 
00945         if(gamma)
00946             linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
00947 
00948         zero_v4(smat->spec);
00949         smat->hard= 0;
00950     }
00951     else {
00952         mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit);
00953         smat->diff[3]= 1.0; /* caller may set this to bmat->alpha */
00954 
00955         if(bmat->shade_flag & MA_OBCOLOR)
00956             mul_v3_v3(smat->diff, ob->col);
00957         
00958         mul_v3_v3fl(smat->spec, &bmat->specr, bmat->spec);
00959         smat->spec[3]= 1.0; /* always 1 */
00960         smat->hard= CLAMPIS(bmat->har, 0, 128);
00961 
00962         if(gamma) {
00963             linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
00964             linearrgb_to_srgb_v3_v3(smat->spec, smat->spec);
00965         }   
00966     }
00967 }
00968 
00969 static Material *gpu_active_node_material(Material *ma)
00970 {
00971     if(ma && ma->use_nodes && ma->nodetree) {
00972         bNode *node= nodeGetActiveID(ma->nodetree, ID_MA);
00973 
00974         if(node)
00975             return (Material *)node->id;
00976         else
00977             return NULL;
00978     }
00979 
00980     return ma;
00981 }
00982 
00983 void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, Object *ob, int glsl, int *do_alpha_after)
00984 {
00985     Material *ma;
00986     GPUMaterial *gpumat;
00987     GPUBlendMode alphablend;
00988     int a;
00989     int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
00990     int new_shading_nodes = scene_use_new_shading_nodes(scene);
00991     
00992     /* initialize state */
00993     memset(&GMS, 0, sizeof(GMS));
00994     GMS.lastmatnr = -1;
00995     GMS.lastretval = -1;
00996     GMS.lastalphablend = GPU_BLEND_SOLID;
00997 
00998     GMS.gob = ob;
00999     GMS.gscene = scene;
01000     GMS.totmat= ob->totcol+1; /* materials start from 1, default material is 0 */
01001     GMS.glay= v3d->lay;
01002     GMS.gviewmat= rv3d->viewmat;
01003     GMS.gviewinv= rv3d->viewinv;
01004 
01005     /* alpha pass setup. there's various cases to handle here:
01006        * object transparency on: only solid materials draw in the first pass,
01007        and only transparent in the second 'alpha' pass.
01008        * object transparency off: for glsl we draw both in a single pass, and
01009        for solid we don't use transparency at all. */
01010     GMS.use_alpha_pass = (do_alpha_after != NULL);
01011     GMS.is_alpha_pass = (v3d && v3d->transp);
01012     if(GMS.use_alpha_pass)
01013         *do_alpha_after = 0;
01014     
01015     if(GMS.totmat > FIXEDMAT) {
01016         GMS.matbuf= MEM_callocN(sizeof(GPUMaterialFixed)*GMS.totmat, "GMS.matbuf");
01017         GMS.gmatbuf= MEM_callocN(sizeof(*GMS.gmatbuf)*GMS.totmat, "GMS.matbuf");
01018         GMS.alphablend= MEM_callocN(sizeof(*GMS.alphablend)*GMS.totmat, "GMS.matbuf");
01019     }
01020     else {
01021         GMS.matbuf= GMS.matbuf_fixed;
01022         GMS.gmatbuf= GMS.gmatbuf_fixed;
01023         GMS.alphablend= GMS.alphablend_fixed;
01024     }
01025 
01026     /* no materials assigned? */
01027     if(ob->totcol==0) {
01028         gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob, new_shading_nodes);
01029 
01030         /* do material 1 too, for displists! */
01031         memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed));
01032 
01033         if(glsl) {
01034             GMS.gmatbuf[0]= &defmaterial;
01035             GPU_material_from_blender(GMS.gscene, &defmaterial);
01036         }
01037 
01038         GMS.alphablend[0]= GPU_BLEND_SOLID;
01039     }
01040     
01041     /* setup materials */
01042     for(a=1; a<=ob->totcol; a++) {
01043         /* find a suitable material */
01044         ma= give_current_material(ob, a);
01045         if(!glsl && !new_shading_nodes) ma= gpu_active_node_material(ma);
01046         if(ma==NULL) ma= &defmaterial;
01047 
01048         /* create glsl material if requested */
01049         gpumat = (glsl)? GPU_material_from_blender(GMS.gscene, ma): NULL;
01050 
01051         if(gpumat) {
01052             /* do glsl only if creating it succeed, else fallback */
01053             GMS.gmatbuf[a]= ma;
01054             alphablend = GPU_material_alpha_blend(gpumat, ob->col);
01055         }
01056         else {
01057             /* fixed function opengl materials */
01058             gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob, new_shading_nodes);
01059 
01060             if(GMS.use_alpha_pass) {
01061                 GMS.matbuf[a].diff[3]= ma->alpha;
01062                 alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;
01063             }
01064             else {
01065                 GMS.matbuf[a].diff[3]= 1.0f;
01066                 alphablend = GPU_BLEND_SOLID;
01067             }
01068         }
01069 
01070         /* setting do_alpha_after = 1 indicates this object needs to be
01071          * drawn in a second alpha pass for improved blending */
01072         if(do_alpha_after && !GMS.is_alpha_pass)
01073             if(ELEM3(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT))
01074                 *do_alpha_after= 1;
01075 
01076         GMS.alphablend[a]= alphablend;
01077     }
01078 
01079     /* let's start with a clean state */
01080     GPU_disable_material();
01081 }
01082 
01083 int GPU_enable_material(int nr, void *attribs)
01084 {
01085     GPUVertexAttribs *gattribs = attribs;
01086     GPUMaterial *gpumat;
01087     GPUBlendMode alphablend;
01088 
01089     /* no GPU_begin_object_materials, use default material */
01090     if(!GMS.matbuf) {
01091         float diff[4], spec[4];
01092 
01093         memset(&GMS, 0, sizeof(GMS));
01094 
01095         mul_v3_v3fl(diff, &defmaterial.r, defmaterial.ref + defmaterial.emit);
01096         diff[3]= 1.0;
01097 
01098         mul_v3_v3fl(spec, &defmaterial.specr, defmaterial.spec);
01099         spec[3]= 1.0;
01100 
01101         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
01102         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
01103         glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 35); /* blender default */
01104 
01105         return 0;
01106     }
01107 
01108     /* prevent index to use un-initialized array items */
01109     if(nr>=GMS.totmat)
01110         nr= 0;
01111 
01112     if(gattribs)
01113         memset(gattribs, 0, sizeof(*gattribs));
01114 
01115     /* keep current material */
01116     if(nr==GMS.lastmatnr)
01117         return GMS.lastretval;
01118 
01119     /* unbind glsl material */
01120     if(GMS.gboundmat) {
01121         if(GMS.is_alpha_pass) glDepthMask(0);
01122         GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat));
01123         GMS.gboundmat= NULL;
01124     }
01125 
01126     /* draw materials with alpha in alpha pass */
01127     GMS.lastmatnr = nr;
01128     GMS.lastretval = 1;
01129 
01130     if(GMS.use_alpha_pass) {
01131         GMS.lastretval = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP);
01132         if(GMS.is_alpha_pass)
01133             GMS.lastretval = !GMS.lastretval;
01134     }
01135     else
01136         GMS.lastretval = !GMS.is_alpha_pass;
01137 
01138     if(GMS.lastretval) {
01139         /* for alpha pass, use alpha blend */
01140         alphablend = GMS.alphablend[nr];
01141 
01142         if(gattribs && GMS.gmatbuf[nr]) {
01143             /* bind glsl material and get attributes */
01144             Material *mat = GMS.gmatbuf[nr];
01145             float auto_bump_scale;
01146 
01147             gpumat = GPU_material_from_blender(GMS.gscene, mat);
01148             GPU_material_vertex_attributes(gpumat, gattribs);
01149             GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT));
01150 
01151             auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
01152             GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, auto_bump_scale);
01153             GMS.gboundmat= mat;
01154 
01155             /* for glsl use alpha blend mode, unless it's set to solid and
01156                we are already drawing in an alpha pass */
01157             if(mat->game.alpha_blend != GPU_BLEND_SOLID)
01158                 alphablend= mat->game.alpha_blend;
01159 
01160             if(GMS.is_alpha_pass) glDepthMask(1);
01161         }
01162         else {
01163             /* or do fixed function opengl material */
01164             glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, GMS.matbuf[nr].diff);
01165             glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, GMS.matbuf[nr].spec);
01166             glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, GMS.matbuf[nr].hard);
01167         }
01168 
01169         /* set (alpha) blending mode */
01170         GPU_set_material_alpha_blend(alphablend);
01171     }
01172 
01173     return GMS.lastretval;
01174 }
01175 
01176 void GPU_set_material_alpha_blend(int alphablend)
01177 {
01178     if(GMS.lastalphablend == alphablend)
01179         return;
01180     
01181     gpu_set_alpha_blend(alphablend);
01182     GMS.lastalphablend = alphablend;
01183 }
01184 
01185 int GPU_get_material_alpha_blend(void)
01186 {
01187     return GMS.lastalphablend;
01188 }
01189 
01190 void GPU_disable_material(void)
01191 {
01192     GMS.lastmatnr= -1;
01193     GMS.lastretval= 1;
01194 
01195     if(GMS.gboundmat) {
01196         if(GMS.is_alpha_pass) glDepthMask(0);
01197         GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat));
01198         GMS.gboundmat= NULL;
01199     }
01200 
01201     GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
01202 }
01203 
01204 void GPU_end_object_materials(void)
01205 {
01206     GPU_disable_material();
01207 
01208     if(GMS.matbuf && GMS.matbuf != GMS.matbuf_fixed) {
01209         MEM_freeN(GMS.matbuf);
01210         MEM_freeN(GMS.gmatbuf);
01211         MEM_freeN(GMS.alphablend);
01212     }
01213 
01214     GMS.matbuf= NULL;
01215     GMS.gmatbuf= NULL;
01216     GMS.alphablend= NULL;
01217 
01218     /* resetting the texture matrix after the glScale needed for tiled textures */
01219     if(GTS.tilemode)
01220     {
01221         glMatrixMode(GL_TEXTURE);
01222         glLoadIdentity();
01223         glMatrixMode(GL_MODELVIEW);
01224     }
01225 }
01226 
01227 /* Lights */
01228 
01229 int GPU_default_lights(void)
01230 {
01231     float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}, position[4];
01232     int a, count = 0;
01233     
01234     /* initialize */
01235     if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) {
01236         U.light[0].flag= 1;
01237         U.light[0].vec[0]= -0.3; U.light[0].vec[1]= 0.3; U.light[0].vec[2]= 0.9;
01238         U.light[0].col[0]= 0.8; U.light[0].col[1]= 0.8; U.light[0].col[2]= 0.8;
01239         U.light[0].spec[0]= 0.5; U.light[0].spec[1]= 0.5; U.light[0].spec[2]= 0.5;
01240         U.light[0].spec[3]= 1.0;
01241         
01242         U.light[1].flag= 0;
01243         U.light[1].vec[0]= 0.5; U.light[1].vec[1]= 0.5; U.light[1].vec[2]= 0.1;
01244         U.light[1].col[0]= 0.4; U.light[1].col[1]= 0.4; U.light[1].col[2]= 0.8;
01245         U.light[1].spec[0]= 0.3; U.light[1].spec[1]= 0.3; U.light[1].spec[2]= 0.5;
01246         U.light[1].spec[3]= 1.0;
01247     
01248         U.light[2].flag= 0;
01249         U.light[2].vec[0]= 0.3; U.light[2].vec[1]= -0.3; U.light[2].vec[2]= -0.2;
01250         U.light[2].col[0]= 0.8; U.light[2].col[1]= 0.5; U.light[2].col[2]= 0.4;
01251         U.light[2].spec[0]= 0.5; U.light[2].spec[1]= 0.4; U.light[2].spec[2]= 0.3;
01252         U.light[2].spec[3]= 1.0;
01253     }
01254 
01255     glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
01256 
01257     for(a=0; a<8; a++) {
01258         if(a<3) {
01259             if(U.light[a].flag) {
01260                 glEnable(GL_LIGHT0+a);
01261 
01262                 normalize_v3_v3(position, U.light[a].vec);
01263                 position[3]= 0.0f;
01264                 
01265                 glLightfv(GL_LIGHT0+a, GL_POSITION, position); 
01266                 glLightfv(GL_LIGHT0+a, GL_DIFFUSE, U.light[a].col); 
01267                 glLightfv(GL_LIGHT0+a, GL_SPECULAR, U.light[a].spec); 
01268 
01269                 count++;
01270             }
01271             else {
01272                 glDisable(GL_LIGHT0+a);
01273 
01274                 glLightfv(GL_LIGHT0+a, GL_POSITION, zero); 
01275                 glLightfv(GL_LIGHT0+a, GL_DIFFUSE, zero); 
01276                 glLightfv(GL_LIGHT0+a, GL_SPECULAR, zero);
01277             }
01278 
01279             // clear stuff from other opengl lamp usage
01280             glLightf(GL_LIGHT0+a, GL_SPOT_CUTOFF, 180.0);
01281             glLightf(GL_LIGHT0+a, GL_CONSTANT_ATTENUATION, 1.0);
01282             glLightf(GL_LIGHT0+a, GL_LINEAR_ATTENUATION, 0.0);
01283         }
01284         else
01285             glDisable(GL_LIGHT0+a);
01286     }
01287     
01288     glDisable(GL_LIGHTING);
01289 
01290     glDisable(GL_COLOR_MATERIAL);
01291 
01292     return count;
01293 }
01294 
01295 int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4], int ortho)
01296 {
01297     Base *base;
01298     Lamp *la;
01299     int count;
01300     float position[4], direction[4], energy[4];
01301     
01302     /* disable all lights */
01303     for(count=0; count<8; count++)
01304         glDisable(GL_LIGHT0+count);
01305     
01306     /* view direction for specular is not compute correct by default in
01307      * opengl, so we set the settings ourselfs */
01308     glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (ortho)? GL_FALSE: GL_TRUE);
01309 
01310     count= 0;
01311     
01312     for(base=scene->base.first; base; base=base->next) {
01313         if(base->object->type!=OB_LAMP)
01314             continue;
01315 
01316         if(!(base->lay & lay) || !(base->lay & ob->lay))
01317             continue;
01318 
01319         la= base->object->data;
01320         
01321         /* setup lamp transform */
01322         glPushMatrix();
01323         glLoadMatrixf((float *)viewmat);
01324         
01325         where_is_object_simul(scene, base->object);
01326         
01327         if(la->type==LA_SUN) {
01328             /* sun lamp */
01329             copy_v3_v3(direction, base->object->obmat[2]);
01330             direction[3]= 0.0;
01331 
01332             glLightfv(GL_LIGHT0+count, GL_POSITION, direction); 
01333         }
01334         else {
01335             /* other lamps with attenuation */
01336             copy_v3_v3(position, base->object->obmat[3]);
01337             position[3]= 1.0f;
01338 
01339             glLightfv(GL_LIGHT0+count, GL_POSITION, position); 
01340             glLightf(GL_LIGHT0+count, GL_CONSTANT_ATTENUATION, 1.0);
01341             glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, la->att1/la->dist);
01342             glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, la->att2/(la->dist*la->dist));
01343             
01344             if(la->type==LA_SPOT) {
01345                 /* spot lamp */
01346                 negate_v3_v3(direction, base->object->obmat[2]);
01347                 glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, direction);
01348                 glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->spotsize/2.0f);
01349                 glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.0f*la->spotblend);
01350             }
01351             else
01352                 glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, 180.0);
01353         }
01354         
01355         /* setup energy */
01356         mul_v3_v3fl(energy, &la->r, la->energy);
01357         energy[3]= 1.0;
01358 
01359         glLightfv(GL_LIGHT0+count, GL_DIFFUSE, energy); 
01360         glLightfv(GL_LIGHT0+count, GL_SPECULAR, energy);
01361         glEnable(GL_LIGHT0+count);
01362         
01363         glPopMatrix();                  
01364         
01365         count++;
01366         if(count==8)
01367             break;
01368     }
01369 
01370     return count;
01371 }
01372 
01373 /* Default OpenGL State */
01374 
01375 void GPU_state_init(void)
01376 {
01377     /* also called when doing opengl rendering and in the game engine */
01378     float mat_ambient[] = { 0.0, 0.0, 0.0, 0.0 };
01379     float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 };
01380     int a, x, y;
01381     GLubyte pat[32*32];
01382     const GLubyte *patc= pat;
01383     
01384     glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
01385     glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular);
01386     glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
01387     glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 35);
01388 
01389     GPU_default_lights();
01390     
01391     glDepthFunc(GL_LEQUAL);
01392     /* scaling matrices */
01393     glEnable(GL_NORMALIZE);
01394 
01395     glShadeModel(GL_FLAT);
01396 
01397     glDisable(GL_ALPHA_TEST);
01398     glDisable(GL_BLEND);
01399     glDisable(GL_DEPTH_TEST);
01400     glDisable(GL_FOG);
01401     glDisable(GL_LIGHTING);
01402     glDisable(GL_LOGIC_OP);
01403     glDisable(GL_STENCIL_TEST);
01404     glDisable(GL_TEXTURE_1D);
01405     glDisable(GL_TEXTURE_2D);
01406 
01407     /* default disabled, enable should be local per function */
01408     glDisableClientState(GL_VERTEX_ARRAY);
01409     glDisableClientState(GL_NORMAL_ARRAY);
01410     glDisableClientState(GL_COLOR_ARRAY);
01411     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01412     
01413     glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
01414     glPixelTransferi(GL_RED_SCALE, 1);
01415     glPixelTransferi(GL_RED_BIAS, 0);
01416     glPixelTransferi(GL_GREEN_SCALE, 1);
01417     glPixelTransferi(GL_GREEN_BIAS, 0);
01418     glPixelTransferi(GL_BLUE_SCALE, 1);
01419     glPixelTransferi(GL_BLUE_BIAS, 0);
01420     glPixelTransferi(GL_ALPHA_SCALE, 1);
01421     glPixelTransferi(GL_ALPHA_BIAS, 0);
01422     
01423     glPixelTransferi(GL_DEPTH_BIAS, 0);
01424     glPixelTransferi(GL_DEPTH_SCALE, 1);
01425     glDepthRange(0.0, 1.0);
01426     
01427     a= 0;
01428     for(x=0; x<32; x++) {
01429         for(y=0; y<4; y++) {
01430             if( (x) & 1) pat[a++]= 0x88;
01431             else pat[a++]= 0x22;
01432         }
01433     }
01434     
01435     glPolygonStipple(patc);
01436 
01437     glMatrixMode(GL_TEXTURE);
01438     glLoadIdentity();
01439     glMatrixMode(GL_MODELVIEW);
01440 
01441     glFrontFace(GL_CCW);
01442     glCullFace(GL_BACK);
01443     glDisable(GL_CULL_FACE);
01444 
01445     /* calling this makes drawing very slow when AA is not set up in ghost
01446        on Linux/NVIDIA.
01447     glDisable(GL_MULTISAMPLE); */
01448 }
01449 
01450 /* debugging aid */
01451 static void gpu_get_print(const char *name, GLenum type)
01452 {
01453     float value[16];
01454     int a;
01455     
01456     memset(value, 0, sizeof(value));
01457     glGetFloatv(type, value);
01458 
01459     printf("%s: ", name);
01460     for(a=0; a<16; a++)
01461         printf("%.2f ", value[a]);
01462     printf("\n");
01463 }
01464 
01465 void GPU_state_print(void)
01466 {
01467     gpu_get_print("GL_ACCUM_ALPHA_BITS", GL_ACCUM_ALPHA_BITS);
01468     gpu_get_print("GL_ACCUM_BLUE_BITS", GL_ACCUM_BLUE_BITS);
01469     gpu_get_print("GL_ACCUM_CLEAR_VALUE", GL_ACCUM_CLEAR_VALUE);
01470     gpu_get_print("GL_ACCUM_GREEN_BITS", GL_ACCUM_GREEN_BITS);
01471     gpu_get_print("GL_ACCUM_RED_BITS", GL_ACCUM_RED_BITS);
01472     gpu_get_print("GL_ACTIVE_TEXTURE", GL_ACTIVE_TEXTURE);
01473     gpu_get_print("GL_ALIASED_POINT_SIZE_RANGE", GL_ALIASED_POINT_SIZE_RANGE);
01474     gpu_get_print("GL_ALIASED_LINE_WIDTH_RANGE", GL_ALIASED_LINE_WIDTH_RANGE);
01475     gpu_get_print("GL_ALPHA_BIAS", GL_ALPHA_BIAS);
01476     gpu_get_print("GL_ALPHA_BITS", GL_ALPHA_BITS);
01477     gpu_get_print("GL_ALPHA_SCALE", GL_ALPHA_SCALE);
01478     gpu_get_print("GL_ALPHA_TEST", GL_ALPHA_TEST);
01479     gpu_get_print("GL_ALPHA_TEST_FUNC", GL_ALPHA_TEST_FUNC);
01480     gpu_get_print("GL_ALPHA_TEST_REF", GL_ALPHA_TEST_REF);
01481     gpu_get_print("GL_ARRAY_BUFFER_BINDING", GL_ARRAY_BUFFER_BINDING);
01482     gpu_get_print("GL_ATTRIB_STACK_DEPTH", GL_ATTRIB_STACK_DEPTH);
01483     gpu_get_print("GL_AUTO_NORMAL", GL_AUTO_NORMAL);
01484     gpu_get_print("GL_AUX_BUFFERS", GL_AUX_BUFFERS);
01485     gpu_get_print("GL_BLEND", GL_BLEND);
01486     gpu_get_print("GL_BLEND_COLOR", GL_BLEND_COLOR);
01487     gpu_get_print("GL_BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA);
01488     gpu_get_print("GL_BLEND_DST_RGB", GL_BLEND_DST_RGB);
01489     gpu_get_print("GL_BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB);
01490     gpu_get_print("GL_BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA);
01491     gpu_get_print("GL_BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA);
01492     gpu_get_print("GL_BLEND_SRC_RGB", GL_BLEND_SRC_RGB);
01493     gpu_get_print("GL_BLUE_BIAS", GL_BLUE_BIAS);
01494     gpu_get_print("GL_BLUE_BITS", GL_BLUE_BITS);
01495     gpu_get_print("GL_BLUE_SCALE", GL_BLUE_SCALE);
01496     gpu_get_print("GL_CLIENT_ACTIVE_TEXTURE", GL_CLIENT_ACTIVE_TEXTURE);
01497     gpu_get_print("GL_CLIENT_ATTRIB_STACK_DEPTH", GL_CLIENT_ATTRIB_STACK_DEPTH);
01498     gpu_get_print("GL_CLIP_PLANE0", GL_CLIP_PLANE0);
01499     gpu_get_print("GL_COLOR_ARRAY", GL_COLOR_ARRAY);
01500     gpu_get_print("GL_COLOR_ARRAY_BUFFER_BINDING", GL_COLOR_ARRAY_BUFFER_BINDING);
01501     gpu_get_print("GL_COLOR_ARRAY_SIZE", GL_COLOR_ARRAY_SIZE);
01502     gpu_get_print("GL_COLOR_ARRAY_STRIDE", GL_COLOR_ARRAY_STRIDE);
01503     gpu_get_print("GL_COLOR_ARRAY_TYPE", GL_COLOR_ARRAY_TYPE);
01504     gpu_get_print("GL_COLOR_CLEAR_VALUE", GL_COLOR_CLEAR_VALUE);
01505     gpu_get_print("GL_COLOR_LOGIC_OP", GL_COLOR_LOGIC_OP);
01506     gpu_get_print("GL_COLOR_MATERIAL", GL_COLOR_MATERIAL);
01507     gpu_get_print("GL_COLOR_MATERIAL_FACE", GL_COLOR_MATERIAL_FACE);
01508     gpu_get_print("GL_COLOR_MATERIAL_PARAMETER", GL_COLOR_MATERIAL_PARAMETER);
01509     gpu_get_print("GL_COLOR_MATRIX", GL_COLOR_MATRIX);
01510     gpu_get_print("GL_COLOR_MATRIX_STACK_DEPTH", GL_COLOR_MATRIX_STACK_DEPTH);
01511     gpu_get_print("GL_COLOR_SUM", GL_COLOR_SUM);
01512     gpu_get_print("GL_COLOR_TABLE", GL_COLOR_TABLE);
01513     gpu_get_print("GL_COLOR_WRITEMASK", GL_COLOR_WRITEMASK);
01514     gpu_get_print("GL_COMPRESSED_TEXTURE_FORMATS", GL_COMPRESSED_TEXTURE_FORMATS);
01515     gpu_get_print("GL_CONVOLUTION_1D", GL_CONVOLUTION_1D);
01516     gpu_get_print("GL_CONVOLUTION_2D", GL_CONVOLUTION_2D);
01517     gpu_get_print("GL_CULL_FACE", GL_CULL_FACE);
01518     gpu_get_print("GL_CULL_FACE_MODE", GL_CULL_FACE_MODE);
01519     gpu_get_print("GL_CURRENT_COLOR", GL_CURRENT_COLOR);
01520     gpu_get_print("GL_CURRENT_FOG_COORD", GL_CURRENT_FOG_COORD);
01521     gpu_get_print("GL_CURRENT_INDEX", GL_CURRENT_INDEX);
01522     gpu_get_print("GL_CURRENT_NORMAL", GL_CURRENT_NORMAL);
01523     gpu_get_print("GL_CURRENT_PROGRAM", GL_CURRENT_PROGRAM);
01524     gpu_get_print("GL_CURRENT_RASTER_COLOR", GL_CURRENT_RASTER_COLOR);
01525     gpu_get_print("GL_CURRENT_RASTER_DISTANCE", GL_CURRENT_RASTER_DISTANCE);
01526     gpu_get_print("GL_CURRENT_RASTER_INDEX", GL_CURRENT_RASTER_INDEX);
01527     gpu_get_print("GL_CURRENT_RASTER_POSITION", GL_CURRENT_RASTER_POSITION);
01528     gpu_get_print("GL_CURRENT_RASTER_POSITION_VALID", GL_CURRENT_RASTER_POSITION_VALID);
01529     gpu_get_print("GL_CURRENT_RASTER_SECONDARY_COLOR", GL_CURRENT_RASTER_SECONDARY_COLOR);
01530     gpu_get_print("GL_CURRENT_RASTER_TEXTURE_COORDS", GL_CURRENT_RASTER_TEXTURE_COORDS);
01531     gpu_get_print("GL_CURRENT_SECONDARY_COLOR", GL_CURRENT_SECONDARY_COLOR);
01532     gpu_get_print("GL_CURRENT_TEXTURE_COORDS", GL_CURRENT_TEXTURE_COORDS);
01533     gpu_get_print("GL_DEPTH_BIAS", GL_DEPTH_BIAS);
01534     gpu_get_print("GL_DEPTH_BITS", GL_DEPTH_BITS);
01535     gpu_get_print("GL_DEPTH_CLEAR_VALUE", GL_DEPTH_CLEAR_VALUE);
01536     gpu_get_print("GL_DEPTH_FUNC", GL_DEPTH_FUNC);
01537     gpu_get_print("GL_DEPTH_RANGE", GL_DEPTH_RANGE);
01538     gpu_get_print("GL_DEPTH_SCALE", GL_DEPTH_SCALE);
01539     gpu_get_print("GL_DEPTH_TEST", GL_DEPTH_TEST);
01540     gpu_get_print("GL_DEPTH_WRITEMASK", GL_DEPTH_WRITEMASK);
01541     gpu_get_print("GL_DITHER", GL_DITHER);
01542     gpu_get_print("GL_DOUBLEBUFFER", GL_DOUBLEBUFFER);
01543     gpu_get_print("GL_DRAW_BUFFER", GL_DRAW_BUFFER);
01544     gpu_get_print("GL_DRAW_BUFFER0", GL_DRAW_BUFFER0);
01545     gpu_get_print("GL_EDGE_FLAG", GL_EDGE_FLAG);
01546     gpu_get_print("GL_EDGE_FLAG_ARRAY", GL_EDGE_FLAG_ARRAY);
01547     gpu_get_print("GL_EDGE_FLAG_ARRAY_BUFFER_BINDING", GL_EDGE_FLAG_ARRAY_BUFFER_BINDING);
01548     gpu_get_print("GL_EDGE_FLAG_ARRAY_STRIDE", GL_EDGE_FLAG_ARRAY_STRIDE);
01549     gpu_get_print("GL_ELEMENT_ARRAY_BUFFER_BINDING", GL_ELEMENT_ARRAY_BUFFER_BINDING);
01550     gpu_get_print("GL_FEEDBACK_BUFFER_SIZE", GL_FEEDBACK_BUFFER_SIZE);
01551     gpu_get_print("GL_FEEDBACK_BUFFER_TYPE", GL_FEEDBACK_BUFFER_TYPE);
01552     gpu_get_print("GL_FOG", GL_FOG);
01553     gpu_get_print("GL_FOG_COORD_ARRAY", GL_FOG_COORD_ARRAY);
01554     gpu_get_print("GL_FOG_COORD_ARRAY_BUFFER_BINDING", GL_FOG_COORD_ARRAY_BUFFER_BINDING);
01555     gpu_get_print("GL_FOG_COORD_ARRAY_STRIDE", GL_FOG_COORD_ARRAY_STRIDE);
01556     gpu_get_print("GL_FOG_COORD_ARRAY_TYPE", GL_FOG_COORD_ARRAY_TYPE);
01557     gpu_get_print("GL_FOG_COORD_SRC", GL_FOG_COORD_SRC);
01558     gpu_get_print("GL_FOG_COLOR", GL_FOG_COLOR);
01559     gpu_get_print("GL_FOG_DENSITY", GL_FOG_DENSITY);
01560     gpu_get_print("GL_FOG_END", GL_FOG_END);
01561     gpu_get_print("GL_FOG_HINT", GL_FOG_HINT);
01562     gpu_get_print("GL_FOG_INDEX", GL_FOG_INDEX);
01563     gpu_get_print("GL_FOG_MODE", GL_FOG_MODE);
01564     gpu_get_print("GL_FOG_START", GL_FOG_START);
01565     gpu_get_print("GL_FRAGMENT_SHADER_DERIVATIVE_HINT", GL_FRAGMENT_SHADER_DERIVATIVE_HINT);
01566     gpu_get_print("GL_FRONT_FACE", GL_FRONT_FACE);
01567     gpu_get_print("GL_GENERATE_MIPMAP_HINT", GL_GENERATE_MIPMAP_HINT);
01568     gpu_get_print("GL_GREEN_BIAS", GL_GREEN_BIAS);
01569     gpu_get_print("GL_GREEN_BITS", GL_GREEN_BITS);
01570     gpu_get_print("GL_GREEN_SCALE", GL_GREEN_SCALE);
01571     gpu_get_print("GL_HISTOGRAM", GL_HISTOGRAM);
01572     gpu_get_print("GL_INDEX_ARRAY", GL_INDEX_ARRAY);
01573     gpu_get_print("GL_INDEX_ARRAY_BUFFER_BINDING", GL_INDEX_ARRAY_BUFFER_BINDING);
01574     gpu_get_print("GL_INDEX_ARRAY_STRIDE", GL_INDEX_ARRAY_STRIDE);
01575     gpu_get_print("GL_INDEX_ARRAY_TYPE", GL_INDEX_ARRAY_TYPE);
01576     gpu_get_print("GL_INDEX_BITS", GL_INDEX_BITS);
01577     gpu_get_print("GL_INDEX_CLEAR_VALUE", GL_INDEX_CLEAR_VALUE);
01578     gpu_get_print("GL_INDEX_LOGIC_OP", GL_INDEX_LOGIC_OP);
01579     gpu_get_print("GL_INDEX_MODE", GL_INDEX_MODE);
01580     gpu_get_print("GL_INDEX_OFFSET", GL_INDEX_OFFSET);
01581     gpu_get_print("GL_INDEX_SHIFT", GL_INDEX_SHIFT);
01582     gpu_get_print("GL_INDEX_WRITEMASK", GL_INDEX_WRITEMASK);
01583     gpu_get_print("GL_LIGHT0", GL_LIGHT0);
01584     gpu_get_print("GL_LIGHTING", GL_LIGHTING);
01585     gpu_get_print("GL_LIGHT_MODEL_AMBIENT", GL_LIGHT_MODEL_AMBIENT);
01586     gpu_get_print("GL_LIGHT_MODEL_COLOR_CONTROL", GL_LIGHT_MODEL_COLOR_CONTROL);
01587     gpu_get_print("GL_LIGHT_MODEL_LOCAL_VIEWER", GL_LIGHT_MODEL_LOCAL_VIEWER);
01588     gpu_get_print("GL_LIGHT_MODEL_TWO_SIDE", GL_LIGHT_MODEL_TWO_SIDE);
01589     gpu_get_print("GL_LINE_SMOOTH", GL_LINE_SMOOTH);
01590     gpu_get_print("GL_LINE_SMOOTH_HINT", GL_LINE_SMOOTH_HINT);
01591     gpu_get_print("GL_LINE_STIPPLE", GL_LINE_STIPPLE);
01592     gpu_get_print("GL_LINE_STIPPLE_PATTERN", GL_LINE_STIPPLE_PATTERN);
01593     gpu_get_print("GL_LINE_STIPPLE_REPEAT", GL_LINE_STIPPLE_REPEAT);
01594     gpu_get_print("GL_LINE_WIDTH", GL_LINE_WIDTH);
01595     gpu_get_print("GL_LINE_WIDTH_GRANULARITY", GL_LINE_WIDTH_GRANULARITY);
01596     gpu_get_print("GL_LINE_WIDTH_RANGE", GL_LINE_WIDTH_RANGE);
01597     gpu_get_print("GL_LIST_BASE", GL_LIST_BASE);
01598     gpu_get_print("GL_LIST_INDEX", GL_LIST_INDEX);
01599     gpu_get_print("GL_LIST_MODE", GL_LIST_MODE);
01600     gpu_get_print("GL_LOGIC_OP_MODE", GL_LOGIC_OP_MODE);
01601     gpu_get_print("GL_MAP1_COLOR_4", GL_MAP1_COLOR_4);
01602     gpu_get_print("GL_MAP1_GRID_DOMAIN", GL_MAP1_GRID_DOMAIN);
01603     gpu_get_print("GL_MAP1_GRID_SEGMENTS", GL_MAP1_GRID_SEGMENTS);
01604     gpu_get_print("GL_MAP1_INDEX", GL_MAP1_INDEX);
01605     gpu_get_print("GL_MAP1_NORMAL", GL_MAP1_NORMAL);
01606     gpu_get_print("GL_MAP1_TEXTURE_COORD_1", GL_MAP1_TEXTURE_COORD_1);
01607     gpu_get_print("GL_MAP1_TEXTURE_COORD_2", GL_MAP1_TEXTURE_COORD_2);
01608     gpu_get_print("GL_MAP1_TEXTURE_COORD_3", GL_MAP1_TEXTURE_COORD_3);
01609     gpu_get_print("GL_MAP1_TEXTURE_COORD_4", GL_MAP1_TEXTURE_COORD_4);
01610     gpu_get_print("GL_MAP1_VERTEX_3", GL_MAP1_VERTEX_3);
01611     gpu_get_print("GL_MAP1_VERTEX_4", GL_MAP1_VERTEX_4);
01612     gpu_get_print("GL_MAP2_COLOR_4", GL_MAP2_COLOR_4);
01613     gpu_get_print("GL_MAP2_GRID_DOMAIN", GL_MAP2_GRID_DOMAIN);
01614     gpu_get_print("GL_MAP2_GRID_SEGMENTS", GL_MAP2_GRID_SEGMENTS);
01615     gpu_get_print("GL_MAP2_INDEX", GL_MAP2_INDEX);
01616     gpu_get_print("GL_MAP2_NORMAL", GL_MAP2_NORMAL);
01617     gpu_get_print("GL_MAP2_TEXTURE_COORD_1", GL_MAP2_TEXTURE_COORD_1);
01618     gpu_get_print("GL_MAP2_TEXTURE_COORD_2", GL_MAP2_TEXTURE_COORD_2);
01619     gpu_get_print("GL_MAP2_TEXTURE_COORD_3", GL_MAP2_TEXTURE_COORD_3);
01620     gpu_get_print("GL_MAP2_TEXTURE_COORD_4", GL_MAP2_TEXTURE_COORD_4);
01621     gpu_get_print("GL_MAP2_VERTEX_3", GL_MAP2_VERTEX_3);
01622     gpu_get_print("GL_MAP2_VERTEX_4", GL_MAP2_VERTEX_4);
01623     gpu_get_print("GL_MAP_COLOR", GL_MAP_COLOR);
01624     gpu_get_print("GL_MAP_STENCIL", GL_MAP_STENCIL);
01625     gpu_get_print("GL_MATRIX_MODE", GL_MATRIX_MODE);
01626     gpu_get_print("GL_MAX_3D_TEXTURE_SIZE", GL_MAX_3D_TEXTURE_SIZE);
01627     gpu_get_print("GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GL_MAX_CLIENT_ATTRIB_STACK_DEPTH);
01628     gpu_get_print("GL_MAX_ATTRIB_STACK_DEPTH", GL_MAX_ATTRIB_STACK_DEPTH);
01629     gpu_get_print("GL_MAX_CLIP_PLANES", GL_MAX_CLIP_PLANES);
01630     gpu_get_print("GL_MAX_COLOR_MATRIX_STACK_DEPTH", GL_MAX_COLOR_MATRIX_STACK_DEPTH);
01631     gpu_get_print("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
01632     gpu_get_print("GL_MAX_CUBE_MAP_TEXTURE_SIZE", GL_MAX_CUBE_MAP_TEXTURE_SIZE);
01633     gpu_get_print("GL_MAX_DRAW_BUFFERS", GL_MAX_DRAW_BUFFERS);
01634     gpu_get_print("GL_MAX_ELEMENTS_INDICES", GL_MAX_ELEMENTS_INDICES);
01635     gpu_get_print("GL_MAX_ELEMENTS_VERTICES", GL_MAX_ELEMENTS_VERTICES);
01636     gpu_get_print("GL_MAX_EVAL_ORDER", GL_MAX_EVAL_ORDER);
01637     gpu_get_print("GL_MAX_FRAGMENT_UNIFORM_COMPONENTS", GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
01638     gpu_get_print("GL_MAX_LIGHTS", GL_MAX_LIGHTS);
01639     gpu_get_print("GL_MAX_LIST_NESTING", GL_MAX_LIST_NESTING);
01640     gpu_get_print("GL_MAX_MODELVIEW_STACK_DEPTH", GL_MAX_MODELVIEW_STACK_DEPTH);
01641     gpu_get_print("GL_MAX_NAME_STACK_DEPTH", GL_MAX_NAME_STACK_DEPTH);
01642     gpu_get_print("GL_MAX_PIXEL_MAP_TABLE", GL_MAX_PIXEL_MAP_TABLE);
01643     gpu_get_print("GL_MAX_PROJECTION_STACK_DEPTH", GL_MAX_PROJECTION_STACK_DEPTH);
01644     gpu_get_print("GL_MAX_TEXTURE_COORDS", GL_MAX_TEXTURE_COORDS);
01645     gpu_get_print("GL_MAX_TEXTURE_IMAGE_UNITS", GL_MAX_TEXTURE_IMAGE_UNITS);
01646     gpu_get_print("GL_MAX_TEXTURE_LOD_BIAS", GL_MAX_TEXTURE_LOD_BIAS);
01647     gpu_get_print("GL_MAX_TEXTURE_SIZE", GL_MAX_TEXTURE_SIZE);
01648     gpu_get_print("GL_MAX_TEXTURE_STACK_DEPTH", GL_MAX_TEXTURE_STACK_DEPTH);
01649     gpu_get_print("GL_MAX_TEXTURE_UNITS", GL_MAX_TEXTURE_UNITS);
01650     gpu_get_print("GL_MAX_VARYING_FLOATS", GL_MAX_VARYING_FLOATS);
01651     gpu_get_print("GL_MAX_VERTEX_ATTRIBS", GL_MAX_VERTEX_ATTRIBS);
01652     gpu_get_print("GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
01653     gpu_get_print("GL_MAX_VERTEX_UNIFORM_COMPONENTS", GL_MAX_VERTEX_UNIFORM_COMPONENTS);
01654     gpu_get_print("GL_MAX_VIEWPORT_DIMS", GL_MAX_VIEWPORT_DIMS);
01655     gpu_get_print("GL_MINMAX", GL_MINMAX);
01656     gpu_get_print("GL_MODELVIEW_MATRIX", GL_MODELVIEW_MATRIX);
01657     gpu_get_print("GL_MODELVIEW_STACK_DEPTH", GL_MODELVIEW_STACK_DEPTH);
01658     gpu_get_print("GL_NAME_STACK_DEPTH", GL_NAME_STACK_DEPTH);
01659     gpu_get_print("GL_NORMAL_ARRAY", GL_NORMAL_ARRAY);
01660     gpu_get_print("GL_NORMAL_ARRAY_BUFFER_BINDING", GL_NORMAL_ARRAY_BUFFER_BINDING);
01661     gpu_get_print("GL_NORMAL_ARRAY_STRIDE", GL_NORMAL_ARRAY_STRIDE);
01662     gpu_get_print("GL_NORMAL_ARRAY_TYPE", GL_NORMAL_ARRAY_TYPE);
01663     gpu_get_print("GL_NORMALIZE", GL_NORMALIZE);
01664     gpu_get_print("GL_NUM_COMPRESSED_TEXTURE_FORMATS", GL_NUM_COMPRESSED_TEXTURE_FORMATS);
01665     gpu_get_print("GL_PACK_ALIGNMENT", GL_PACK_ALIGNMENT);
01666     gpu_get_print("GL_PACK_IMAGE_HEIGHT", GL_PACK_IMAGE_HEIGHT);
01667     gpu_get_print("GL_PACK_LSB_FIRST", GL_PACK_LSB_FIRST);
01668     gpu_get_print("GL_PACK_ROW_LENGTH", GL_PACK_ROW_LENGTH);
01669     gpu_get_print("GL_PACK_SKIP_IMAGES", GL_PACK_SKIP_IMAGES);
01670     gpu_get_print("GL_PACK_SKIP_PIXELS", GL_PACK_SKIP_PIXELS);
01671     gpu_get_print("GL_PACK_SKIP_ROWS", GL_PACK_SKIP_ROWS);
01672     gpu_get_print("GL_PACK_SWAP_BYTES", GL_PACK_SWAP_BYTES);
01673     gpu_get_print("GL_PERSPECTIVE_CORRECTION_HINT", GL_PERSPECTIVE_CORRECTION_HINT);
01674     gpu_get_print("GL_PIXEL_MAP_A_TO_A_SIZE", GL_PIXEL_MAP_A_TO_A_SIZE);
01675     gpu_get_print("GL_PIXEL_MAP_B_TO_B_SIZE", GL_PIXEL_MAP_B_TO_B_SIZE);
01676     gpu_get_print("GL_PIXEL_MAP_G_TO_G_SIZE", GL_PIXEL_MAP_G_TO_G_SIZE);
01677     gpu_get_print("GL_PIXEL_MAP_I_TO_A_SIZE", GL_PIXEL_MAP_I_TO_A_SIZE);
01678     gpu_get_print("GL_PIXEL_MAP_I_TO_B_SIZE", GL_PIXEL_MAP_I_TO_B_SIZE);
01679     gpu_get_print("GL_PIXEL_MAP_I_TO_G_SIZE", GL_PIXEL_MAP_I_TO_G_SIZE);
01680     gpu_get_print("GL_PIXEL_MAP_I_TO_I_SIZE", GL_PIXEL_MAP_I_TO_I_SIZE);
01681     gpu_get_print("GL_PIXEL_MAP_I_TO_R_SIZE", GL_PIXEL_MAP_I_TO_R_SIZE);
01682     gpu_get_print("GL_PIXEL_MAP_R_TO_R_SIZE", GL_PIXEL_MAP_R_TO_R_SIZE);
01683     gpu_get_print("GL_PIXEL_MAP_S_TO_S_SIZE", GL_PIXEL_MAP_S_TO_S_SIZE);
01684     gpu_get_print("GL_PIXEL_PACK_BUFFER_BINDING", GL_PIXEL_PACK_BUFFER_BINDING);
01685     gpu_get_print("GL_PIXEL_UNPACK_BUFFER_BINDING", GL_PIXEL_UNPACK_BUFFER_BINDING);
01686     gpu_get_print("GL_POINT_DISTANCE_ATTENUATION", GL_POINT_DISTANCE_ATTENUATION);
01687     gpu_get_print("GL_POINT_FADE_THRESHOLD_SIZE", GL_POINT_FADE_THRESHOLD_SIZE);
01688     gpu_get_print("GL_POINT_SIZE", GL_POINT_SIZE);
01689     gpu_get_print("GL_POINT_SIZE_GRANULARITY", GL_POINT_SIZE_GRANULARITY);
01690     gpu_get_print("GL_POINT_SIZE_MAX", GL_POINT_SIZE_MAX);
01691     gpu_get_print("GL_POINT_SIZE_MIN", GL_POINT_SIZE_MIN);
01692     gpu_get_print("GL_POINT_SIZE_RANGE", GL_POINT_SIZE_RANGE);
01693     gpu_get_print("GL_POINT_SMOOTH", GL_POINT_SMOOTH);
01694     gpu_get_print("GL_POINT_SMOOTH_HINT", GL_POINT_SMOOTH_HINT);
01695     gpu_get_print("GL_POINT_SPRITE", GL_POINT_SPRITE);
01696     gpu_get_print("GL_POLYGON_MODE", GL_POLYGON_MODE);
01697     gpu_get_print("GL_POLYGON_OFFSET_FACTOR", GL_POLYGON_OFFSET_FACTOR);
01698     gpu_get_print("GL_POLYGON_OFFSET_UNITS", GL_POLYGON_OFFSET_UNITS);
01699     gpu_get_print("GL_POLYGON_OFFSET_FILL", GL_POLYGON_OFFSET_FILL);
01700     gpu_get_print("GL_POLYGON_OFFSET_LINE", GL_POLYGON_OFFSET_LINE);
01701     gpu_get_print("GL_POLYGON_OFFSET_POINT", GL_POLYGON_OFFSET_POINT);
01702     gpu_get_print("GL_POLYGON_SMOOTH", GL_POLYGON_SMOOTH);
01703     gpu_get_print("GL_POLYGON_SMOOTH_HINT", GL_POLYGON_SMOOTH_HINT);
01704     gpu_get_print("GL_POLYGON_STIPPLE", GL_POLYGON_STIPPLE);
01705     gpu_get_print("GL_POST_COLOR_MATRIX_COLOR_TABLE", GL_POST_COLOR_MATRIX_COLOR_TABLE);
01706     gpu_get_print("GL_POST_COLOR_MATRIX_RED_BIAS", GL_POST_COLOR_MATRIX_RED_BIAS);
01707     gpu_get_print("GL_POST_COLOR_MATRIX_GREEN_BIAS", GL_POST_COLOR_MATRIX_GREEN_BIAS);
01708     gpu_get_print("GL_POST_COLOR_MATRIX_BLUE_BIAS", GL_POST_COLOR_MATRIX_BLUE_BIAS);
01709     gpu_get_print("GL_POST_COLOR_MATRIX_ALPHA_BIAS", GL_POST_COLOR_MATRIX_ALPHA_BIAS);
01710     gpu_get_print("GL_POST_COLOR_MATRIX_RED_SCALE", GL_POST_COLOR_MATRIX_RED_SCALE);
01711     gpu_get_print("GL_POST_COLOR_MATRIX_GREEN_SCALE", GL_POST_COLOR_MATRIX_GREEN_SCALE);
01712     gpu_get_print("GL_POST_COLOR_MATRIX_BLUE_SCALE", GL_POST_COLOR_MATRIX_BLUE_SCALE);
01713     gpu_get_print("GL_POST_COLOR_MATRIX_ALPHA_SCALE", GL_POST_COLOR_MATRIX_ALPHA_SCALE);
01714     gpu_get_print("GL_POST_CONVOLUTION_COLOR_TABLE", GL_POST_CONVOLUTION_COLOR_TABLE);
01715     gpu_get_print("GL_POST_CONVOLUTION_RED_BIAS", GL_POST_CONVOLUTION_RED_BIAS);
01716     gpu_get_print("GL_POST_CONVOLUTION_GREEN_BIAS", GL_POST_CONVOLUTION_GREEN_BIAS);
01717     gpu_get_print("GL_POST_CONVOLUTION_BLUE_BIAS", GL_POST_CONVOLUTION_BLUE_BIAS);
01718     gpu_get_print("GL_POST_CONVOLUTION_ALPHA_BIAS", GL_POST_CONVOLUTION_ALPHA_BIAS);
01719     gpu_get_print("GL_POST_CONVOLUTION_RED_SCALE", GL_POST_CONVOLUTION_RED_SCALE);
01720     gpu_get_print("GL_POST_CONVOLUTION_GREEN_SCALE", GL_POST_CONVOLUTION_GREEN_SCALE);
01721     gpu_get_print("GL_POST_CONVOLUTION_BLUE_SCALE", GL_POST_CONVOLUTION_BLUE_SCALE);
01722     gpu_get_print("GL_POST_CONVOLUTION_ALPHA_SCALE", GL_POST_CONVOLUTION_ALPHA_SCALE);
01723     gpu_get_print("GL_PROJECTION_MATRIX", GL_PROJECTION_MATRIX);
01724     gpu_get_print("GL_PROJECTION_STACK_DEPTH", GL_PROJECTION_STACK_DEPTH);
01725     gpu_get_print("GL_READ_BUFFER", GL_READ_BUFFER);
01726     gpu_get_print("GL_RED_BIAS", GL_RED_BIAS);
01727     gpu_get_print("GL_RED_BITS", GL_RED_BITS);
01728     gpu_get_print("GL_RED_SCALE", GL_RED_SCALE);
01729     gpu_get_print("GL_RENDER_MODE", GL_RENDER_MODE);
01730     gpu_get_print("GL_RESCALE_NORMAL", GL_RESCALE_NORMAL);
01731     gpu_get_print("GL_RGBA_MODE", GL_RGBA_MODE);
01732     gpu_get_print("GL_SAMPLE_BUFFERS", GL_SAMPLE_BUFFERS);
01733     gpu_get_print("GL_SAMPLE_COVERAGE_VALUE", GL_SAMPLE_COVERAGE_VALUE);
01734     gpu_get_print("GL_SAMPLE_COVERAGE_INVERT", GL_SAMPLE_COVERAGE_INVERT);
01735     gpu_get_print("GL_SAMPLES", GL_SAMPLES);
01736     gpu_get_print("GL_SCISSOR_BOX", GL_SCISSOR_BOX);
01737     gpu_get_print("GL_SCISSOR_TEST", GL_SCISSOR_TEST);
01738     gpu_get_print("GL_SECONDARY_COLOR_ARRAY", GL_SECONDARY_COLOR_ARRAY);
01739     gpu_get_print("GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING", GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING);
01740     gpu_get_print("GL_SECONDARY_COLOR_ARRAY_SIZE", GL_SECONDARY_COLOR_ARRAY_SIZE);
01741     gpu_get_print("GL_SECONDARY_COLOR_ARRAY_STRIDE", GL_SECONDARY_COLOR_ARRAY_STRIDE);
01742     gpu_get_print("GL_SECONDARY_COLOR_ARRAY_TYPE", GL_SECONDARY_COLOR_ARRAY_TYPE);
01743     gpu_get_print("GL_SELECTION_BUFFER_SIZE", GL_SELECTION_BUFFER_SIZE);
01744     gpu_get_print("GL_SEPARABLE_2D", GL_SEPARABLE_2D);
01745     gpu_get_print("GL_SHADE_MODEL", GL_SHADE_MODEL);
01746     gpu_get_print("GL_SMOOTH_LINE_WIDTH_RANGE", GL_SMOOTH_LINE_WIDTH_RANGE);
01747     gpu_get_print("GL_SMOOTH_LINE_WIDTH_GRANULARITY", GL_SMOOTH_LINE_WIDTH_GRANULARITY);
01748     gpu_get_print("GL_SMOOTH_POINT_SIZE_RANGE", GL_SMOOTH_POINT_SIZE_RANGE);
01749     gpu_get_print("GL_SMOOTH_POINT_SIZE_GRANULARITY", GL_SMOOTH_POINT_SIZE_GRANULARITY);
01750     gpu_get_print("GL_STENCIL_BACK_FAIL", GL_STENCIL_BACK_FAIL);
01751     gpu_get_print("GL_STENCIL_BACK_FUNC", GL_STENCIL_BACK_FUNC);
01752     gpu_get_print("GL_STENCIL_BACK_PASS_DEPTH_FAIL", GL_STENCIL_BACK_PASS_DEPTH_FAIL);
01753     gpu_get_print("GL_STENCIL_BACK_PASS_DEPTH_PASS", GL_STENCIL_BACK_PASS_DEPTH_PASS);
01754     gpu_get_print("GL_STENCIL_BACK_REF", GL_STENCIL_BACK_REF);
01755     gpu_get_print("GL_STENCIL_BACK_VALUE_MASK", GL_STENCIL_BACK_VALUE_MASK);
01756     gpu_get_print("GL_STENCIL_BACK_WRITEMASK", GL_STENCIL_BACK_WRITEMASK);
01757     gpu_get_print("GL_STENCIL_BITS", GL_STENCIL_BITS);
01758     gpu_get_print("GL_STENCIL_CLEAR_VALUE", GL_STENCIL_CLEAR_VALUE);
01759     gpu_get_print("GL_STENCIL_FAIL", GL_STENCIL_FAIL);
01760     gpu_get_print("GL_STENCIL_FUNC", GL_STENCIL_FUNC);
01761     gpu_get_print("GL_STENCIL_PASS_DEPTH_FAIL", GL_STENCIL_PASS_DEPTH_FAIL);
01762     gpu_get_print("GL_STENCIL_PASS_DEPTH_PASS", GL_STENCIL_PASS_DEPTH_PASS);
01763     gpu_get_print("GL_STENCIL_REF", GL_STENCIL_REF);
01764     gpu_get_print("GL_STENCIL_TEST", GL_STENCIL_TEST);
01765     gpu_get_print("GL_STENCIL_VALUE_MASK", GL_STENCIL_VALUE_MASK);
01766     gpu_get_print("GL_STENCIL_WRITEMASK", GL_STENCIL_WRITEMASK);
01767     gpu_get_print("GL_STEREO", GL_STEREO);
01768     gpu_get_print("GL_SUBPIXEL_BITS", GL_SUBPIXEL_BITS);
01769     gpu_get_print("GL_TEXTURE_1D", GL_TEXTURE_1D);
01770     gpu_get_print("GL_TEXTURE_BINDING_1D", GL_TEXTURE_BINDING_1D);
01771     gpu_get_print("GL_TEXTURE_2D", GL_TEXTURE_2D);
01772     gpu_get_print("GL_TEXTURE_BINDING_2D", GL_TEXTURE_BINDING_2D);
01773     gpu_get_print("GL_TEXTURE_3D", GL_TEXTURE_3D);
01774     gpu_get_print("GL_TEXTURE_BINDING_3D", GL_TEXTURE_BINDING_3D);
01775     gpu_get_print("GL_TEXTURE_BINDING_CUBE_MAP", GL_TEXTURE_BINDING_CUBE_MAP);
01776     gpu_get_print("GL_TEXTURE_COMPRESSION_HINT", GL_TEXTURE_COMPRESSION_HINT);
01777     gpu_get_print("GL_TEXTURE_COORD_ARRAY", GL_TEXTURE_COORD_ARRAY);
01778     gpu_get_print("GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING", GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING);
01779     gpu_get_print("GL_TEXTURE_COORD_ARRAY_SIZE", GL_TEXTURE_COORD_ARRAY_SIZE);
01780     gpu_get_print("GL_TEXTURE_COORD_ARRAY_STRIDE", GL_TEXTURE_COORD_ARRAY_STRIDE);
01781     gpu_get_print("GL_TEXTURE_COORD_ARRAY_TYPE", GL_TEXTURE_COORD_ARRAY_TYPE);
01782     gpu_get_print("GL_TEXTURE_CUBE_MAP", GL_TEXTURE_CUBE_MAP);
01783     gpu_get_print("GL_TEXTURE_GEN_Q", GL_TEXTURE_GEN_Q);
01784     gpu_get_print("GL_TEXTURE_GEN_R", GL_TEXTURE_GEN_R);
01785     gpu_get_print("GL_TEXTURE_GEN_S", GL_TEXTURE_GEN_S);
01786     gpu_get_print("GL_TEXTURE_GEN_T", GL_TEXTURE_GEN_T);
01787     gpu_get_print("GL_TEXTURE_MATRIX", GL_TEXTURE_MATRIX);
01788     gpu_get_print("GL_TEXTURE_STACK_DEPTH", GL_TEXTURE_STACK_DEPTH);
01789     gpu_get_print("GL_TRANSPOSE_COLOR_MATRIX", GL_TRANSPOSE_COLOR_MATRIX);
01790     gpu_get_print("GL_TRANSPOSE_MODELVIEW_MATRIX", GL_TRANSPOSE_MODELVIEW_MATRIX);
01791     gpu_get_print("GL_TRANSPOSE_PROJECTION_MATRIX", GL_TRANSPOSE_PROJECTION_MATRIX);
01792     gpu_get_print("GL_TRANSPOSE_TEXTURE_MATRIX", GL_TRANSPOSE_TEXTURE_MATRIX);
01793     gpu_get_print("GL_UNPACK_ALIGNMENT", GL_UNPACK_ALIGNMENT);
01794     gpu_get_print("GL_UNPACK_IMAGE_HEIGHT", GL_UNPACK_IMAGE_HEIGHT);
01795     gpu_get_print("GL_UNPACK_LSB_FIRST", GL_UNPACK_LSB_FIRST);
01796     gpu_get_print("GL_UNPACK_ROW_LENGTH", GL_UNPACK_ROW_LENGTH);
01797     gpu_get_print("GL_UNPACK_SKIP_IMAGES", GL_UNPACK_SKIP_IMAGES);
01798     gpu_get_print("GL_UNPACK_SKIP_PIXELS", GL_UNPACK_SKIP_PIXELS);
01799     gpu_get_print("GL_UNPACK_SKIP_ROWS", GL_UNPACK_SKIP_ROWS);
01800     gpu_get_print("GL_UNPACK_SWAP_BYTES", GL_UNPACK_SWAP_BYTES);
01801     gpu_get_print("GL_VERTEX_ARRAY", GL_VERTEX_ARRAY);
01802     gpu_get_print("GL_VERTEX_ARRAY_BUFFER_BINDING", GL_VERTEX_ARRAY_BUFFER_BINDING);
01803     gpu_get_print("GL_VERTEX_ARRAY_SIZE", GL_VERTEX_ARRAY_SIZE);
01804     gpu_get_print("GL_VERTEX_ARRAY_STRIDE", GL_VERTEX_ARRAY_STRIDE);
01805     gpu_get_print("GL_VERTEX_ARRAY_TYPE", GL_VERTEX_ARRAY_TYPE);
01806     gpu_get_print("GL_VERTEX_PROGRAM_POINT_SIZE", GL_VERTEX_PROGRAM_POINT_SIZE);
01807     gpu_get_print("GL_VERTEX_PROGRAM_TWO_SIDE", GL_VERTEX_PROGRAM_TWO_SIDE);
01808     gpu_get_print("GL_VIEWPORT", GL_VIEWPORT);
01809     gpu_get_print("GL_ZOOM_X", GL_ZOOM_X);
01810     gpu_get_print("GL_ZOOM_Y", GL_ZOOM_Y);
01811 }
01812