Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/glgsg/glGraphicsStateGuardian.I

Go to the documentation of this file.
00001 // Filename: glGraphicsStateGuardian.I
00002 // Created by:  drose (02Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "config_glgsg.h"
00020 
00021 #include "graphicsWindow.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: GLGraphicsStateGuardian::report_errors
00025 //       Access: Public, Static
00026 //  Description: Checks for any outstanding error codes and outputs
00027 //               them, if found.  If NDEBUG is defined, this function
00028 //               does nothing.
00029 //
00030 //               This is a static method so it can be called when
00031 //               there's no gsg pointer around.
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE void GLGraphicsStateGuardian::
00034 report_errors(int line, const char *source_file) {
00035 #ifndef NDEBUG
00036   GLenum error_code = glGetError();
00037   if (error_code != GL_NO_ERROR) {
00038     report_errors_loop(line, source_file, error_code);
00039   }
00040 #endif
00041 }
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: GLGraphicsStateGuardian::call_glClearColor
00045 //       Access: Public
00046 //  Description:
00047 ////////////////////////////////////////////////////////////////////
00048 INLINE void GLGraphicsStateGuardian::
00049 call_glClearColor(GLclampf red, GLclampf green, GLclampf blue,
00050                   GLclampf alpha) {
00051   if (red != _clear_color_red ||
00052       green != _clear_color_green ||
00053       blue != _clear_color_blue ||
00054       alpha != _clear_color_alpha) {
00055     glClearColor(red, green, blue, alpha);
00056     _clear_color_red = red;
00057     _clear_color_green = green;
00058     _clear_color_blue = blue;
00059     _clear_color_alpha = alpha;
00060   }
00061 }
00062 
00063 ////////////////////////////////////////////////////////////////////
00064 //     Function: GLGraphicsStateGuardian::call_glClearDepth
00065 //       Access: Public
00066 //  Description:
00067 ////////////////////////////////////////////////////////////////////
00068 INLINE void GLGraphicsStateGuardian::
00069 call_glClearDepth(GLclampd depth) {
00070   if (depth != _clear_depth) {
00071 #ifdef GSG_VERBOSE
00072     glgsg_cat.spam()
00073       << "glClearDepth(" << (double)depth << ")" << endl;
00074 #endif
00075     glClearDepth(depth);
00076     _clear_depth = depth;
00077   }
00078 }
00079 
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: GLGraphicsStateGuardian::call_glClearStencil
00083 //       Access: Public
00084 //  Description:
00085 ////////////////////////////////////////////////////////////////////
00086 INLINE void GLGraphicsStateGuardian::
00087 call_glClearStencil(GLint s) {
00088   if (s != _clear_stencil) {
00089     glClearStencil(s);
00090     _clear_stencil = s;
00091   }
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: GLGraphicsStateGuardian::call_glClearAccum
00096 //       Access: Public
00097 //  Description:
00098 ////////////////////////////////////////////////////////////////////
00099 INLINE void GLGraphicsStateGuardian::
00100 call_glClearAccum(GLclampf red, GLclampf green, GLclampf blue,
00101                   GLclampf alpha) {
00102   if (red != _clear_accum_red ||
00103       green != _clear_accum_green ||
00104       blue != _clear_accum_blue ||
00105       alpha != _clear_accum_alpha) {
00106     glClearAccum(red, green, blue, alpha);
00107     _clear_accum_red = red;
00108     _clear_accum_green = green;
00109     _clear_accum_blue = blue;
00110     _clear_accum_alpha = alpha;
00111   }
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: GLGraphicsStateGuardian::call_glDrawBuffer
00116 //       Access: Public
00117 //  Description:
00118 ////////////////////////////////////////////////////////////////////
00119 INLINE void GLGraphicsStateGuardian::
00120 call_glDrawBuffer(GLenum mode) {
00121   if (mode != _draw_buffer_mode) {
00122 #ifdef GSG_VERBOSE
00123     glgsg_cat.spam() << "glDrawBuffer(";
00124     switch (mode) {
00125     case GL_FRONT:
00126       glgsg_cat.spam(false) << "GL_FRONT)";
00127       break;
00128     case GL_BACK:
00129       glgsg_cat.spam(false) << "GL_BACK)";
00130       break;
00131     case GL_RIGHT:
00132       glgsg_cat.spam(false) << "GL_RIGHT)";
00133       break;
00134     case GL_LEFT:
00135       glgsg_cat.spam(false) << "GL_LEFT)";
00136       break;
00137     case GL_FRONT_RIGHT:
00138       glgsg_cat.spam(false) << "GL_FRONT_RIGHT)";
00139       break;
00140     case GL_FRONT_LEFT:
00141       glgsg_cat.spam(false) << "GL_FRONT_LEFT)";
00142       break;
00143     case GL_BACK_RIGHT:
00144       glgsg_cat.spam(false) << "GL_BACK_RIGHT)";
00145       break;
00146     case GL_BACK_LEFT:
00147       glgsg_cat.spam(false) << "GL_BACK_LEFT)";
00148       break;
00149     case GL_FRONT_AND_BACK:
00150       glgsg_cat.spam(false) << "GL_FRONT_AND_BACK)";
00151       break;
00152     }
00153     glgsg_cat.spam(false) << endl;
00154 #endif
00155     glDrawBuffer(mode);
00156     _draw_buffer_mode = mode;
00157   }
00158 }
00159 
00160 ////////////////////////////////////////////////////////////////////
00161 //     Function: GLGraphicsStateGuardian::call_glReadBuffer
00162 //       Access: Public
00163 //  Description:
00164 ////////////////////////////////////////////////////////////////////
00165 INLINE void GLGraphicsStateGuardian::
00166 call_glReadBuffer(GLenum mode) {
00167   if (mode != _read_buffer_mode) {
00168     glReadBuffer(mode);
00169     _read_buffer_mode = mode;
00170   }
00171 }
00172 
00173 
00174 ////////////////////////////////////////////////////////////////////
00175 //     Function: GLGraphicsStateGuardian::call_glShadeModel
00176 //       Access:
00177 //  Description: Set the shading model to be either GL_FLAT or GL_SMOOTH
00178 ////////////////////////////////////////////////////////////////////
00179 INLINE void GLGraphicsStateGuardian::
00180 call_glShadeModel(GLenum mode) {
00181   if (_shade_model_mode != mode) {
00182     glShadeModel(mode);
00183     _shade_model_mode = mode;
00184   }
00185 }
00186 
00187 ////////////////////////////////////////////////////////////////////
00188 //     Function: GLGraphicsStateGuardian::call_glScissor
00189 //       Access:
00190 //  Description:
00191 ////////////////////////////////////////////////////////////////////
00192 INLINE void GLGraphicsStateGuardian::
00193 call_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
00194 {
00195     if ( _scissor_x != x || _scissor_y != y ||
00196         _scissor_width != width || _scissor_height != height )
00197     {
00198         _scissor_x = x; _scissor_y = y;
00199         _scissor_width = width; _scissor_height = height;
00200         glScissor( x, y, width, height );
00201     }
00202 }
00203 
00204 ////////////////////////////////////////////////////////////////////
00205 //     Function: GLGraphicsStateGuardian::call_glViewport
00206 //       Access:
00207 //  Description:
00208 ////////////////////////////////////////////////////////////////////
00209 INLINE void GLGraphicsStateGuardian::
00210 call_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
00211 {
00212     if ( _viewport_x != x || _viewport_y != y ||
00213         _viewport_width != width || _viewport_height != height )
00214     {
00215         _viewport_x = x; _viewport_y = y;
00216         _viewport_width = width; _viewport_height = height;
00217         glViewport( x, y, width, height );
00218     }
00219 }
00220 
00221 ////////////////////////////////////////////////////////////////////
00222 //     Function: GLGraphicsStateGuardian::call_glLightModelLocal
00223 //       Access:
00224 //  Description:
00225 ////////////////////////////////////////////////////////////////////
00226 INLINE void GLGraphicsStateGuardian::
00227 call_glLightModelLocal(GLboolean local)
00228 {
00229     if ( _lmodel_local != local )
00230     {
00231         _lmodel_local = local;
00232         glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, local );
00233     }
00234 }
00235 
00236 ////////////////////////////////////////////////////////////////////
00237 //     Function: GLGraphicsStateGuardian::call_glLightModelLocal
00238 //       Access:
00239 //  Description:
00240 ////////////////////////////////////////////////////////////////////
00241 INLINE void GLGraphicsStateGuardian::
00242 call_glLightModelTwoSide(GLboolean twoside)
00243 {
00244   if (_lmodel_twoside != twoside) {
00245     _lmodel_twoside = twoside;
00246 #ifdef GSG_VERBOSE
00247     glgsg_cat.spam()
00248       << "glLightModel(GL_LIGHT_MODEL_TWO_SIDE, " << (int)twoside << ")" << endl;
00249 #endif
00250     glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, twoside);
00251   }
00252 }
00253 
00254 ////////////////////////////////////////////////////////////////////
00255 //     Function: GLGraphicsStateGuardian::call_glStencilFunc
00256 //       Access:
00257 //  Description:
00258 ////////////////////////////////////////////////////////////////////
00259 INLINE void GLGraphicsStateGuardian::
00260 call_glStencilFunc(GLenum func,GLint ref,GLuint mask) {
00261 
00262 #ifdef GSG_VERBOSE
00263     glgsg_cat.spam() << "glStencilFunc(";
00264     switch (func) {
00265     case GL_NEVER:
00266       glgsg_cat.spam(false) << "GL_NEVER, ";
00267       break;
00268     case GL_LESS:
00269       glgsg_cat.spam(false) << "GL_LESS, ";
00270       break;
00271     case GL_EQUAL:
00272       glgsg_cat.spam(false) << "GL_EQUAL, ";
00273       break;
00274     case GL_LEQUAL:
00275       glgsg_cat.spam(false) << "GL_LEQUAL, ";
00276       break;
00277     case GL_GREATER:
00278       glgsg_cat.spam(false) << "GL_GREATER, ";
00279       break;
00280     case GL_NOTEQUAL:
00281       glgsg_cat.spam(false) << "GL_NOTEQUAL, ";
00282       break;
00283     case GL_GEQUAL:
00284       glgsg_cat.spam(false) << "GL_GEQUAL, ";
00285       break;
00286     case GL_ALWAYS:
00287       glgsg_cat.spam(false) << "GL_ALWAYS, ";
00288       break;
00289     default:
00290       glgsg_cat.spam(false) << "unknown, ";
00291       break;
00292     }
00293     glgsg_cat.spam(false) << (int)ref << (unsigned int)mask << ")\n";
00294 #endif
00295     glStencilFunc(func, ref, mask);
00296 }
00297 
00298 ////////////////////////////////////////////////////////////////////
00299 //     Function: GLGraphicsStateGuardian::call_glStencilOp
00300 //       Access:
00301 //  Description:
00302 ////////////////////////////////////////////////////////////////////
00303 INLINE void GLGraphicsStateGuardian::
00304 call_glStencilOp(GLenum fail,GLenum zfail,GLenum zpass) {
00305 #ifdef GSG_VERBOSE
00306     glgsg_cat.spam() << "glStencilOp(fail, zfail, ";
00307     switch (zpass) {
00308     case GL_KEEP:
00309       glgsg_cat.spam(false) << "GL_KEEP)";
00310       break;
00311     case GL_ZERO:
00312       glgsg_cat.spam(false) << "GL_ZERO)";
00313       break;
00314     case GL_REPLACE:
00315       glgsg_cat.spam(false) << "GL_REPLACE)";
00316       break;
00317     case GL_INCR:
00318       glgsg_cat.spam(false) << "GL_INCR)";
00319       break;
00320     case GL_DECR:
00321       glgsg_cat.spam(false) << "GL_DECR)";
00322       break;
00323     case GL_INVERT:
00324       glgsg_cat.spam(false) << "GL_INVERT)";
00325       break;
00326     default:
00327       glgsg_cat.spam(false) << "unknown)";
00328       break;
00329     }
00330     glgsg_cat.spam(false) << endl;
00331 #endif
00332     glStencilOp(fail,zfail,zpass);
00333 }
00334 
00335 ////////////////////////////////////////////////////////////////////
00336 //     Function: GLGraphicsStateGuardian::call_glLineWidth
00337 //       Access:
00338 //  Description:
00339 ////////////////////////////////////////////////////////////////////
00340 INLINE void GLGraphicsStateGuardian::
00341 call_glLineWidth(GLfloat width) {
00342   if (_line_width != width) {
00343     _line_width = width;
00344 #ifdef GSG_VERBOSE
00345   glgsg_cat.spam()
00346     << "glLineWidth(" << width << ")" << endl;
00347 #endif
00348     glLineWidth(width);
00349   }
00350 }
00351 
00352 ////////////////////////////////////////////////////////////////////
00353 //     Function: GLGraphicsStateGuardian::call_glPointSize
00354 //       Access:
00355 //  Description:
00356 ////////////////////////////////////////////////////////////////////
00357 INLINE void GLGraphicsStateGuardian::
00358 call_glPointSize(GLfloat size) {
00359   if (_point_size != size) {
00360     _point_size = size;
00361 #ifdef GSG_VERBOSE
00362   glgsg_cat.spam()
00363     << "glPointSize(" << size << ")" << endl;
00364 #endif
00365     glPointSize(size);
00366   }
00367 }
00368 
00369 ////////////////////////////////////////////////////////////////////
00370 //     Function: GLGraphicsStateGuardian::call_glBlendFunc
00371 //       Access:
00372 //  Description:
00373 ////////////////////////////////////////////////////////////////////
00374 INLINE void GLGraphicsStateGuardian::
00375 call_glBlendFunc(GLenum sfunc, GLenum dfunc) {
00376   if (_blend_source_func != sfunc || _blend_dest_func != dfunc) {
00377     _blend_source_func = sfunc;
00378     _blend_dest_func = dfunc;
00379 #ifdef GSG_VERBOSE
00380     glgsg_cat.spam() << "glBlendFunc(";
00381     switch (sfunc) {
00382     case GL_ZERO:
00383       glgsg_cat.spam(false) << "GL_ZERO, ";
00384       break;
00385     case GL_ONE:
00386       glgsg_cat.spam(false) << "GL_ONE, ";
00387       break;
00388     case GL_DST_COLOR:
00389       glgsg_cat.spam(false) << "GL_DST_COLOR, ";
00390       break;
00391     case GL_ONE_MINUS_DST_COLOR:
00392       glgsg_cat.spam(false) << "GL_ONE_MINUS_DST_COLOR, ";
00393       break;
00394     case GL_SRC_ALPHA:
00395       glgsg_cat.spam(false) << "GL_SRC_ALPHA, ";
00396       break;
00397     case GL_ONE_MINUS_SRC_ALPHA:
00398       glgsg_cat.spam(false) << "GL_ONE_MINUS_SRC_ALPHA, ";
00399       break;
00400     case GL_DST_ALPHA:
00401       glgsg_cat.spam(false) << "GL_DST_ALPHA, ";
00402       break;
00403     case GL_ONE_MINUS_DST_ALPHA:
00404       glgsg_cat.spam(false) << "GL_ONE_MINUS_DST_ALPHA, ";
00405       break;
00406     case GL_SRC_ALPHA_SATURATE:
00407 
00408       glgsg_cat.spam(false) << "GL_SRC_ALPHA_SATURATE, ";
00409       break;
00410     default:
00411       glgsg_cat.spam(false) << "unknown, ";
00412       break;
00413     }
00414     switch (dfunc) {
00415     case GL_ZERO:
00416       glgsg_cat.spam(false) << "GL_ZERO)";
00417       break;
00418     case GL_ONE:
00419       glgsg_cat.spam(false) << "GL_ONE)";
00420       break;
00421     case GL_SRC_COLOR:
00422       glgsg_cat.spam(false) << "GL_SRC_COLOR)";
00423       break;
00424     case GL_ONE_MINUS_SRC_COLOR:
00425       glgsg_cat.spam(false) << "GL_ONE_MINUS_SRC_COLOR)";
00426       break;
00427     case GL_SRC_ALPHA:
00428       glgsg_cat.spam(false) << "GL_SRC_ALPHA)";
00429       break;
00430     case GL_ONE_MINUS_SRC_ALPHA:
00431       glgsg_cat.spam(false) << "GL_ONE_MINUS_SRC_ALPHA)";
00432       break;
00433     case GL_DST_ALPHA:
00434       glgsg_cat.spam(false) << "GL_DST_ALPHA)";
00435       break;
00436     case GL_ONE_MINUS_DST_ALPHA:
00437       glgsg_cat.spam(false) << "GL_ONE_MINUS_DST_ALPHA)";
00438       break;
00439     default:
00440       glgsg_cat.spam(false) << "unknown)";
00441       break;
00442     }
00443     glgsg_cat.spam(false) << endl;
00444 #endif
00445     glBlendFunc(sfunc, dfunc);
00446   }
00447 }
00448 
00449 ////////////////////////////////////////////////////////////////////
00450 //     Function: GLGraphicsStateGuardian::call_glFogMode
00451 //       Access:
00452 //  Description:
00453 ////////////////////////////////////////////////////////////////////
00454 INLINE void GLGraphicsStateGuardian::
00455 call_glFogMode(GLint mode) {
00456   if (_fog_mode != mode) {
00457     _fog_mode = mode;
00458 #ifdef GSG_VERBOSE
00459     glgsg_cat.spam() << "glFog(GL_FOG_MODE, ";
00460     switch(mode) {
00461     case GL_LINEAR:
00462       glgsg_cat.spam(false) << "GL_LINEAR)" << endl;
00463       break;
00464     case GL_EXP:
00465       glgsg_cat.spam(false) << "GL_EXP)" << endl;
00466       break;
00467     case GL_EXP2:
00468       glgsg_cat.spam(false) << "GL_EXP2)" << endl;
00469       break;
00470 #ifdef GL_FOG_FUNC_SGIS
00471     case GL_FOG_FUNC_SGIS:
00472       glgsg_cat.spam(false) << "GL_FOG_FUNC_SGIS)" << endl;
00473       break;
00474 #endif
00475     default:
00476       glgsg_cat.spam(false) << "unknown)" << endl;
00477       break;
00478     }
00479 #endif
00480     glFogi(GL_FOG_MODE, mode);
00481   }
00482 }
00483 
00484 ////////////////////////////////////////////////////////////////////
00485 //     Function: GLGraphicsStateGuardian::call_glFogStart
00486 //       Access:
00487 //  Description:
00488 ////////////////////////////////////////////////////////////////////
00489 INLINE void GLGraphicsStateGuardian::
00490 call_glFogStart(GLfloat start) {
00491   if (_fog_start != start) {
00492     _fog_start = start;
00493 #ifdef GSG_VERBOSE
00494   glgsg_cat.spam()
00495     << "glFog(GL_FOG_START, " << start << ")" << endl;
00496 #endif
00497     glFogf(GL_FOG_START, start);
00498   }
00499 }
00500 
00501 ////////////////////////////////////////////////////////////////////
00502 //     Function: GLGraphicsStateGuardian::call_glFogEnd
00503 //       Access:
00504 //  Description:
00505 ////////////////////////////////////////////////////////////////////
00506 INLINE void GLGraphicsStateGuardian::
00507 call_glFogEnd(GLfloat end) {
00508   if (_fog_end != end) {
00509     _fog_end = end;
00510 #ifdef GSG_VERBOSE
00511   glgsg_cat.spam()
00512     << "glFog(GL_FOG_END, " << end << ")" << endl;
00513 #endif
00514     glFogf(GL_FOG_END, end);
00515   }
00516 }
00517 
00518 ////////////////////////////////////////////////////////////////////
00519 //     Function: GLGraphicsStateGuardian::call_glFogDensity
00520 //       Access:
00521 //  Description:
00522 ////////////////////////////////////////////////////////////////////
00523 INLINE void GLGraphicsStateGuardian::
00524 call_glFogDensity(GLfloat density) {
00525   if (_fog_density != density) {
00526     _fog_density = density;
00527 #ifdef GSG_VERBOSE
00528   glgsg_cat.spam()
00529     << "glFog(GL_FOG_DENSITY, " << density << ")" << endl;
00530 #endif
00531     glFogf(GL_FOG_DENSITY, density);
00532   }
00533 }
00534 
00535 ////////////////////////////////////////////////////////////////////
00536 //     Function: GLGraphicsStateGuardian::call_glFogColor
00537 //       Access:
00538 //  Description:
00539 ////////////////////////////////////////////////////////////////////
00540 INLINE void GLGraphicsStateGuardian::
00541 call_glFogColor(const Colorf &color) {
00542   if (_fog_color != color) {
00543     _fog_color = color;
00544 #ifdef GSG_VERBOSE
00545   glgsg_cat.spam()
00546     << "glFog(GL_FOG_COLOR, " << color << ")" << endl;
00547 #endif
00548     glFogfv(GL_FOG_COLOR, color.get_data());
00549   }
00550 }
00551 
00552 ////////////////////////////////////////////////////////////////////
00553 //     Function: GLGraphicsStateGuardian::call_glAlphaFunc
00554 //       Access:
00555 //  Description:
00556 ////////////////////////////////////////////////////////////////////
00557 INLINE void GLGraphicsStateGuardian::
00558 call_glAlphaFunc(GLenum func, GLclampf ref) {
00559   if (_alpha_func != func || _alpha_func_ref != ref) {
00560     _alpha_func = func;
00561     _alpha_func_ref = ref;
00562 #ifdef GSG_VERBOSE
00563     glgsg_cat.spam() << "glAlphaFunc(";
00564     switch (func) {
00565     case GL_NEVER:
00566       glgsg_cat.spam(false) << "GL_NEVER, ";
00567       break;
00568     case GL_LESS:
00569       glgsg_cat.spam(false) << "GL_LESS, ";
00570       break;
00571     case GL_EQUAL:
00572       glgsg_cat.spam(false) << "GL_EQUAL, ";
00573       break;
00574     case GL_LEQUAL:
00575       glgsg_cat.spam(false) << "GL_LEQUAL, ";
00576       break;
00577     case GL_GREATER:
00578       glgsg_cat.spam(false) << "GL_GREATER, ";
00579       break;
00580     case GL_NOTEQUAL:
00581       glgsg_cat.spam(false) << "GL_NOTEQUAL, ";
00582       break;
00583     case GL_GEQUAL:
00584       glgsg_cat.spam(false) << "GL_GEQUAL, ";
00585       break;
00586     case GL_ALWAYS:
00587       glgsg_cat.spam(false) << "GL_ALWAYS, ";
00588       break;
00589     }
00590     glgsg_cat.spam() << ref << ")" << endl;
00591 #endif
00592     glAlphaFunc(func, ref);
00593   }
00594 }
00595 
00596 ////////////////////////////////////////////////////////////////////
00597 //     Function: GLGraphicsStateGuardian::call_glPolygonMode
00598 //       Access:
00599 //  Description:
00600 ////////////////////////////////////////////////////////////////////
00601 INLINE void GLGraphicsStateGuardian::
00602 call_glPolygonMode(GLenum mode) {
00603   if (_polygon_mode != mode) {
00604     _polygon_mode = mode;
00605 #ifdef GSG_VERBOSE
00606     glgsg_cat.spam() << "glPolygonMode(GL_BACK_AND_FRONT, ";
00607     switch (mode) {
00608     case GL_POINT:
00609       glgsg_cat.spam(false) << "GL_POINT)" << endl;
00610       break;
00611     case GL_LINE:
00612       glgsg_cat.spam(false) << "GL_LINE)" << endl;
00613       break;
00614     case GL_FILL:
00615       glgsg_cat.spam(false) << "GL_FILL)" << endl;
00616       break;
00617     }
00618 #endif
00619     glPolygonMode(GL_FRONT_AND_BACK, mode);
00620   }
00621 }
00622 
00623 ////////////////////////////////////////////////////////////////////
00624 //     Function: GLGraphicsStateGuardian::set_pack_alignment
00625 //       Access:
00626 //  Description:
00627 ////////////////////////////////////////////////////////////////////
00628 INLINE void GLGraphicsStateGuardian::
00629 set_pack_alignment(GLint alignment) {
00630   if (_pack_alignment != alignment) {
00631     glPixelStorei(GL_PACK_ALIGNMENT, alignment);
00632     _pack_alignment = alignment;
00633   }
00634 }
00635 
00636 ////////////////////////////////////////////////////////////////////
00637 //     Function: GLGraphicsStateGuardian::set_unpack_alignment
00638 //       Access:
00639 //  Description:
00640 ////////////////////////////////////////////////////////////////////
00641 INLINE void GLGraphicsStateGuardian::
00642 set_unpack_alignment(GLint alignment) {
00643   if (_unpack_alignment != alignment) {
00644     glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
00645     _unpack_alignment = alignment;
00646   }
00647 }
00648 
00649 ////////////////////////////////////////////////////////////////////
00650 //     Function: GLGraphicsStateGuardian::enable_multisample
00651 //       Access:
00652 //  Description:
00653 ////////////////////////////////////////////////////////////////////
00654 INLINE void GLGraphicsStateGuardian::
00655 enable_multisample(bool val) {
00656   if (_multisample_enabled != val) {
00657     _multisample_enabled = val;
00658     if (val) {
00659 #ifdef GL_MULTISAMPLE_SGIS
00660       glEnable(GL_MULTISAMPLE_SGIS);
00661 #endif
00662       glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
00663     } else {
00664 #ifdef GL_MULTISAMPLE_SGIS
00665       glDisable(GL_MULTISAMPLE_SGIS);
00666 #endif
00667       glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
00668     }
00669   }
00670 }
00671 
00672 ////////////////////////////////////////////////////////////////////
00673 //     Function: GLGraphicsStateGuardian::enable_line_smooth
00674 //       Access:
00675 //  Description:
00676 ////////////////////////////////////////////////////////////////////
00677 INLINE void GLGraphicsStateGuardian::
00678 enable_line_smooth(bool val) {
00679   if (_line_smooth_enabled != val) {
00680     _line_smooth_enabled = val;
00681     if (val) {
00682       glEnable(GL_LINE_SMOOTH);
00683       glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
00684     } else {
00685       glDisable(GL_LINE_SMOOTH);
00686     }
00687   }
00688 }
00689 
00690 ////////////////////////////////////////////////////////////////////
00691 //     Function: GLGraphicsStateGuardian::enable_point_smooth
00692 //       Access:
00693 //  Description:
00694 ////////////////////////////////////////////////////////////////////
00695 INLINE void GLGraphicsStateGuardian::
00696 enable_point_smooth(bool val) {
00697   if (_point_smooth_enabled != val) {
00698     _point_smooth_enabled = val;
00699     if (val) {
00700       glEnable(GL_POINT_SMOOTH);
00701       glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
00702     } else {
00703       glDisable(GL_POINT_SMOOTH);
00704       glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
00705     }
00706   }
00707 }
00708 
00709 ////////////////////////////////////////////////////////////////////
00710 //     Function: GLGraphicsStateGuardian::enable_stencil_test
00711 //       Access:
00712 //  Description:
00713 ////////////////////////////////////////////////////////////////////
00714 INLINE void GLGraphicsStateGuardian::
00715 enable_stencil_test(bool val) {
00716   if (_stencil_test_enabled != val) {
00717     _stencil_test_enabled = val;
00718     if (val) {
00719 #ifdef GSG_VERBOSE
00720       glgsg_cat.spam()
00721         << "glEnable(GL_STENCIL_TEST)" << endl;
00722 #endif
00723       glEnable(GL_STENCIL_TEST);
00724     } else {
00725 #ifdef GSG_VERBOSE
00726       glgsg_cat.spam()
00727         << "glDisable(GL_STENCIL_TEST)" << endl;
00728 #endif
00729       glDisable(GL_STENCIL_TEST);
00730     }
00731   }
00732 }
00733 
00734 ////////////////////////////////////////////////////////////////////
00735 //     Function: GLGraphicsStateGuardian::enable_texturing
00736 //       Access:
00737 //  Description:
00738 ////////////////////////////////////////////////////////////////////
00739 INLINE void GLGraphicsStateGuardian::
00740 enable_texturing(bool val) {
00741   if (_texturing_enabled != val) {
00742     _texturing_enabled = val;
00743     if (val) {
00744 #ifdef GSG_VERBOSE
00745       glgsg_cat.spam()
00746         << "glEnable(GL_TEXTURE_2D)" << endl;
00747 #endif
00748       glEnable(GL_TEXTURE_2D);
00749     } else {
00750 #ifdef GSG_VERBOSE
00751       glgsg_cat.spam()
00752         << "glDisable(GL_TEXTURE_2D)" << endl;
00753 #endif
00754       glDisable(GL_TEXTURE_2D);
00755     }
00756   }
00757 }
00758 
00759 ////////////////////////////////////////////////////////////////////
00760 //     Function: GLGraphicsStateGuardian::enable_scissor
00761 //       Access:
00762 //  Description:
00763 ////////////////////////////////////////////////////////////////////
00764 INLINE void GLGraphicsStateGuardian::
00765 enable_scissor(bool val)
00766 {
00767     if ( _scissor_enabled != val ) {
00768         _scissor_enabled = val;
00769         if ( val )
00770             glEnable( GL_SCISSOR_TEST );
00771         else
00772             glDisable( GL_SCISSOR_TEST );
00773     }
00774 }
00775 
00776 ////////////////////////////////////////////////////////////////////
00777 //     Function: GLGraphicsStateGuardian::enable_multisample_alpha_one
00778 //       Access:
00779 //  Description:
00780 ////////////////////////////////////////////////////////////////////
00781 INLINE void GLGraphicsStateGuardian::
00782 enable_multisample_alpha_one(bool val) {
00783   if (_multisample_alpha_one_enabled != val) {
00784     _multisample_alpha_one_enabled = val;
00785 #ifdef GL_SAMPLE_ALPHA_TO_ONE_SGIS
00786     if (val) {
00787 #ifdef GSG_VERBOSE
00788       glgsg_cat.spam()
00789         << "glEnable(GL_SAMPLE_ALPHA_TO_ONE_SGIS)" << endl;
00790 #endif
00791       glEnable(GL_SAMPLE_ALPHA_TO_ONE_SGIS);
00792     } else {
00793 #ifdef GSG_VERBOSE
00794       glgsg_cat.spam()
00795         << "glDisable(GL_SAMPLE_ALPHA_TO_ONE_SGIS)" << endl;
00796 #endif
00797       glDisable(GL_SAMPLE_ALPHA_TO_ONE_SGIS);
00798     }
00799 #endif  // GL_SAMPLE_ALPHA_TO_ONE_SGIS
00800   }
00801 }
00802 
00803 ////////////////////////////////////////////////////////////////////
00804 //     Function: GLGraphicsStateGuardian::enable_multisample_alpha_mask
00805 //       Access:
00806 //  Description:
00807 ////////////////////////////////////////////////////////////////////
00808 INLINE void GLGraphicsStateGuardian::
00809 enable_multisample_alpha_mask(bool val) {
00810   if (_multisample_alpha_mask_enabled != val) {
00811     _multisample_alpha_mask_enabled = val;
00812 #ifdef GL_SAMPLE_ALPHA_TO_MASK_SGIS
00813     if (val) {
00814 #ifdef GSG_VERBOSE
00815       glgsg_cat.spam()
00816         << "glEnable(GL_SAMPLE_ALPHA_TO_MASK_SGIS)" << endl;
00817 #endif
00818       glEnable(GL_SAMPLE_ALPHA_TO_MASK_SGIS);
00819     } else {
00820 #ifdef GSG_VERBOSE
00821       glgsg_cat.spam()
00822         << "glDisable(GL_SAMPLE_ALPHA_TO_MASK_SGIS)" << endl;
00823 #endif
00824       glDisable(GL_SAMPLE_ALPHA_TO_MASK_SGIS);
00825     }
00826 #endif  // GL_SAMPLE_ALPHA_TO_MASK_SGIS
00827   }
00828 }
00829 
00830 ////////////////////////////////////////////////////////////////////
00831 //     Function: GLGraphicsStateGuardian::enable_blend
00832 //       Access:
00833 //  Description:
00834 ////////////////////////////////////////////////////////////////////
00835 INLINE void GLGraphicsStateGuardian::
00836 enable_blend(bool val) {
00837   if (_blend_enabled != val) {
00838     _blend_enabled = val;
00839     if (val) {
00840 #ifdef GSG_VERBOSE
00841       glgsg_cat.spam()
00842         << "glEnable(GL_BLEND)" << endl;
00843 #endif
00844       glEnable(GL_BLEND);
00845     } else {
00846 #ifdef GSG_VERBOSE
00847       glgsg_cat.spam()
00848         << "glDisable(GL_BLEND)" << endl;
00849 #endif
00850       glDisable(GL_BLEND);
00851     }
00852   }
00853 }
00854 
00855 ////////////////////////////////////////////////////////////////////
00856 //     Function: GLGraphicsStateGuardian::enable_depth_test
00857 //       Access:
00858 //  Description:
00859 ////////////////////////////////////////////////////////////////////
00860 INLINE void GLGraphicsStateGuardian::
00861 enable_depth_test(bool val) {
00862   if (_depth_test_enabled != val) {
00863     _depth_test_enabled = val;
00864     if (val) {
00865 #ifdef GSG_VERBOSE
00866       glgsg_cat.spam()
00867         << "glEnable(GL_DEPTH_TEST)" << endl;
00868 #endif
00869       glEnable(GL_DEPTH_TEST);
00870     } else {
00871 #ifdef GSG_VERBOSE
00872       glgsg_cat.spam()
00873         << "glDisable(GL_DEPTH_TEST)" << endl;
00874 #endif
00875       glDisable(GL_DEPTH_TEST);
00876     }
00877   }
00878 }
00879 
00880 ////////////////////////////////////////////////////////////////////
00881 //     Function: GLGraphicsStateGuardian::enable_fog
00882 //       Access:
00883 //  Description:
00884 ////////////////////////////////////////////////////////////////////
00885 INLINE void GLGraphicsStateGuardian::
00886 enable_fog(bool val) {
00887   if (_fog_enabled != val) {
00888     _fog_enabled = val;
00889     if (val) {
00890 #ifdef GSG_VERBOSE
00891       glgsg_cat.spam()
00892         << "glEnable(GL_FOG)" << endl;
00893 #endif
00894       glEnable(GL_FOG);
00895     } else {
00896 #ifdef GSG_VERBOSE
00897       glgsg_cat.spam()
00898         << "glDisable(GL_FOG)" << endl;
00899 #endif
00900       glDisable(GL_FOG);
00901     }
00902   }
00903 }
00904 
00905 ////////////////////////////////////////////////////////////////////
00906 //     Function: GLGraphicsStateGuardian::enable_alpha_test
00907 //       Access:
00908 //  Description:
00909 ////////////////////////////////////////////////////////////////////
00910 INLINE void GLGraphicsStateGuardian::
00911 enable_alpha_test(bool val) {
00912   if (_alpha_test_enabled != val) {
00913     _alpha_test_enabled = val;
00914     if (val) {
00915 #ifdef GSG_VERBOSE
00916       glgsg_cat.spam()
00917         << "glEnable(GL_ALPHA_TEST)" << endl;
00918 #endif
00919       glEnable(GL_ALPHA_TEST);
00920     } else {
00921 #ifdef GSG_VERBOSE
00922       glgsg_cat.spam()
00923         << "glDisable(GL_ALPHA_TEST)" << endl;
00924 #endif
00925       glDisable(GL_ALPHA_TEST);
00926     }
00927   }
00928 }
00929 
00930 
00931 ////////////////////////////////////////////////////////////////////
00932 //     Function: GLGraphicsStateGuardian::enable_polygon_offset
00933 //       Access:
00934 //  Description:
00935 ////////////////////////////////////////////////////////////////////
00936 INLINE void GLGraphicsStateGuardian::
00937 enable_polygon_offset(bool val) {
00938   if (_polygon_offset_enabled != val) {
00939     _polygon_offset_enabled = val;
00940     if (val) {
00941 #ifdef GSG_VERBOSE
00942       glgsg_cat.spam()
00943         << "glEnable(GL_POLYGON_OFFSET_*)" << endl;
00944 #endif
00945       glEnable(GL_POLYGON_OFFSET_FILL);
00946     } else {
00947 #ifdef GSG_VERBOSE
00948       glgsg_cat.spam()
00949         << "glDisable(GL_POLYGON_OFFSET_*)" << endl;
00950 #endif
00951       glDisable(GL_POLYGON_OFFSET_FILL);
00952     }
00953   }
00954 }
00955 
00956 ////////////////////////////////////////////////////////////////////
00957 //     Function: GLGraphicsStateGuardian::get_light_id
00958 //       Access: Public
00959 //  Description: Convert index to gl light id
00960 ////////////////////////////////////////////////////////////////////
00961 INLINE GLenum GLGraphicsStateGuardian::get_light_id(int index) const {
00962   return GL_LIGHT0 + index;
00963 }
00964 
00965 ////////////////////////////////////////////////////////////////////
00966 //     Function: GLGraphicsStateGuardian::get_clip_plane_id
00967 //       Access: Public
00968 //  Description: Convert index to gl clip plane id
00969 ////////////////////////////////////////////////////////////////////
00970 INLINE GLenum GLGraphicsStateGuardian::
00971 get_clip_plane_id(int index) const {
00972   return GL_CLIP_PLANE0 + index;
00973 }
00974 
00975 ////////////////////////////////////////////////////////////////////
00976 //     Function: GLGraphicsStateGuardian::issue_scene_graph_color
00977 //       Access: Public
00978 //  Description: Checks whether the scene graph color needs to be
00979 //               issued, and sends the appropriate glColor command if
00980 //               it does.
00981 ////////////////////////////////////////////////////////////////////
00982 INLINE void GLGraphicsStateGuardian::
00983 issue_scene_graph_color() {
00984   if (_scene_graph_color_stale) {
00985     issue_transformed_color(_scene_graph_color);
00986     _scene_graph_color_stale = false;
00987   }
00988 }

Generated on Fri May 2 00:39:09 2003 for Panda by doxygen1.3