00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "config_crgsg.h"
00020
00021 #include <graphicsWindow.h>
00022
00023
00024
00025
00026
00027
00028
00029 INLINE void CRGraphicsStateGuardian::
00030 activate() {
00031
00032
00033
00034
00035
00036
00037 _win->make_current();
00038 }
00039
00040
00041
00042
00043
00044
00045 INLINE void CRGraphicsStateGuardian::
00046 call_glClearColor(GLclampf red, GLclampf green, GLclampf blue,
00047 GLclampf alpha) {
00048 if (red != _clear_color_red ||
00049 green != _clear_color_green ||
00050 blue != _clear_color_blue ||
00051 alpha != _clear_color_alpha) {
00052 chromium.ClearColor(red, green, blue, alpha);
00053 _clear_color_red = red;
00054 _clear_color_green = green;
00055 _clear_color_blue = blue;
00056 _clear_color_alpha = alpha;
00057 }
00058 }
00059
00060
00061
00062
00063
00064
00065 INLINE void CRGraphicsStateGuardian::
00066 call_glClearDepth(GLclampd depth) {
00067 if (depth != _clear_depth) {
00068 #ifdef GSG_VERBOSE
00069 crgsg_cat.debug()
00070 << "crClearDepth(" << (double)depth << ")" << endl;
00071 #endif
00072 chromium.ClearDepth(depth);
00073 _clear_depth = depth;
00074 }
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 INLINE void CRGraphicsStateGuardian::
00084 call_glClearStencil(GLint s) {
00085 if (s != _clear_stencil) {
00086 chromium.ClearStencil(s);
00087 _clear_stencil = s;
00088 }
00089 }
00090
00091
00092
00093
00094
00095
00096 INLINE void CRGraphicsStateGuardian::
00097 call_glClearAccum(GLclampf red, GLclampf green, GLclampf blue,
00098 GLclampf alpha) {
00099 if (red != _clear_accum_red ||
00100 green != _clear_accum_green ||
00101 blue != _clear_accum_blue ||
00102 alpha != _clear_accum_alpha) {
00103 chromium.ClearAccum(red, green, blue, alpha);
00104 _clear_accum_red = red;
00105 _clear_accum_green = green;
00106 _clear_accum_blue = blue;
00107 _clear_accum_alpha = alpha;
00108 }
00109 }
00110
00111
00112
00113
00114
00115
00116 INLINE void CRGraphicsStateGuardian::
00117 call_glDrawBuffer(GLenum mode) {
00118 if (mode != _draw_buffer_mode) {
00119 #ifdef GSG_VERBOSE
00120 crgsg_cat.debug() << "crDrawBuffer(";
00121 switch (mode) {
00122 case GL_FRONT:
00123 crgsg_cat.debug(false) << "GL_FRONT)";
00124 break;
00125 case GL_BACK:
00126 crgsg_cat.debug(false) << "GL_BACK)";
00127 break;
00128 case GL_RIGHT:
00129 crgsg_cat.debug(false) << "GL_RIGHT)";
00130 break;
00131 case GL_LEFT:
00132 crgsg_cat.debug(false) << "GL_LEFT)";
00133 break;
00134 case GL_FRONT_RIGHT:
00135 crgsg_cat.debug(false) << "GL_FRONT_RIGHT)";
00136 break;
00137 case GL_FRONT_LEFT:
00138 crgsg_cat.debug(false) << "GL_FRONT_LEFT)";
00139 break;
00140 case GL_BACK_RIGHT:
00141 crgsg_cat.debug(false) << "GL_BACK_RIGHT)";
00142 break;
00143 case GL_BACK_LEFT:
00144 crgsg_cat.debug(false) << "GL_BACK_LEFT)";
00145 break;
00146 case GL_FRONT_AND_BACK:
00147 crgsg_cat.debug(false) << "GL_FRONT_AND_BACK)";
00148 break;
00149 }
00150 crgsg_cat.debug(false) << endl;
00151 #endif
00152 chromium.DrawBuffer(mode);
00153 _draw_buffer_mode = mode;
00154 }
00155 }
00156
00157
00158
00159
00160
00161
00162 INLINE void CRGraphicsStateGuardian::
00163 call_glReadBuffer(GLenum mode) {
00164 if (mode != _read_buffer_mode) {
00165 chromium.ReadBuffer(mode);
00166 _read_buffer_mode = mode;
00167 }
00168 }
00169
00170
00171
00172
00173
00174
00175
00176 INLINE void CRGraphicsStateGuardian::
00177 call_glShadeModel(GLenum mode) {
00178 if (_shade_model_mode != mode) {
00179 chromium.ShadeModel(mode);
00180 _shade_model_mode = mode;
00181 }
00182 }
00183
00184
00185
00186
00187
00188
00189 INLINE void CRGraphicsStateGuardian::
00190 call_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
00191 {
00192 if ( _scissor_x != x || _scissor_y != y ||
00193 _scissor_width != width || _scissor_height != height )
00194 {
00195 _scissor_x = x; _scissor_y = y;
00196 _scissor_width = width; _scissor_height = height;
00197 chromium.Scissor( x, y, width, height );
00198 }
00199 }
00200
00201
00202
00203
00204
00205
00206 INLINE void CRGraphicsStateGuardian::
00207 call_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
00208 {
00209 if ( _viewport_x != x || _viewport_y != y ||
00210 _viewport_width != width || _viewport_height != height )
00211 {
00212 _viewport_x = x; _viewport_y = y;
00213 _viewport_width = width; _viewport_height = height;
00214 chromium.Viewport( x, y, width, height );
00215 }
00216 }
00217
00218
00219
00220
00221
00222
00223 INLINE void CRGraphicsStateGuardian::
00224 call_glLightModelLocal(GLboolean local)
00225 {
00226 if ( _lmodel_local != local )
00227 {
00228 _lmodel_local = local;
00229 chromium.LightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, local );
00230 }
00231 }
00232
00233
00234
00235
00236
00237
00238 INLINE void CRGraphicsStateGuardian::
00239 call_glLightModelTwoSide(GLboolean twoside)
00240 {
00241 if (_lmodel_twoside != twoside) {
00242 _lmodel_twoside = twoside;
00243 #ifdef GSG_VERBOSE
00244 crgsg_cat.debug()
00245 << "crLightModel(GL_LIGHT_MODEL_TWO_SIDE, " << (int)twoside << ")" << endl;
00246 #endif
00247 chromium.LightModeli(GL_LIGHT_MODEL_TWO_SIDE, twoside);
00248 }
00249 }
00250
00251
00252
00253
00254
00255
00256 INLINE void CRGraphicsStateGuardian::
00257 call_glStencilFunc(GLenum func,GLint ref,GLuint mask) {
00258
00259 #ifdef GSG_VERBOSE
00260 crgsg_cat.debug() << "crStencilFunc(";
00261 switch (func) {
00262 case GL_NEVER:
00263 crgsg_cat.debug(false) << "GL_NEVER, ";
00264 break;
00265 case GL_LESS:
00266 crgsg_cat.debug(false) << "GL_LESS, ";
00267 break;
00268 case GL_EQUAL:
00269 crgsg_cat.debug(false) << "GL_EQUAL, ";
00270 break;
00271 case GL_LEQUAL:
00272 crgsg_cat.debug(false) << "GL_LEQUAL, ";
00273 break;
00274 case GL_GREATER:
00275 crgsg_cat.debug(false) << "GL_GREATER, ";
00276 break;
00277 case GL_NOTEQUAL:
00278 crgsg_cat.debug(false) << "GL_NOTEQUAL, ";
00279 break;
00280 case GL_GEQUAL:
00281 crgsg_cat.debug(false) << "GL_GEQUAL, ";
00282 break;
00283 case GL_ALWAYS:
00284 crgsg_cat.debug(false) << "GL_ALWAYS, ";
00285 break;
00286 default:
00287 crgsg_cat.debug(false) << "unknown, ";
00288 break;
00289 }
00290 crgsg_cat.debug(false) << ref << mask << ")\n";
00291 #endif
00292 chromium.StencilFunc(func, ref, mask);
00293 }
00294
00295
00296
00297
00298
00299
00300 INLINE void CRGraphicsStateGuardian::
00301 call_glStencilOp(GLenum fail,GLenum zfail,GLenum zpass) {
00302 #ifdef GSG_VERBOSE
00303 crgsg_cat.debug() << "crStencilOp(fail, zfail, ";
00304 switch (zpass) {
00305 case GL_KEEP:
00306 crgsg_cat.debug(false) << "GL_KEEP)";
00307 break;
00308 case GL_ZERO:
00309 crgsg_cat.debug(false) << "GL_ZERO)";
00310 break;
00311 case GL_REPLACE:
00312 crgsg_cat.debug(false) << "GL_REPLACE)";
00313 break;
00314 case GL_INCR:
00315 crgsg_cat.debug(false) << "GL_INCR)";
00316 break;
00317 case GL_DECR:
00318 crgsg_cat.debug(false) << "GL_DECR)";
00319 break;
00320 case GL_INVERT:
00321 crgsg_cat.debug(false) << "GL_INVERT)";
00322 break;
00323 default:
00324 crgsg_cat.debug(false) << "unknown)";
00325 break;
00326 }
00327 crgsg_cat.debug(false) << endl;
00328 #endif
00329 chromium.StencilOp(fail,zfail,zpass);
00330 }
00331
00332
00333
00334
00335
00336
00337 INLINE void CRGraphicsStateGuardian::
00338 call_glLineWidth(GLfloat width) {
00339 if (_line_width != width) {
00340 _line_width = width;
00341 #ifdef GSG_VERBOSE
00342 crgsg_cat.debug()
00343 << "crLineWidth(" << width << ")" << endl;
00344 #endif
00345 chromium.LineWidth(width);
00346 }
00347 }
00348
00349
00350
00351
00352
00353
00354 INLINE void CRGraphicsStateGuardian::
00355 call_glPointSize(GLfloat size) {
00356 if (_point_size != size) {
00357 _point_size = size;
00358 #ifdef GSG_VERBOSE
00359 crgsg_cat.debug()
00360 << "crPointSize(" << size << ")" << endl;
00361 #endif
00362 chromium.PointSize(size);
00363 }
00364 }
00365
00366
00367
00368
00369
00370
00371 INLINE void CRGraphicsStateGuardian::
00372 call_glBlendFunc(GLenum sfunc, GLenum dfunc) {
00373 if (_blend_source_func != sfunc || _blend_dest_func != dfunc) {
00374 _blend_source_func = sfunc;
00375 _blend_dest_func = dfunc;
00376 #ifdef GSG_VERBOSE
00377 crgsg_cat.debug() << "crBlendFunc(";
00378 switch (sfunc) {
00379 case GL_ZERO:
00380 crgsg_cat.debug(false) << "GL_ZERO, ";
00381 break;
00382 case GL_ONE:
00383 crgsg_cat.debug(false) << "GL_ONE, ";
00384 break;
00385 case GL_DST_COLOR:
00386 crgsg_cat.debug(false) << "GL_DST_COLOR, ";
00387 break;
00388 case GL_ONE_MINUS_DST_COLOR:
00389 crgsg_cat.debug(false) << "GL_ONE_MINUS_DST_COLOR, ";
00390 break;
00391 case GL_SRC_ALPHA:
00392 crgsg_cat.debug(false) << "GL_SRC_ALPHA, ";
00393 break;
00394 case GL_ONE_MINUS_SRC_ALPHA:
00395 crgsg_cat.debug(false) << "GL_ONE_MINUS_SRC_ALPHA, ";
00396 break;
00397 case GL_DST_ALPHA:
00398 crgsg_cat.debug(false) << "GL_DST_ALPHA, ";
00399 break;
00400 case GL_ONE_MINUS_DST_ALPHA:
00401 crgsg_cat.debug(false) << "GL_ONE_MINUS_DST_ALPHA, ";
00402 break;
00403 case GL_SRC_ALPHA_SATURATE:
00404
00405 crgsg_cat.debug(false) << "GL_SRC_ALPHA_SATURATE, ";
00406 break;
00407 default:
00408 crgsg_cat.debug(false) << "unknown, ";
00409 break;
00410 }
00411 switch (dfunc) {
00412 case GL_ZERO:
00413 crgsg_cat.debug(false) << "GL_ZERO)";
00414 break;
00415 case GL_ONE:
00416 crgsg_cat.debug(false) << "GL_ONE)";
00417 break;
00418 case GL_SRC_COLOR:
00419 crgsg_cat.debug(false) << "GL_SRC_COLOR)";
00420 break;
00421 case GL_ONE_MINUS_SRC_COLOR:
00422 crgsg_cat.debug(false) << "GL_ONE_MINUS_SRC_COLOR)";
00423 break;
00424 case GL_SRC_ALPHA:
00425 crgsg_cat.debug(false) << "GL_SRC_ALPHA)";
00426 break;
00427 case GL_ONE_MINUS_SRC_ALPHA:
00428 crgsg_cat.debug(false) << "GL_ONE_MINUS_SRC_ALPHA)";
00429 break;
00430 case GL_DST_ALPHA:
00431 crgsg_cat.debug(false) << "GL_DST_ALPHA)";
00432 break;
00433 case GL_ONE_MINUS_DST_ALPHA:
00434 crgsg_cat.debug(false) << "GL_ONE_MINUS_DST_ALPHA)";
00435 break;
00436 default:
00437 crgsg_cat.debug(false) << "unknown)";
00438 break;
00439 }
00440 crgsg_cat.debug(false) << endl;
00441 #endif
00442 chromium.BlendFunc(sfunc, dfunc);
00443 }
00444 }
00445
00446
00447
00448
00449
00450
00451 INLINE void CRGraphicsStateGuardian::
00452 call_glFogMode(GLint mode) {
00453 if (_fog_mode != mode) {
00454 _fog_mode = mode;
00455 #ifdef GSG_VERBOSE
00456 crgsg_cat.debug() << "crFog(GL_FOG_MODE, ";
00457 switch(mode) {
00458 case GL_LINEAR:
00459 crgsg_cat.debug(false) << "GL_LINEAR)" << endl;
00460 break;
00461 case GL_EXP:
00462 crgsg_cat.debug(false) << "GL_EXP)" << endl;
00463 break;
00464 case GL_EXP2:
00465 crgsg_cat.debug(false) << "GL_EXP2)" << endl;
00466 break;
00467 #ifdef GL_FOG_FUNC_SGIS
00468 case GL_FOG_FUNC_SGIS:
00469 crgsg_cat.debug(false) << "GL_FOG_FUNC_SGIS)" << endl;
00470 break;
00471 #endif
00472 default:
00473 crgsg_cat.debug(false) << "unknown)" << endl;
00474 break;
00475 }
00476 #endif
00477 chromium.Fogi(GL_FOG_MODE, mode);
00478 }
00479 }
00480
00481
00482
00483
00484
00485
00486 INLINE void CRGraphicsStateGuardian::
00487 call_glFogStart(GLfloat start) {
00488 if (_fog_start != start) {
00489 _fog_start = start;
00490 #ifdef GSG_VERBOSE
00491 crgsg_cat.debug()
00492 << "crFog(GL_FOG_START, " << start << ")" << endl;
00493 #endif
00494 chromium.Fogf(GL_FOG_START, start);
00495 }
00496 }
00497
00498
00499
00500
00501
00502
00503 INLINE void CRGraphicsStateGuardian::
00504 call_glFogEnd(GLfloat end) {
00505 if (_fog_end != end) {
00506 _fog_end = end;
00507 #ifdef GSG_VERBOSE
00508 crgsg_cat.debug()
00509 << "crFog(GL_FOG_END, " << end << ")" << endl;
00510 #endif
00511 chromium.Fogf(GL_FOG_END, end);
00512 }
00513 }
00514
00515
00516
00517
00518
00519
00520 INLINE void CRGraphicsStateGuardian::
00521 call_glFogDensity(GLfloat density) {
00522 if (_fog_density != density) {
00523 _fog_density = density;
00524 #ifdef GSG_VERBOSE
00525 crgsg_cat.debug()
00526 << "crFog(GL_FOG_DENSITY, " << density << ")" << endl;
00527 #endif
00528 chromium.Fogf(GL_FOG_DENSITY, density);
00529 }
00530 }
00531
00532
00533
00534
00535
00536
00537 INLINE void CRGraphicsStateGuardian::
00538 call_glFogColor(const Colorf &color) {
00539 if (_fog_color != color) {
00540 _fog_color = color;
00541 #ifdef GSG_VERBOSE
00542 crgsg_cat.debug()
00543 << "crFog(GL_FOG_COLOR, " << color << ")" << endl;
00544 #endif
00545 chromium.Fogfv(GL_FOG_COLOR, color.get_data());
00546 }
00547 }
00548
00549
00550
00551
00552
00553
00554 INLINE void CRGraphicsStateGuardian::
00555 call_glAlphaFunc(GLenum func, GLclampf ref) {
00556 if (_alpha_func != func || _alpha_func_ref != ref) {
00557 _alpha_func = func;
00558 _alpha_func_ref = ref;
00559 #ifdef GSG_VERBOSE
00560 crgsg_cat.debug() << "crAlphaFunc(";
00561 switch (func) {
00562 case GL_NEVER:
00563 crgsg_cat.debug(false) << "GL_NEVER, ";
00564 break;
00565 case GL_LESS:
00566 crgsg_cat.debug(false) << "GL_LESS, ";
00567 break;
00568 case GL_EQUAL:
00569 crgsg_cat.debug(false) << "GL_EQUAL, ";
00570 break;
00571 case GL_LEQUAL:
00572 crgsg_cat.debug(false) << "GL_LEQUAL, ";
00573 break;
00574 case GL_GREATER:
00575 crgsg_cat.debug(false) << "GL_GREATER, ";
00576 break;
00577 case GL_NOTEQUAL:
00578 crgsg_cat.debug(false) << "GL_NOTEQUAL, ";
00579 break;
00580 case GL_GEQUAL:
00581 crgsg_cat.debug(false) << "GL_GEQUAL, ";
00582 break;
00583 case GL_ALWAYS:
00584 crgsg_cat.debug(false) << "GL_ALWAYS, ";
00585 break;
00586 }
00587 crgsg_cat.debug() << ref << ")" << endl;
00588 #endif
00589 chromium.AlphaFunc(func, ref);
00590 }
00591 }
00592
00593
00594
00595
00596
00597
00598 INLINE void CRGraphicsStateGuardian::
00599 call_glPolygonMode(GLenum mode) {
00600 if (_polygon_mode != mode) {
00601 _polygon_mode = mode;
00602 #ifdef GSG_VERBOSE
00603 crgsg_cat.debug() << "crPolygonMode(GL_BACK_AND_FRONT, ";
00604 switch (mode) {
00605 case GL_POINT:
00606 crgsg_cat.debug(false) << "GL_POINT)" << endl;
00607 break;
00608 case GL_LINE:
00609 crgsg_cat.debug(false) << "GL_LINE)" << endl;
00610 break;
00611 case GL_FILL:
00612 crgsg_cat.debug(false) << "GL_FILL)" << endl;
00613 break;
00614 }
00615 #endif
00616 chromium.PolygonMode(GL_FRONT_AND_BACK, mode);
00617 }
00618 }
00619
00620
00621
00622
00623
00624
00625 INLINE void CRGraphicsStateGuardian::
00626 set_pack_alignment(GLint alignment) {
00627 if (_pack_alignment != alignment) {
00628 chromium.PixelStorei(GL_PACK_ALIGNMENT, alignment);
00629 _pack_alignment = alignment;
00630 }
00631 }
00632
00633
00634
00635
00636
00637
00638 INLINE void CRGraphicsStateGuardian::
00639 set_unpack_alignment(GLint alignment) {
00640 if (_unpack_alignment != alignment) {
00641 chromium.PixelStorei(GL_UNPACK_ALIGNMENT, alignment);
00642 _unpack_alignment = alignment;
00643 }
00644 }
00645
00646
00647
00648
00649
00650
00651 INLINE void CRGraphicsStateGuardian::
00652 enable_multisample(bool val) {
00653 if (_multisample_enabled != val) {
00654 _multisample_enabled = val;
00655 if (val) {
00656 #ifdef GL_MULTISAMPLE_SGIS
00657 chromium.Enable(GL_MULTISAMPLE_SGIS);
00658 #endif
00659 chromium.Hint(GL_POINT_SMOOTH_HINT, GL_NICEST);
00660 } else {
00661 #ifdef GL_MULTISAMPLE_SGIS
00662 chromium.Disable(GL_MULTISAMPLE_SGIS);
00663 #endif
00664 chromium.Hint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
00665 }
00666 }
00667 }
00668
00669
00670
00671
00672
00673
00674 INLINE void CRGraphicsStateGuardian::
00675 enable_line_smooth(bool val) {
00676 if (_line_smooth_enabled != val) {
00677 _line_smooth_enabled = val;
00678 if (val) {
00679 chromium.Enable(GL_LINE_SMOOTH);
00680 chromium.Hint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
00681 } else {
00682 chromium.Disable(GL_LINE_SMOOTH);
00683 }
00684 }
00685 }
00686
00687
00688
00689
00690
00691
00692 INLINE void CRGraphicsStateGuardian::
00693 enable_point_smooth(bool val) {
00694 if (_point_smooth_enabled != val) {
00695 _point_smooth_enabled = val;
00696 if (val) {
00697 chromium.Enable(GL_POINT_SMOOTH);
00698 chromium.Hint(GL_POINT_SMOOTH_HINT, GL_NICEST);
00699 } else {
00700 chromium.Disable(GL_POINT_SMOOTH);
00701 chromium.Hint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
00702 }
00703 }
00704 }
00705
00706
00707
00708
00709
00710
00711 INLINE void CRGraphicsStateGuardian::
00712 enable_dither(bool val) {
00713 if (_dither_enabled != val) {
00714 _dither_enabled = val;
00715 if (val) {
00716 #ifdef GSG_VERBOSE
00717 crgsg_cat.debug()
00718 << "crEnable(GL_DITHER)" << endl;
00719 #endif
00720 chromium.Enable(GL_DITHER);
00721 } else {
00722 #ifdef GSG_VERBOSE
00723 crgsg_cat.debug()
00724 << "crDisable(GL_DITHER)" << endl;
00725 #endif
00726 chromium.Disable(GL_DITHER);
00727 }
00728 }
00729 }
00730
00731
00732
00733
00734
00735
00736 INLINE void CRGraphicsStateGuardian::
00737 enable_stencil_test(bool val) {
00738 if (_stencil_test_enabled != val) {
00739 _stencil_test_enabled = val;
00740 if (val) {
00741 #ifdef GSG_VERBOSE
00742 crgsg_cat.debug()
00743 << "crEnable(GL_STENCIL_TEST)" << endl;
00744 #endif
00745 chromium.Enable(GL_STENCIL_TEST);
00746 } else {
00747 #ifdef GSG_VERBOSE
00748 crgsg_cat.debug()
00749 << "crDisable(GL_STENCIL_TEST)" << endl;
00750 #endif
00751 chromium.Disable(GL_STENCIL_TEST);
00752 }
00753 }
00754 }
00755
00756
00757
00758
00759
00760
00761 INLINE void CRGraphicsStateGuardian::
00762 enable_texturing(bool val) {
00763 if (_texturing_enabled != val) {
00764 _texturing_enabled = val;
00765 if (val) {
00766 #ifdef GSG_VERBOSE
00767 crgsg_cat.debug()
00768 << "crEnable(GL_TEXTURE_2D)" << endl;
00769 #endif
00770 chromium.Enable(GL_TEXTURE_2D);
00771 } else {
00772 #ifdef GSG_VERBOSE
00773 crgsg_cat.debug()
00774 << "crDisable(GL_TEXTURE_2D)" << endl;
00775 #endif
00776 chromium.Disable(GL_TEXTURE_2D);
00777 }
00778 }
00779 }
00780
00781
00782
00783
00784
00785
00786 INLINE void CRGraphicsStateGuardian::
00787 enable_scissor(bool val)
00788 {
00789 if ( _scissor_enabled != val ) {
00790 _scissor_enabled = val;
00791 if ( val )
00792 chromium.Enable( GL_SCISSOR_TEST );
00793 else
00794 chromium.Disable( GL_SCISSOR_TEST );
00795 }
00796 }
00797
00798
00799
00800
00801
00802
00803 INLINE void CRGraphicsStateGuardian::
00804 enable_clip_plane(int clip_plane, bool val) {
00805 if (_clip_plane_enabled[clip_plane] != val) {
00806 _clip_plane_enabled[clip_plane] = val;
00807 if (val) {
00808 #ifdef GSG_VERBOSE
00809 crgsg_cat.debug()
00810 << "crEnable(GL_CLIP_PLANE_" << clip_plane << ")" << endl;
00811 #endif
00812 chromium.Enable(get_clip_plane_id(clip_plane));
00813 } else {
00814 #ifdef GSG_VERBOSE
00815 crgsg_cat.debug()
00816 << "crDisable(GL_CLIP_PLANE_" << clip_plane << ")" << endl;
00817 #endif
00818 chromium.Disable(get_clip_plane_id(clip_plane));
00819 }
00820 }
00821 }
00822
00823
00824
00825
00826
00827
00828 INLINE void CRGraphicsStateGuardian::
00829 enable_multisample_alpha_one(bool val) {
00830 if (_multisample_alpha_one_enabled != val) {
00831 _multisample_alpha_one_enabled = val;
00832 #ifdef GL_SAMPLE_ALPHA_TO_ONE_SGIS
00833 if (val) {
00834 #ifdef GSG_VERBOSE
00835 crgsg_cat.debug()
00836 << "crEnable(GL_SAMPLE_ALPHA_TO_ONE_SGIS)" << endl;
00837 #endif
00838 chromium.Enable(GL_SAMPLE_ALPHA_TO_ONE_SGIS);
00839 } else {
00840 #ifdef GSG_VERBOSE
00841 crgsg_cat.debug()
00842 << "crDisable(GL_SAMPLE_ALPHA_TO_ONE_SGIS)" << endl;
00843 #endif
00844 chromium.Disable(GL_SAMPLE_ALPHA_TO_ONE_SGIS);
00845 }
00846 #endif // GL_SAMPLE_ALPHA_TO_ONE_SGIS
00847 }
00848 }
00849
00850
00851
00852
00853
00854
00855 INLINE void CRGraphicsStateGuardian::
00856 enable_multisample_alpha_mask(bool val) {
00857 if (_multisample_alpha_mask_enabled != val) {
00858 _multisample_alpha_mask_enabled = val;
00859 #ifdef GL_SAMPLE_ALPHA_TO_MASK_SGIS
00860 if (val) {
00861 #ifdef GSG_VERBOSE
00862 crgsg_cat.debug()
00863 << "crEnable(GL_SAMPLE_ALPHA_TO_MASK_SGIS)" << endl;
00864 #endif
00865 chromium.Enable(GL_SAMPLE_ALPHA_TO_MASK_SGIS);
00866 } else {
00867 #ifdef GSG_VERBOSE
00868 crgsg_cat.debug()
00869 << "crDisable(GL_SAMPLE_ALPHA_TO_MASK_SGIS)" << endl;
00870 #endif
00871 chromium.Disable(GL_SAMPLE_ALPHA_TO_MASK_SGIS);
00872 }
00873 #endif // GL_SAMPLE_ALPHA_TO_MASK_SGIS
00874 }
00875 }
00876
00877
00878
00879
00880
00881
00882 INLINE void CRGraphicsStateGuardian::
00883 enable_blend(bool val) {
00884 if (_blend_enabled != val) {
00885 _blend_enabled = val;
00886 if (val) {
00887 #ifdef GSG_VERBOSE
00888 crgsg_cat.debug()
00889 << "crEnable(GL_BLEND)" << endl;
00890 #endif
00891 chromium.Enable(GL_BLEND);
00892 } else {
00893 #ifdef GSG_VERBOSE
00894 crgsg_cat.debug()
00895 << "crDisable(GL_BLEND)" << endl;
00896 #endif
00897 chromium.Disable(GL_BLEND);
00898 }
00899 }
00900 }
00901
00902
00903
00904
00905
00906
00907 INLINE void CRGraphicsStateGuardian::
00908 enable_depth_test(bool val) {
00909 if (_depth_test_enabled != val) {
00910 _depth_test_enabled = val;
00911 if (val) {
00912 #ifdef GSG_VERBOSE
00913 crgsg_cat.debug()
00914 << "crEnable(GL_DEPTH_TEST)" << endl;
00915 #endif
00916 chromium.Enable(GL_DEPTH_TEST);
00917 } else {
00918 #ifdef GSG_VERBOSE
00919 crgsg_cat.debug()
00920 << "crDisable(GL_DEPTH_TEST)" << endl;
00921 #endif
00922 chromium.Disable(GL_DEPTH_TEST);
00923 }
00924 }
00925 }
00926
00927
00928
00929
00930
00931
00932 INLINE void CRGraphicsStateGuardian::
00933 enable_fog(bool val) {
00934 if (_fog_enabled != val) {
00935 _fog_enabled = val;
00936 if (val) {
00937 #ifdef GSG_VERBOSE
00938 crgsg_cat.debug()
00939 << "crEnable(GL_FOG)" << endl;
00940 #endif
00941 chromium.Enable(GL_FOG);
00942 } else {
00943 #ifdef GSG_VERBOSE
00944 crgsg_cat.debug()
00945 << "crDisable(GL_FOG)" << endl;
00946 #endif
00947 chromium.Disable(GL_FOG);
00948 }
00949 }
00950 }
00951
00952
00953
00954
00955
00956
00957 INLINE void CRGraphicsStateGuardian::
00958 enable_alpha_test(bool val) {
00959 if (_alpha_test_enabled != val) {
00960 _alpha_test_enabled = val;
00961 if (val) {
00962 #ifdef GSG_VERBOSE
00963 crgsg_cat.debug()
00964 << "crEnable(GL_ALPHA_TEST)" << endl;
00965 #endif
00966 chromium.Enable(GL_ALPHA_TEST);
00967 } else {
00968 #ifdef GSG_VERBOSE
00969 crgsg_cat.debug()
00970 << "crDisable(GL_ALPHA_TEST)" << endl;
00971 #endif
00972 chromium.Disable(GL_ALPHA_TEST);
00973 }
00974 }
00975 }
00976
00977
00978
00979
00980
00981
00982
00983 INLINE void CRGraphicsStateGuardian::
00984 enable_polygon_offset(bool val) {
00985 if (_polygon_offset_enabled != val) {
00986 _polygon_offset_enabled = val;
00987 if (val) {
00988 #ifdef GSG_VERBOSE
00989 crgsg_cat.debug()
00990 << "crEnable(GL_POLYGON_OFFSET_*)" << endl;
00991 #endif
00992 chromium.Enable(GL_POLYGON_OFFSET_FILL);
00993 } else {
00994 #ifdef GSG_VERBOSE
00995 crgsg_cat.debug()
00996 << "crDisable(GL_POLYGON_OFFSET_*)" << endl;
00997 #endif
00998 chromium.Disable(GL_POLYGON_OFFSET_FILL);
00999 }
01000 }
01001 }
01002
01003
01004
01005
01006
01007
01008 INLINE const LMatrix4f &CRGraphicsStateGuardian::
01009 get_current_color_mat() const {
01010 return _current_color_mat;
01011 }
01012
01013
01014
01015
01016
01017
01018 INLINE const float &CRGraphicsStateGuardian::
01019 get_current_alpha_offset() const {
01020 return _current_alpha_offset;
01021 }
01022
01023
01024
01025
01026
01027
01028 INLINE const float &CRGraphicsStateGuardian::
01029 get_current_alpha_scale() const {
01030 return _current_alpha_scale;
01031 }
01032
01033
01034
01035
01036
01037
01038 INLINE GLenum CRGraphicsStateGuardian::get_light_id(int index) const
01039 {
01040 return GL_LIGHT0 + index;
01041 }
01042
01043
01044
01045
01046
01047
01048 INLINE GLenum CRGraphicsStateGuardian::
01049 get_clip_plane_id(int index) const {
01050 switch(index) {
01051 case 0: return GL_CLIP_PLANE0;
01052 case 1: return GL_CLIP_PLANE1;
01053 case 2: return GL_CLIP_PLANE2;
01054 case 3: return GL_CLIP_PLANE3;
01055 case 4: return GL_CLIP_PLANE4;
01056 case 5: return GL_CLIP_PLANE5;
01057 default:
01058 crgsg_cat.error()
01059 << "get_clip_plane_id() - we don't currently support ids "
01060 << "> 5" << endl;
01061 break;
01062 }
01063 return GL_CLIP_PLANE0;
01064 }
01065
01066
01067
01068
01069
01070
01071
01072
01073 INLINE void CRGraphicsStateGuardian::
01074 issue_scene_graph_color() {
01075 if (_scene_graph_color_stale) {
01076 issue_transformed_color(_scene_graph_color);
01077 _scene_graph_color_stale = false;
01078 }
01079 }
01080
01081
01082
01083
01084
01085
01086
01087
01088 INLINE void
01089 report_errors() {
01090
01091 #ifndef NDEBUG
01092 extern void report_errors_loop(GLenum error_code);
01093
01094 GLenum error_code = chromium.GetError();
01095 if (error_code != GL_NO_ERROR) {
01096 report_errors_loop(error_code);
01097 }
01098 #endif
01099 }