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