00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "config_glgsg.h"
00020
00021 #include "graphicsWindow.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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
00045
00046
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
00065
00066
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
00083
00084
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
00096
00097
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
00116
00117
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
00162
00163
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
00176
00177
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
00189
00190
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
00206
00207
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
00223
00224
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
00238
00239
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
00256
00257
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
00300
00301
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
00337
00338
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
00354
00355
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
00371
00372
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
00451
00452
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
00486
00487
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
00503
00504
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
00520
00521
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
00537
00538
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
00554
00555
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
00598
00599
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
00625
00626
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
00638
00639
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
00651
00652
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
00674
00675
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
00692
00693
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
00711
00712
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
00736
00737
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
00761
00762
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
00778
00779
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
00805
00806
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
00832
00833
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
00857
00858
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
00882
00883
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
00907
00908
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
00933
00934
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
00958
00959
00960
00961 INLINE GLenum GLGraphicsStateGuardian::get_light_id(int index) const {
00962 return GL_LIGHT0 + index;
00963 }
00964
00965
00966
00967
00968
00969
00970 INLINE GLenum GLGraphicsStateGuardian::
00971 get_clip_plane_id(int index) const {
00972 return GL_CLIP_PLANE0 + index;
00973 }
00974
00975
00976
00977
00978
00979
00980
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 }