Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkOpenGLStateCache.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkOpenGLStateCache.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00033 #ifndef VTK_IMPLEMENT_MESA_CXX
00034 #if defined(__APPLE__) && (defined(VTK_USE_CARBON) || defined(VTK_USE_COCOA))
00035 #include <OpenGL/gl.h>
00036 #else
00037 #include <GL/gl.h>
00038 #endif
00039 #endif
00040 
00041 #define vtkOpenGLCall_glEnable vtkOpenGLStateCache::CurrentGLCache->glEnable
00042 #define vtkOpenGLCall_glDisable vtkOpenGLStateCache::CurrentGLCache->glDisable
00043 #define vtkOpenGLCall_glAlphaFunc vtkOpenGLStateCache::CurrentGLCache->glAlphaFunc
00044 #define vtkOpenGLCall_glBlendFunc vtkOpenGLStateCache::CurrentGLCache->glBlendFunc
00045 #define vtkOpenGLCall_glDepthFunc vtkOpenGLStateCache::CurrentGLCache->glDepthFunc
00046 #define vtkOpenGLCall_glTexEnvf vtkOpenGLStateCache::CurrentGLCache->glTexEnvf
00047 #define vtkOpenGLCall_glLightModeli vtkOpenGLStateCache::CurrentGLCache->glLightModeli
00048 #define vtkOpenGLCall_glLightModelfv vtkOpenGLStateCache::CurrentGLCache->glLightMOdelfv
00049 #define vtkOpenGLCall_glLightfv vtkOpenGLStateCache::CurrentGLCache->glLightfv
00050 #define vtkOpenGLCall_glLightf vtkOpenGLStateCache::CurrentGLCache->glLightf
00051 #define vtkOpenGLCall_glLighti vtkOpenGLStateCache::CurrentGLCache->glLighti
00052 #define vtkOpenGLCall_glMaterialfv vtkOpenGLStateCache::CurrentGLCache->glMaterialfv
00053 #define vtkOpenGLCall_glShadeModel vtkOpenGLStateCache::CurrentGLCache->glShadeModel
00054 #define vtkOpenGLCall_glClearColor vtkOpenGLStateCache::CurrentGLCache->glClearColor
00055 #define vtkOpenGLCall_glClearDepth vtkOpenGLStateCache::CurrentGLCache->glClearDepth
00056 #define vtkOpenGLCall_glDepthMask vtkOpenGLStateCache::CurrentGLCache->glDepthMask
00057 #define vtkOpenGLCall_glCullFace vtkOpenGLStateCache::CurrentGLCache->glCullFace
00058 #define vtkOpenGLCall_glClear vtkOpenGLStateCache::CurrentGLCache->glClear
00059 #define vtkOpenGLCall_glDrawBuffer vtkOpenGLStateCache::CurrentGLCache->glDrawBuffer
00060 #define vtkOpenGLCall_glMatrixMode vtkOpenGLStateCache::CurrentGLCache->glMatrixMode
00061 #define vtkOpenGLCall_glViewport vtkOpenGLStateCache::CurrentGLCache->glViewport
00062 #define vtkOpenGLCall_glScissor vtkOpenGLStateCache::CurrentGLCache->glScissor
00063 #define vtkOpenGLCall_glClipPlane vtkOpenGLStateCache::CurrentGLCache->glClipPlane
00064 #define vtkOpenGLCall_glColorMaterial vtkOpenGLStateCache::CurrentGLCache->glColorMaterial
00065 #define vtkOpenGLCall_glPointSize vtkOpenGLStateCache::CurrentGLCache->glPointSize
00066 #define vtkOpenGLCall_glLineWidth vtkOpenGLStateCache::CurrentGLCache->glLineWidth
00067 #define vtkOpenGLCall_glLineStipple vtkOpenGLStateCache::CurrentGLCache->glLineStipple
00068 #define vtkOpenGLCall_glDepthRange vtkOpenGLStateCache::CurrentGLCache->glDepthRange
00069 #define vtkOpenGLCall_glPolygonOffset vtkOpenGLStateCache::CurrentGLCache->glPolygonOffset
00070 
00071 #define vtkOpenGLCall_glPushMatrix glPushMatrix
00072 #define vtkOpenGLCall_glPopMatrix glPopMatrix
00073 #define vtkOpenGLCall_glMultMatrixd glMultMatrixd
00074 #define vtkOpenGLCall_glLoadMatrixd glLoadMatrixd
00075 #define vtkOpenGLCall_glLoadIdentity glLoadIdentity
00076 #define vtkOpenGLCall_glSelectBuffer glSelectBuffer
00077 #define vtkOpenGLCall_glRenderMode glRenderMode
00078 #define vtkOpenGLCall_glInitNames glInitNames
00079 #define vtkOpenGLCall_glPushName glPushName
00080 #define vtkOpenGLCall_glLoadName glLoadName
00081 #define vtkOpenGLCall_glGetIntegerv glGetIntegerv
00082 #define vtkOpenGLCall_glIsTexture glIsTexture
00083 #define vtkOpenGLCall_glDeleteTextures glDeleteTexture
00084 #define vtkOpenGLCall_glGenTextures glGenTextures
00085 #define vtkOpenGLCall_glBindTexture glBindTexture
00086 #define vtkOpenGLCall_glTexParameterf glTextParameterf
00087 #define vtkOpenGLCall_glTexCoord2fv glTexCoord2fv
00088 #define vtkOpenGLCall_glVertex3fv glVertex3fv
00089 #define vtkOpenGLCall_glNormal3fv glNormal3fv
00090 #define vtkOpenGLCall_glColor3f glColor3f
00091 #define vtkOpenGLCall_glColor4ubv glColor4ubv
00092 #define vtkOpenGLCall_glColor4fv glColor4fv
00093 #define vtkOpenGLCall_glBegin glBegin
00094 #define vtkOpenGLCall_glEnd glEnd
00095 #define vtkOpenGLCall_glTexImage2D glTextImage2D
00096 #define vtkOpenGLCall_glDeleteLists glDeleteLists
00097 #define vtkOpenGLCall_glIsList glIsList
00098 #define vtkOpenGLCall_glGenLists glGenLists
00099 #define vtkOpenGLCall_glCallList glCallList
00100 #define vtkOpenGLCall_glReadBuffer glReadBuffer
00101 #define vtkOpenGLCall_glPixelStorei glPixelStorei
00102 #define vtkOpenGLCall_glReadPixels glReadPixels
00103 #define vtkOpenGLCall_glRasterPos3f glRasterPos3f
00104 #define vtkOpenGLCall_glDrawPixels glDrawPixels
00105 #define vtkOpenGLCall_glRasterPos2f glRasterPos2f
00106 #define vtkOpenGLCall_glNewList glNewList
00107 #define vtkOpenGLCall_glEndList glEndList
00108 
00109 class vtkOpenGLStateCache  
00110 {
00111 public:
00112   static vtkOpenGLStateCache *CurrentGLCache; // recursive definition
00113 
00114   vtkOpenGLStateCache(); // set all members to initial values
00115   ~vtkOpenGLStateCache(); // delete any dynamic objects
00116   void Initialize();
00117 
00118   // GL_BLEND         = 0x0BE2
00119   // GL_POINT_SMOOTH  = 0x0B10
00120   // GL_LINE_SMOOTH   = 0x0B20
00121   // GL_POLYGON_SMOOTH= 0x0B41
00122   // GL_DEPTH_TEST    = 0x0B71
00123   // GL_ALPHA_TEST    = 0x0BC0
00124   // GL_TEXTURE_2D    = 0x0DE1
00125   // GL_CLIP_PLANE0+i = 0x3000
00126   // GL_LIGHTING      = 0x0B50
00127   // GL_COLOR_MATERIAL= 0x0B57
00128   // GL_NORMALIZE     = 0x0BA1
00129   // GL_CULL_FACE     = 0x0B44
00130   // GL_SCISSOR_TEST  = 0x0C11
00131   // GL_POLYGON_OFFSET_FILL = 0x8037
00132   // GL_LINE_STIPPLE  = 0x0B24
00133   // GL_LIGHT+i       = 0x4000
00134   char Enable_buckets[0xDE1-0xB10+1]; // 0xB10-0xDE1
00135   char Enable_GL_LIGHT_buckets[8]; // 0x4000 + i (0<i<8)
00136   char Enable_GL_CLIP_PLANE_buckets[8]; // 0x8000 + i (0<i<8)
00137   /* Need to have special handling for disabling and enabling the 
00138      GL_LIGHT's because they are disabling too many lights!
00139      need to propagate in how many lights are actually *on*
00140      and only apply the op to them.
00141    */
00142   inline void glEnable(GLenum e) 
00143     {
00144       register int ex;
00145       register char *val=0;
00146       if(e&0x4000)
00147         {
00148         ex=e-0x4000;
00149         if(ex<8) {val=Enable_GL_LIGHT_buckets+ex; }
00150         }    
00151       else 
00152         {
00153         if(e&0x8000)
00154           {
00155           ex=e-0x8000;
00156           if(ex<8) { val=Enable_GL_CLIP_PLANE_buckets+ex; }
00157           }
00158         else 
00159           {
00160           if(e>=0xB10 && e<=0xDE1)
00161             {
00162             ex=e-0xB10;
00163             val=Enable_buckets+ex;
00164             }
00165           else
00166             {
00167             printf("Error: glEnable of 0x%X failed\n",e);
00168             }
00169           }
00170         }
00171       if(val && *val!=1)
00172         {
00173         *val=1;
00174         ::glEnable(e);
00175         }
00176     }
00177   inline void glDisable(GLenum e) 
00178     {
00179       register int ex;
00180       register char *val=0;
00181       if(e&0x4000)
00182         {
00183         ex=e-0x4000;
00184         if(ex<8) { val=Enable_GL_LIGHT_buckets+ex; }
00185         }    
00186       else
00187         {
00188         if(e&0x8000)
00189           {
00190           ex=e-0x8000;
00191           if(ex<8) { val=Enable_GL_CLIP_PLANE_buckets+ex; }
00192           }
00193         else 
00194           {
00195           if(e>=0xB10 && e<=0xDE1)
00196             {
00197             ex=e-0xB10;
00198             val=Enable_buckets+ex;
00199             }
00200           else
00201             {
00202             printf("Error: glEnable of 0x%X failed\n",e);
00203             }
00204           }
00205         }
00206       if(val && *val!=0)
00207         {
00208         *val=0;
00209         ::glDisable(e);
00210         }
00211     }
00212   
00213   // GL_GREATER = 0x0204, (GLclampf) 0
00214   GLclampf AlphaFunc_bucket;
00215   inline void glAlphaFunc(GLenum e,GLclampf cf) 
00216     {
00217       if(e==GL_GREATER && cf!=AlphaFunc_bucket)
00218         {
00219         AlphaFunc_bucket=cf;
00220         ::glAlphaFunc(e,cf);
00221         }
00222     }
00223   
00224   // GL_SRC_ALPHA = 0x0302, GL_ONE_MINUS_SRC_ALPHA = 0x0303
00225   GLenum BlendFunc_bucket; // multibucket if any other blendfunc is used
00226   inline void glBlendFunc(GLenum e,GLenum e1) 
00227     {
00228       if(e==GL_SRC_ALPHA && e1!=BlendFunc_bucket)
00229         {
00230         BlendFunc_bucket=e1;
00231         ::glBlendFunc(e,e1);
00232         }
00233     }
00234   
00235   // GL_GREATER = 0x0204
00236   // GL_LESS    = 0x0201
00237   // GL_LEQUAL  = 0x0203
00238   GLenum DepthFunc_bucket;
00239   inline void glDepthFunc(GLenum e) 
00240     {
00241       if(e!=DepthFunc_bucket)
00242         {
00243         DepthFunc_bucket=e;
00244         ::glDepthFunc(e);
00245         }
00246     }
00247   
00248   // GL_TEXTURE_ENV = 0x2300, GL_TEXTURE_ENV_MODE = 0x2200, GL_MODULATE = 0x2100
00249   GLfloat TexEnvf_MODE_bucket; // total kludge right now
00250   inline void glTexEnvf(GLenum e,GLenum e1,GLfloat f) 
00251     {
00252       if(e==GL_TEXTURE_ENV && e1==GL_TEXTURE_ENV_MODE)
00253         {
00254         if(f!=TexEnvf_MODE_bucket)
00255           {
00256           TexEnvf_MODE_bucket=f;
00257           ::glTexEnvf(e,e1,f);
00258           }
00259         }
00260     }
00261   
00262   // GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE/FALSE
00263   // GL_LIGHT_MODEL_TWO_SIDE, 0
00264   GLint LightModeli_LIGHT_MODEL_TWO_SIDE_bucket; // shoudld check other modes
00265   inline void glLightModeli(GLenum e,GLint i) 
00266     {
00267       if(e==GL_LIGHT_MODEL_TWO_SIDE && i!=LightModeli_LIGHT_MODEL_TWO_SIDE_bucket){
00268       LightModeli_LIGHT_MODEL_TWO_SIDE_bucket=i;
00269       ::glLightModeli(e,i);
00270       }
00271     }
00272   
00273   // GL_LIGHT_MODEL_AMBIENT, fvect(amb color), A=1.0
00274   // GL_LIGHT_MODEL_AMBIENT = 0x0B53
00275   GLfloat LightModelfv_LIGHT_MODEL_AMBIENT_bucket[3];
00276   inline void glLightModelfv(GLenum e,GLfloat *fv) 
00277     {
00278       if(e==GL_LIGHT_MODEL_AMBIENT && 
00279          (fv[0]!=LightModelfv_LIGHT_MODEL_AMBIENT_bucket[0] ||
00280           fv[1]!=LightModelfv_LIGHT_MODEL_AMBIENT_bucket[1] ||
00281           fv[2]!=LightModelfv_LIGHT_MODEL_AMBIENT_bucket[2])){
00282       fv[0]=LightModelfv_LIGHT_MODEL_AMBIENT_bucket[0];
00283       fv[1]=LightModelfv_LIGHT_MODEL_AMBIENT_bucket[1];
00284       fv[2]=LightModelfv_LIGHT_MODEL_AMBIENT_bucket[2]; 
00285       ::glLightModelfv(e,fv);
00286       }
00287     }
00288   
00289   // light=GL_LIGHT index
00290   // pname= lighting type
00291   //   GL_DIFFUSE        = 0x1201
00292   //   GL_SPECULAR       = 0x1202
00293   //   GL_POSITION       = 0x1203
00294   //   GL_SPOT_DIRECTION = 0x1204
00295   GLfloat Lightfv_buckets[8*4*8];
00296   inline void glLightfv( GLenum light, GLenum pname, const GLfloat *params) 
00297     {
00298       register GLfloat *val = Lightfv_buckets + ((((int)(pname-0x1201))|((int)(light-GL_LIGHT0)<<3))<<2);
00299       if(params[0]!=val[0] ||
00300          params[1]!=val[1] ||
00301          params[2]!=val[2] ||
00302          params[3]!=val[3])
00303         {
00304         val[0]=params[0];
00305         val[1]=params[1];
00306         val[2]=params[2];
00307         val[3]=params[3];
00308         ::glLightfv(light,pname,params);
00309         }
00310     } 
00311   
00312   // light=GL_LIGHT index
00313   // pname= lighting parameter
00314   //   GL_SPOT_EXPONENT        = 0x1205
00315   //   GL_SPOT_CUTOFF          = 0x1206
00316   //   GL_CONSTANT_ATTENUATION = 0x1207
00317   //   GL_LINEAR_ATTENUATION   = 0x1208
00318   //   GL_QUADRATIC_ATTENUATION= 0x1209
00319   GLfloat Lightf_buckets[8*8];
00320   GLint Lighti_SPOT_CUTOFF_buckets[8];
00321   inline void glLightf( GLenum light, GLenum pname, GLfloat f){
00322     register GLfloat *val=Lightf_buckets+(((int)(light-GL_LIGHT0)<<3)|((int)(pname-0x1205)));
00323     if(val[0]!=f)
00324       {
00325       val[0]=f;
00326       ::glLightf(light,pname,f);
00327       if(pname==GL_SPOT_CUTOFF) // invalidate integer spot cutoff
00328         Lighti_SPOT_CUTOFF_buckets[light-GL_LIGHT0]=-1;
00329       }
00330   }
00331   
00332   // light=GL_LIGHT index
00333   // pname=lighting parameter
00334   //   GL_SPOT_CUTOFF = 0x1206
00335   // needs to invalidate the float light cutoff
00336   inline void glLighti( GLenum light, GLenum pname, GLint f) 
00337     {
00338       if(pname==GL_SPOT_CUTOFF && f!=Lighti_SPOT_CUTOFF_buckets[light-GL_LIGHT0]){
00339       Lighti_SPOT_CUTOFF_buckets[light-GL_LIGHT0]=f;
00340       ::glLighti(light,pname,f);
00341       // need to invalidate the float cutoff
00342       Lightf_buckets[((int)(light-GL_LIGHT0)<<3)|0x02] = -1.0f;
00343       }
00344     }  
00345   
00346   // Face, GL_AMBIENT, float Info[4] 
00347   //   GL_FRONT          = 0x0404  
00348   //   GL_BACK           = 0x0405
00349   //   GL_FRONT_AND_BACK = 0x0408
00350   // GL_AMBIENT   = 0x1200
00351   // GL_DIFFUSE   = 0x1201
00352   // GL_SPECULAR  = 0x1202
00353   // GL_EMISSION  = 0x1600
00354   // GL_SHININESS = 0x1601
00355   // GL_AMBIENT_AND_DIFFUSE = 0x1602
00356   // GL_COLOR_INDEXES       = 0x1603
00357   GLfloat Materialfv_buckets[8*8*4]; 
00358   inline void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params ) 
00359     {
00360       register int idx;
00361       register GLfloat *val;
00362       if(pname>=0x1600) 
00363         {
00364         idx=pname-0x1600 + 4; // put it just past the 120x buckets
00365         }
00366       else 
00367         {
00368         idx=pname-0x1200;
00369         }
00370       // FRONT/BACK and FRONT_AND_BACK should do both.
00371       // or perhaps should be a separate state key?
00372       // For now, we will treat FRONT_AND_BACK independently
00373       // because from a practical standpoint, that's how 
00374       // it tends to get used.
00375       val = Materialfv_buckets + ((((face-0x0404)<<3)|idx)<<2);
00376       if(val[0]!=params[0] ||
00377          val[1]!=params[1] || 
00378          val[2]!=params[2] ||
00379          val[3]!=params[3])
00380         {
00381         val[0]=params[0];
00382         val[1]=params[1];
00383         val[2]=params[2];
00384         val[3]=params[3];
00385         ::glMaterialfv(face,pname,params);
00386         }
00387     }
00388 
00389   /*
00390     a=0;
00391     a|=(val[0]^params[0])
00392     a|=(val[1]^params[1])
00393     a|=(val[2]^params[2])
00394     a|=(val[3]^params[3])
00395    */
00396   // GL_FLAT   = 0x1D00
00397   // GL_SMOOTH = 0x1D01
00398   GLenum ShadeModel_bucket; 
00399   inline void glShadeModel(GLenum e)
00400     {
00401       if(ShadeModel_bucket!=e)
00402         {
00403         ShadeModel_bucket=e;
00404         ::glShadeModel(e);
00405         }
00406     }
00407   
00408   GLclampf ClearColor_buckets[4];
00409   inline void glClearColor(GLclampf r,GLclampf g,GLclampf b,GLclampf a)
00410     {
00411       register GLclampf *c=ClearColor_buckets;
00412       if(c[0]!=r ||
00413          c[1]!=g ||
00414          c[2]!=b ||
00415          c[3]!=a)
00416         {
00417         c[0]=r;
00418         c[1]=g;
00419         c[2]=b;
00420         c[3]=a;
00421         ::glClearColor(r,g,b,a);
00422         }
00423     }
00424   
00425   GLclampd ClearDepth_bucket;
00426   inline void glClearDepth(GLclampd d) 
00427     { 
00428       if(d!=ClearDepth_bucket)
00429         {
00430         ClearDepth_bucket=d;
00431         ::glClearDepth(d);
00432         }
00433     }
00434   
00435   GLclampf DepthMask_bucket;
00436   inline void glDepthMask(GLenum e)
00437     {
00438       if(DepthMask_bucket!=e)
00439         {
00440         DepthMask_bucket=e;
00441         ::glDepthMask(e);
00442         }
00443     }
00444   
00445   // GL_FRONT = 0x0404
00446   // GL_BACK  = 0x0405
00447   GLenum CullFace_bucket;
00448   inline void glCullFace(GLenum e)
00449     {
00450       if(CullFace_bucket!=e)
00451         {
00452         CullFace_bucket=e;
00453         ::glCullFace(e);
00454         }
00455     }
00456   
00457   // well, lets go ahead and let it clear when it wants to
00458   inline void glClear(GLbitfield b) { ::glClear(b);}
00459   // GL_BACK_LEFT  = 0x0402
00460   // GL_BACK_RIGHT = 0x0403
00461   // GL_FRONT      = 0x0404
00462   // GL_BACK       = 0x0405
00463   GLenum DrawBuffer_bucket;
00464   inline void glDrawBuffer(GLenum e) {
00465     if(e!=DrawBuffer_bucket){
00466       DrawBuffer_bucket=e;
00467       ::glDrawBuffer(e);
00468     }
00469   }
00470   //============Matrix Ops (behave different for deferred ops)===
00471   // GL_MODELVIEW=0x1700
00472   // GL_PROJECTION=0x1701
00473   GLenum  MatrixMode_bucket;
00474   inline void glMatrixMode(GLenum e) {
00475     if(e!=MatrixMode_bucket){
00476       MatrixMode_bucket=e;
00477       ::glMatrixMode(e);
00478     }
00479   }
00480 
00481   GLint Viewport_bucket[4];
00482   inline void glViewport(GLint llx,GLint lly,GLint u,GLint v){
00483     register GLint *val=Viewport_bucket;
00484     if(val[0]!=llx ||
00485        val[1]!=lly ||
00486        val[2]!=u ||
00487        val[3]!=v){
00488       val[0]=llx;
00489       val[1]=lly;
00490       val[2]=u;
00491       val[3]=v;
00492       ::glViewport(llx,lly,u,v);
00493     }
00494   }
00495   // only needs to be called if scissor changes (and it usually won't)
00496   GLint Scissor_bucket[4];
00497   inline void glScissor(GLint llx,GLint lly,GLint u,GLint v){
00498     register GLint *val=Scissor_bucket;
00499     if(val[0]!=llx ||
00500        val[1]!=lly ||
00501        val[2]!=u ||
00502        val[3]!=v){
00503       val[0]=llx;
00504       val[1]=lly;
00505       val[2]=u;
00506       val[3]=v;
00507       ::glScissor(llx,lly,u,v);
00508     }
00509   }
00510   
00511   // what is the order of the clip plane eqn???
00512   // GL_CLIP_PLANE0 = 0x3000
00513   GLdouble ClipPlane_bucket[4*GL_MAX_CLIP_PLANES];
00514   inline void glClipPlane(GLenum e,const GLdouble *eqn){
00515     register GLdouble *val=ClipPlane_bucket + ((e-0x3000)<<2);
00516     if(val[0]!=eqn[0] ||
00517        val[1]!=eqn[1] ||
00518        val[2]!=eqn[2] ||
00519        val[3]!=eqn[3]){
00520       val[0]=eqn[0];
00521       val[1]=eqn[1];
00522       val[2]=eqn[2];
00523       val[3]=eqn[3];
00524       ::glClipPlane(e,eqn);
00525     }
00526   }
00527 
00528   // face= 
00529   //   GL_FRONT          = 0x0404  
00530   //   GL_BACK           = 0x0405
00531   //   GL_FRONT_AND_BACK = 0x0408
00532   GLenum ColorMaterial_bucket[8];
00533   inline void glColorMaterial(GLenum face,GLenum mode ){
00534     register GLenum *val= ColorMaterial_bucket + (face-0x0404);
00535     if(*val!=mode){
00536       *val=mode;
00537       ::glColorMaterial(face,mode);
00538     }
00539   }
00540   GLfloat PointSize_bucket;
00541   inline void glPointSize(GLfloat f) {
00542     if(f!=PointSize_bucket){
00543       PointSize_bucket=f;
00544       ::glPointSize(f);
00545     }
00546   }
00547   GLfloat LineWidth_bucket;
00548   inline void glLineWidth(GLfloat f){
00549     if(f!=LineWidth_bucket){
00550       LineWidth_bucket=f;
00551       ::glPointSize(f);
00552     }
00553   }
00554   GLint LineStipple_FACTOR_bucket;
00555   GLushort LineStipple_PATTERN_bucket;
00556   inline void glLineStipple(GLint factor, GLushort pattern )
00557     {
00558       if(factor!=LineStipple_FACTOR_bucket ||
00559          pattern!=LineStipple_PATTERN_bucket)
00560         {
00561         LineStipple_FACTOR_bucket=factor;
00562         LineStipple_PATTERN_bucket=pattern;
00563         ::glLineStipple(factor,pattern);
00564         }
00565     }
00566 
00567   GLclampd DepthRange_NEAR_bucket;
00568   GLclampd DepthRange_FAR_bucket;
00569   inline void glDepthRange(GLclampd nearval,GLclampd farval )
00570     {
00571       if(DepthRange_NEAR_bucket!=nearval ||
00572          DepthRange_FAR_bucket!=farval)
00573         {
00574         DepthRange_NEAR_bucket=nearval;
00575         DepthRange_FAR_bucket=farval;
00576         ::glDepthRange(nearval,farval);
00577         }
00578     }
00579   
00580 #ifdef GL_VERSION_1_1
00581   // enable GL_POLYGON_OFFSET_FILL = 0x8037
00582   GLfloat PolygonOffset_bucket[2];
00583   inline void glPolygonOffset( GLfloat f,GLfloat u) {
00584     if(PolygonOffset_bucket[0]!=f ||
00585        PolygonOffset_bucket[1]!=u){
00586       PolygonOffset_bucket[0]=f;
00587       PolygonOffset_bucket[1]=u;
00588       ::glPolygonOffset(f,u);
00589     }
00590   }
00591 #endif
00592 };
00593 
00594 
00595 //#ifdef vtkOpenGLStateCache_Cache
00596 //#undef vtkOpenGLStateCache_Cache
00597 //#endif