Back to index

nux  3.0.0
GLRenderStates.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef GLRENDERSTATES_H
00024 #define GLRENDERSTATES_H
00025 
00026 #include "NuxCore/NuxCore.h"
00027 #include "GpuDevice.h"
00028 
00029 namespace nux
00030 {
00031 
00032   enum
00033   {
00034     GFXRS_FRONT_POLYGONMODE,                                    // GL_FILL
00035     GFXRS_BACK_POLYGONMODE,                                     // GL_FILL
00036     GFXRS_CULLFACEENABLE,                                       // GL_FALSE
00037     GFXRS_CULLFACE,                                             // GL_BACK
00038     GFXRS_FRONTFACE,                                            // GL_CCW
00039 
00040     GFXRS_SCISSORTESTENABLE,                                    // GL_FALSE
00041     GFXRS_FOGENABLE,                                            // GL_FALSE
00042 
00043     GFXRS_ZTESTENABLE,                                          // GL_TRUE
00044     GFXRS_ZWRITEENABLE,                                         // GL_TRUE
00045     GFXRS_ZFUNC,                                                // GL_LESS
00046     GFXRS_ZNEAR,                                                // 0.0f
00047     GFXRS_ZFAR,                                                 // 1.0f
00048 
00049     GFXRS_ALPHABLENDENABLE,                                     // GL_FALSE
00050     GFXRS_BLENDOP,                                              // GL_FUNC_ADD
00051     GFXRS_BLENDOPALPHA,                                         // GL_FUNC_ADD
00052     GFXRS_SRCBLEND,                                             // GL_ONE
00053     GFXRS_DESTBLEND,                                            // GL_ZERO
00054     GFXRS_SRCBLENDALPHA,                                        // GL_ONE
00055     GFXRS_DESTBLENDALPHA,                                       // GL_ZERO
00056 
00057     GFXRS_ALPHATESTENABLE,                                      // GL_FALSE
00058     GFXRS_ALPHATESTREF,                                         // 0x0
00059     GFXRS_ALPHATESTFUNC,                                        // GL_ALWAYS
00060 
00061     GFXRS_STENCILENABLE,                                        // GL_FALSE
00062     GFXRS_TWOSIDEDSTENCILENABLE,                                // GL_FALSE
00063     GFXRS_FRONT_STENCILWRITEMASK,                               // 0xFFFFFFFF
00064     GFXRS_BACK_STENCILWRITEMASK,                                // 0xFFFFFFFF
00065 
00066     GFXRS_FRONT_STENCILFUNC,                                    // GL_ALWAYS
00067     GFXRS_FRONT_STENCILREF,                                     // 0x0
00068     GFXRS_FRONT_STENCILMASK,                                    // 0xFF
00069     GFXRS_FRONT_STENCILFAIL,                                    // GL_KEEP
00070     GFXRS_FRONT_STENCILZFAIL,                                   // GL_KEEP
00071     GFXRS_FRONT_STENCILZPASS,                                   // GL_KEEP
00072 
00073     GFXRS_BACK_STENCILFUNC,                                     // GL_ALWAYS
00074     GFXRS_BACK_STENCILREF,                                      // 0x0
00075     GFXRS_BACK_STENCILMASK,                                     // 0xFF
00076     GFXRS_BACK_STENCILFAIL,                                     // GL_KEEP
00077     GFXRS_BACK_STENCILZFAIL,                                    // GL_KEEP
00078     GFXRS_BACK_STENCILZPASS,                                    // GL_KEEP
00079 
00080 
00081     GFXRS_POINTSMOOTHENABLE,                                    // GL_FLASE
00082     GFXRS_LINESMOOTHENABLE,                                     // GL_FALSE
00083     GFXRS_POINTSIZE,                                            // 1.0f
00084     GFXRS_LINEWIDTH,                                            // 1.0f
00085     GFXRS_POINTHINT,                                            // GL_FASTEST
00086     GFXRS_LINEHINT,                                             // GL_FASTEST
00087 
00088     GFXRS_COLORWRITEENABLE_R,                                   // TRUE or FALSE
00089     GFXRS_COLORWRITEENABLE_G,                                   // TRUE or FALSE
00090     GFXRS_COLORWRITEENABLE_B,                                   // TRUE or FALSE
00091     GFXRS_COLORWRITEENABLE_A,                                   // TRUE or FALSE
00092 
00093     GFXRS_POLYGONOFFSETENABLE,                                  // GL_FALSE
00094     GFXRS_POLYGONOFFSETFACTOR,                                  // 0.0f
00095     GFXRS_POLYGONOFFSETUNITS,                                   // 0.0f
00096 
00097     GFXRS_MAX_RENDERSTATES,
00098   };
00099 
00100   enum
00101   {
00102     GFXSS_ADDRESSU,
00103     GFXSS_ADDRESSV,
00104     GFXSS_ADDRESSW,
00105     GFXSS_MINFILTER,
00106     GFXSS_MAGFILTER,
00107     GFXSS_MIPMAPFILTER,
00108     GFXSS_MIPMAPLODBIAS,
00109     GFXSS_MAXANISOTROPY,
00110     GFXSS_SRGBWRITEENABLE,
00111 
00112     GFXSS_MAX_SAMPLERSTATES,
00113   };
00114 
00115   typedef enum
00116   {
00117     CLEAR = 0,
00118     SRC,
00119     DST,
00120     SRC_OVER,
00121     DST_OVER,
00122     SRC_IN,
00123     DST_IN,
00124     SRC_OUT,
00125     DST_OUT,
00126     SRC_ATOP,
00127     DST_ATOP,
00128     XOR,
00129     PLUS
00130   } PorterDuffOperator;
00131 
00132   struct RenderStateMap
00133   {
00134     unsigned int   Checked;
00135     unsigned int    State;
00136     unsigned int    iValue;
00137     float   fValue;
00138   };
00139 
00140   class GpuRenderStates
00141   {
00142   public:
00143     GpuRenderStates(GpuBrand board, GpuInfo* info);
00144     ~GpuRenderStates();
00145 
00146     void ResetDefault();
00147     void ResetStateChangeToDefault();
00148     void CommitStateChangeToDefault();
00149     void CheckStateChange();
00150 
00151     void SubmitChangeStates();
00153     void CheckRenderStatesConformity();
00154 
00155     // Render states
00156     inline void SetAlphaTest(
00157       bool EnableAlphaTest_,
00158       unsigned int AlphaTestFunc_    = GL_ALWAYS,
00159       BYTE  AlphaTestRef_     = 0);
00160 
00161     inline void SetBlend(bool AlphaBlendEnable_);
00162     inline void SetBlend(bool AlphaBlendEnable_,
00163                           unsigned int SrcBlendFactor_   /*= GL_ONE*/,
00164                           unsigned int DestBlendFactor_  /*= GL_ZERO*/);
00165 
00166     inline void GetBlend(unsigned int& AlphaBlendEnable_,
00167                       unsigned int& SrcBlendFactor_,
00168                       unsigned int& DestBlendFactor_);
00169     
00170     inline void SetSeparateBlend(bool _bEnable,
00171                                   unsigned int SrcBlendFactor_   /*= GL_ONE*/,
00172                                   unsigned int DestBlendFactor_  /*= GL_ZERO*/,
00173                                   unsigned int SrcFactorAlpha_   /*= GL_ONE*/,
00174                                   unsigned int DestFactorAlpha_  /*= GL_ZERO*/);
00175 
00176     inline void SetPremultipliedBlend(PorterDuffOperator op);
00177 
00178     inline void SetBlendOp(
00179       unsigned int BlendOp       = GL_FUNC_ADD);
00180 
00181     inline void SetSeparateBlendOp(
00182       unsigned int BlendOpRGB_       = GL_FUNC_ADD,
00183       unsigned int BlendOpAlpha_     = GL_FUNC_ADD);
00184 
00185     inline void SetCullMode(bool EnableCullFace,
00186                              unsigned int FrontFace_        = GL_CCW,
00187                              unsigned int Cullface_         = GL_BACK);
00188 
00189     inline void SetDepthTest(bool EnableDepthTest,
00190                               unsigned int WriteEnable_      = GL_TRUE,
00191                               unsigned int DepthFunc_        = GL_LEQUAL);
00192 
00193     inline void SetDepthRange(
00194       float zNear = 0.0f,
00195       float zFar = 1.0f);
00196 
00197 
00198     inline void SetStencil(bool enable_stencil);
00199     inline void SetStencilFunc(unsigned int func, int ref, unsigned int mask);
00200     inline void SetStencilOp(unsigned int stencil_fail, unsigned int stencil_pass_depth_fail, unsigned int stencil_pass_depth_pass);
00201 
00202 #if 0
00203     // If two sided stencil is not activated, the setting is also used for the back face.
00204     inline void SetStencilFrontFace(
00205       bool EnableStencil_,                            // GL_TRUE enable stencil test
00206       unsigned int Func_             = GL_ALWAYS,
00207       unsigned int FailOp_           = GL_KEEP,
00208       unsigned int ZFailOp_          = GL_KEEP,
00209       unsigned int ZPassOp_          = GL_KEEP,
00210       unsigned int Ref_              = 0,
00211       unsigned int Mask_             = 0xffffffff);
00212 
00213     // Set stencil test for the back face.
00214     inline void SetStencilBackFace(
00215       bool EnableTwoSideStencil_,                     // GL_TRUE enable Two Sided Stencil test
00216       unsigned int Func_             = GL_ALWAYS,
00217       unsigned int FailOp_           = GL_KEEP,
00218       unsigned int ZFailOp_          = GL_KEEP,
00219       unsigned int ZPassOp_          = GL_KEEP,
00220       unsigned int Ref_              = 0,
00221       unsigned int Mask_             = 0xffffffff);
00222 
00223     inline void SetFrontFaceStencilWriteMask(
00224       unsigned int WriteMask_        = 0xffffffff);
00225 
00226     inline void SetBackFaceStencilWriteMask(
00227       unsigned int WriteMask_        = 0xffffffff);
00228 #endif
00229 
00230     inline void EnableLineSmooth(
00231       bool EnableLineSmooth = TRUE,
00232       unsigned int  LineWidth = 1,
00233       unsigned int HINT = GL_FASTEST);
00234 
00235     inline void EnablePointSmooth(
00236       bool EnablePointSmooth = TRUE,
00237       unsigned int  PointSize = 1,
00238       unsigned int HINT = GL_FASTEST);
00239 
00240     inline void SetColorMask(
00241       unsigned int bRed      = TRUE,
00242       unsigned int bGreen    = TRUE,
00243       unsigned int bBlue     = TRUE,
00244       unsigned int bAlpha    = TRUE);
00245 
00246     inline void GetColorMask(
00247       unsigned int& bRed,
00248       unsigned int& bGreen,
00249       unsigned int& bBlue,
00250       unsigned int& bAlpha);
00251     
00252     inline void SetDepthMask(unsigned int bDepth = TRUE);
00253 
00254     inline void EnableScissor(unsigned int bScissor = FALSE);
00255     inline void EnableFog(unsigned int bFog = FALSE);
00256 #ifndef NUX_OPENGLES_20
00257     inline void SetPolygonMode(unsigned int FrontMode = GL_FILL, unsigned int BackMode = GL_FILL);
00258 #else
00259     inline void SetPolygonMode(unsigned int FrontMode, unsigned int BackMode);
00260 #endif
00261 
00262     inline void SetPolygonOffset(unsigned int bEnable,
00263                                   float Factor = 0.0f, float Units = 0.0f);
00264 
00265   private:
00266 
00267     GpuBrand _gpu_brand;
00268     GpuInfo *_gpu_info;
00269 
00270     inline void HW__EnableAlphaTest(unsigned int b);
00271 
00272     inline void HW__SetAlphaTestFunc(
00273       unsigned int AlphaTestFunc_,
00274       BYTE  AlphaTestRef_);
00275 
00276     inline void HW__EnableAlphaBlend(unsigned int b);
00277 
00278     inline void HW__SetSeparateAlphaBlend_Enable(unsigned int b);
00279 
00280     inline void HW__SetSeparateAlphaBlendFactors(
00281       unsigned int SrcBlendFactor_,
00282       unsigned int DestBlendFactor_,
00283       unsigned int SrcFactorAlpha_,
00284       unsigned int DestFactorAlpha_);
00285 
00286     inline void HW__SetAlphaBlendOp(unsigned int BlendOpRGB_,
00287                                      unsigned int BlendOpAlpha_);
00288 
00289     inline void HW__EnableCulling(unsigned int b);
00290 
00291     inline void HW__SetFrontFace(unsigned int FrontFace_);
00292 
00293     inline void HW__SetCullFace(unsigned int CullFace_);
00294 
00295     inline void HW__SetEnableDepthTest(unsigned int b);
00296     inline void HW__SetDepthFunc(unsigned int Func);
00297     inline void HW__SetDepthRange(float zNear, float zFar);
00298 
00299 
00300     inline void HW__EnableStencil(unsigned int b);
00301     inline void HW__SetStencilOp(unsigned int FailOp_, unsigned int ZFailOp_, unsigned int ZPassOp_);
00302     inline void HW__SetStencilFunc(unsigned int func, int ref, unsigned int mask);
00303 
00304 #if 0
00305     inline void HW__EnableTwoSidedStencil(unsigned int b);
00306     inline void HW__SetStencilFrontFaceWriteMask(unsigned int WriteMask_);
00307     inline void HW__SetStencilBackFaceWriteMask(unsigned int WriteMask_);
00308 
00309     inline void HW__SetFrontFaceStencilFunc(unsigned int Func_,
00310         unsigned int Ref_,
00311         unsigned int Mask_);
00312 
00313     inline void HW__SetBackFaceStencilFunc(
00314       unsigned int Func_,
00315       unsigned int Ref_,
00316       unsigned int Mask_);
00317 
00318     inline void HW__SetFrontFaceStencilOp(
00319       unsigned int FailOp_,
00320       unsigned int ZFailOp_,
00321       unsigned int ZPassOp_);
00322 
00323     inline void HW__SetBackFaceStencilOp(
00324       unsigned int FailOp_,
00325       unsigned int ZFailOp_,
00326       unsigned int ZPassOp_);
00327 #endif
00328 
00329     inline void HW__EnableLineSmooth(unsigned int EnableLineSmooth);
00330     inline void HW__SetLineWidth(unsigned int width, unsigned int HINT);
00331 
00332     inline void HW__EnablePointSmooth(unsigned int EnablePointSmooth);
00333     inline void HW__SetPointSize(unsigned int size, unsigned int HINT);
00334 
00335     inline void HW__SetColorMask(unsigned int bRed, unsigned int bGreen, unsigned int bBlue, unsigned int bAlpha);
00336     inline void HW__SetDepthMask(unsigned int bDepth);
00337 
00338     inline void HW__EnableScissor(unsigned int bScissor);
00339     inline void HW__EnableFog(unsigned int bFog);
00340 
00341     inline void HW__SetPolygonMode(unsigned int FrontMode, unsigned int BackMode);
00342     inline void HW__EnablePolygonOffset(unsigned int EnablePolygonOffset);
00343     inline void HW__SetPolygonOffset(float Factor, float Units);
00344 
00345   private:
00346     RenderStateMap render_state_changes_[GFXRS_MAX_RENDERSTATES];
00347     RenderStateMap sampler_state_changes_[4][GFXSS_MAX_SAMPLERSTATES];
00348   };
00349 
00350 
00351 
00352 #define SET_RS_VALUE(a, b)  (a).iValue = (b)
00353 #define RS_VALUE(a)      (a).iValue
00354 
00355 //#define SET_RS_VALUE_FLOAT(a, b)  (a).fValue = (b)
00356 //#define RS_VALUE_FLOAT(a, b)      (a).fValue
00357 
00358 
00359   inline void GpuRenderStates::SetAlphaTest(
00360     bool EnableAlphaTest_,
00361     unsigned int AlphaTestFunc_,
00362     BYTE AlphaTestRef_)
00363   {
00364     if (EnableAlphaTest_)
00365     {
00366       if (!RS_VALUE(render_state_changes_[GFXRS_ALPHATESTENABLE]))
00367       {
00368         HW__EnableAlphaTest(TRUE);
00369       }
00370 
00371       if ((RS_VALUE(render_state_changes_[GFXRS_ALPHATESTFUNC]) != AlphaTestFunc_) ||
00372            (RS_VALUE(render_state_changes_[GFXRS_ALPHATESTREF]) != AlphaTestRef_))
00373       {
00374         HW__SetAlphaTestFunc(AlphaTestFunc_, AlphaTestRef_);
00375       }
00376     }
00377     else
00378     {
00379       HW__EnableAlphaTest(GL_FALSE);
00380       HW__SetAlphaTestFunc(AlphaTestFunc_, AlphaTestRef_);
00381     }
00382   }
00383 
00384   inline void GpuRenderStates::SetBlend(bool AlphaBlendEnable_)
00385   {
00386     if (AlphaBlendEnable_)
00387     {
00388       if (!RS_VALUE(render_state_changes_[GFXRS_ALPHABLENDENABLE]))
00389       {
00390         HW__EnableAlphaBlend(TRUE);
00391       }
00392     }
00393     else
00394     {
00395       if (RS_VALUE(render_state_changes_[GFXRS_ALPHABLENDENABLE]))
00396       {
00397         HW__EnableAlphaBlend(GL_FALSE);
00398       }
00399     }
00400   }
00401 
00402   inline void GpuRenderStates::SetBlend(bool AlphaBlendEnable_,
00403                                         unsigned int SrcBlendFactor_,
00404                                         unsigned int DestBlendFactor_)
00405   {
00406     SetBlend(AlphaBlendEnable_);
00407 
00408     if ((RS_VALUE(render_state_changes_[GFXRS_SRCBLEND]) != SrcBlendFactor_) ||
00409          (RS_VALUE(render_state_changes_[GFXRS_DESTBLEND]) != DestBlendFactor_))
00410     {
00411       HW__SetSeparateAlphaBlendFactors(
00412         SrcBlendFactor_,
00413         DestBlendFactor_,
00414         SrcBlendFactor_,
00415         DestBlendFactor_);
00416     }
00417   }
00418 
00419   inline void GpuRenderStates::GetBlend(unsigned int& AlphaBlendEnable_,
00420                     unsigned int& SrcBlendFactor_,
00421                     unsigned int& DestBlendFactor_)
00422   {
00423     AlphaBlendEnable_ = RS_VALUE(render_state_changes_[GFXRS_ALPHABLENDENABLE]);
00424     SrcBlendFactor_   = RS_VALUE(render_state_changes_[GFXRS_SRCBLEND]);
00425     DestBlendFactor_  = RS_VALUE(render_state_changes_[GFXRS_DESTBLEND]);
00426   }
00427     
00428   inline void GpuRenderStates::SetSeparateBlend(bool EnableSeparateAlphaBlend,
00429       unsigned int SrcBlendFactor_,
00430       unsigned int DestBlendFactor_,
00431       unsigned int SrcBlendFactorAlpha_,
00432       unsigned int DestBlendFactorAlpha_)
00433   {
00434     SetBlend(EnableSeparateAlphaBlend);
00435 
00436 //     if (EnableSeparateAlphaBlend)
00437 //     {
00438 //         if (!RS_VALUE(render_state_changes_[GFXRS_ALPHABLENDENABLE]))
00439 //         {
00440 //             HW__EnableAlphaBlend(TRUE);
00441 //         }
00442 
00443     if ((RS_VALUE(render_state_changes_[GFXRS_SRCBLEND]) != SrcBlendFactor_) ||
00444          (RS_VALUE(render_state_changes_[GFXRS_DESTBLEND]) != DestBlendFactor_) ||
00445          (RS_VALUE(render_state_changes_[GFXRS_SRCBLENDALPHA]) != SrcBlendFactorAlpha_) ||
00446          (RS_VALUE(render_state_changes_[GFXRS_DESTBLENDALPHA]) != DestBlendFactorAlpha_))
00447     {
00448       HW__SetSeparateAlphaBlendFactors(
00449         SrcBlendFactor_,
00450         DestBlendFactor_,
00451         SrcBlendFactorAlpha_,
00452         DestBlendFactorAlpha_);
00453     }
00454 
00455 //     }
00456 //     else
00457 //     {
00458 //         HW__EnableAlphaBlend(GL_FALSE);
00459 //         HW__SetSeparateAlphaBlendFactors(
00460 //             SrcBlendFactor_,
00461 //             DestBlendFactor_,
00462 //             SrcBlendFactorAlpha_,
00463 //             DestBlendFactorAlpha_);
00464 //     }
00465   }
00466 
00467   inline void GpuRenderStates::SetPremultipliedBlend(PorterDuffOperator op)
00468   {
00469     static const struct
00470     {
00471       const unsigned int src_blend;
00472       const unsigned int dst_blend;
00473     } factor[13] =
00474     {
00475       { GL_ZERO,                GL_ZERO                }, // CLEAR
00476       { GL_ONE,                 GL_ZERO                }, // SRC
00477       { GL_ZERO,                GL_ONE                 }, // DST
00478       { GL_ONE,                 GL_ONE_MINUS_SRC_ALPHA }, // SRC_OVER
00479       { GL_ONE_MINUS_DST_ALPHA, GL_ONE                 }, // DST_OVER
00480       { GL_DST_ALPHA,           GL_ZERO                }, // SRC_IN
00481       { GL_ZERO,                GL_SRC_ALPHA           }, // DST_IN
00482       { GL_ONE_MINUS_DST_ALPHA, GL_ZERO                }, // SRC_OUT
00483       { GL_ZERO,                GL_ONE_MINUS_SRC_ALPHA }, // DST_OUT
00484       { GL_DST_ALPHA,           GL_ONE_MINUS_SRC_ALPHA }, // SRC_ATOP
00485       { GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA           }, // DST_ATOP
00486       { GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA }, // XOR
00487       { GL_ONE,                 GL_ONE                 }  // PLUS
00488     };
00489 
00490     if ((RS_VALUE(render_state_changes_[GFXRS_SRCBLEND]) !=
00491          factor[op].src_blend) ||
00492         (RS_VALUE(render_state_changes_[GFXRS_DESTBLEND]) !=
00493          factor[op].dst_blend))
00494     {
00495       HW__SetSeparateAlphaBlendFactors
00496         (factor[op].src_blend, factor[op].dst_blend,
00497          factor[op].src_blend, factor[op].dst_blend);
00498     }
00499   }
00500 
00501   inline void GpuRenderStates::SetBlendOp(unsigned int BlendOp)
00502   {
00503     if ((RS_VALUE(render_state_changes_[GFXRS_BLENDOP]) != BlendOp))
00504     {
00505       HW__SetAlphaBlendOp(BlendOp, BlendOp);
00506     }
00507   }
00508 
00509   inline void GpuRenderStates::SetSeparateBlendOp(
00510     unsigned int BlendOpRGB_,
00511     unsigned int BlendOpAlpha_)
00512   {
00513     if ((RS_VALUE(render_state_changes_[GFXRS_BLENDOP]) != BlendOpRGB_) ||
00514          (RS_VALUE(render_state_changes_[GFXRS_BLENDOPALPHA]) != BlendOpAlpha_))
00515     {
00516       HW__SetAlphaBlendOp(BlendOpRGB_, BlendOpAlpha_);
00517     }
00518   }
00519 
00520   inline void GpuRenderStates::SetCullMode(bool EnableCullFace,
00521       unsigned int FrontFace_,
00522       unsigned int Cullface_)
00523   {
00524     if (EnableCullFace)
00525     {
00526       if (!RS_VALUE(render_state_changes_[GFXRS_CULLFACEENABLE]))
00527       {
00528         HW__EnableCulling(TRUE);
00529       }
00530 
00531       if (RS_VALUE(render_state_changes_[GFXRS_FRONTFACE]) != FrontFace_)
00532       {
00533         HW__SetFrontFace(FrontFace_);
00534       }
00535 
00536       if (RS_VALUE(render_state_changes_[GFXRS_CULLFACE]) != Cullface_)
00537       {
00538         HW__SetCullFace(Cullface_);
00539       }
00540     }
00541     else
00542     {
00543       HW__EnableCulling(FALSE);
00544       HW__SetFrontFace(FrontFace_);
00545       HW__SetCullFace(Cullface_);
00546     }
00547   }
00548 
00549   inline void GpuRenderStates::SetDepthTest(bool EnableDepthTest,
00550       unsigned int WriteEnable_,
00551       unsigned int DepthFunc_)
00552   {
00553     if (EnableDepthTest)
00554     {
00555       if (!RS_VALUE(render_state_changes_[GFXRS_ZTESTENABLE]))
00556       {
00557         HW__SetEnableDepthTest(TRUE);
00558       }
00559 
00560       if (RS_VALUE(render_state_changes_[GFXRS_ZWRITEENABLE]) != WriteEnable_)
00561       {
00562         HW__SetDepthMask(WriteEnable_);
00563       }
00564 
00565       if (RS_VALUE(render_state_changes_[GFXRS_ZFUNC]) != DepthFunc_)
00566       {
00567         HW__SetDepthFunc(DepthFunc_);
00568       }
00569     }
00570     else
00571     {
00572       HW__SetEnableDepthTest(FALSE);
00573       HW__SetDepthMask(WriteEnable_);
00574       HW__SetDepthFunc(DepthFunc_);
00575     }
00576   }
00577 
00578   inline void GpuRenderStates::SetDepthRange(float zNear, float zFar)
00579   {
00580     if ((RS_VALUE(render_state_changes_[GFXRS_ZNEAR]) != static_cast<unsigned int> (zNear)) ||
00581          (RS_VALUE(render_state_changes_[GFXRS_ZFAR]) != static_cast<unsigned int> (zFar)))
00582     {
00583       HW__SetDepthRange(zNear, zFar);
00584     }
00585   }
00586 
00587   void GpuRenderStates::SetStencil(bool enable_stencil)
00588   {
00589     if (enable_stencil)
00590     {
00591       if (!RS_VALUE(render_state_changes_[GFXRS_STENCILENABLE]))
00592       {
00593         HW__EnableStencil(TRUE);
00594       }
00595     }
00596     else
00597     {
00598       HW__EnableStencil(FALSE);
00599     }
00600   }
00601 
00602   void GpuRenderStates::SetStencilFunc(unsigned int func, int ref, unsigned int mask)
00603   {
00604     if (
00605       (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFUNC]) != func) ||
00606       (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILREF]) != (unsigned int)ref) ||
00607       (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILMASK]) != mask)
00608       )
00609     {
00610       HW__SetStencilFunc(func, ref, mask);
00611     }
00612   }
00613 
00614   void GpuRenderStates::SetStencilOp(unsigned int stencil_fail, unsigned int stencil_pass_depth_fail, unsigned int stencil_pass_depth_pass)
00615   {
00616     if (
00617       (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFAIL]) != stencil_fail) ||
00618       (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZFAIL]) != stencil_pass_depth_fail) ||
00619       (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZPASS]) != stencil_pass_depth_pass)
00620       )
00621     {
00622       HW__SetStencilOp(stencil_fail, stencil_pass_depth_fail, stencil_pass_depth_pass);
00623     }
00624   }
00625 
00626 #if 0
00627   inline void GpuRenderStates::SetStencilFrontFace(
00628     bool EnableStencil_,                            // GL_TRUE enable stencil test
00629     unsigned int Func_,
00630     unsigned int FailOp_,
00631     unsigned int ZFailOp_,
00632     unsigned int ZPassOp_,
00633     unsigned int Ref_,
00634     unsigned int Mask_)
00635   {
00636     if (EnableStencil_)
00637     {
00638       if (!RS_VALUE(render_state_changes_[GFXRS_STENCILENABLE]))
00639       {
00640         HW__EnableStencil(TRUE);
00641       }
00642 
00643       if (
00644         (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFUNC]) != Func_) ||
00645         (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILREF]) != Ref_) ||
00646         (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILMASK]) != Mask_) ||
00647         (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFAIL]) != FailOp_) ||
00648         (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZFAIL]) != ZFailOp_) ||
00649         (RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZPASS]) != ZPassOp_)
00650       )
00651       {
00652         HW__SetFrontFaceStencilFunc(Func_, Ref_, Mask_);
00653         HW__SetFrontFaceStencilOp(FailOp_, ZFailOp_, ZPassOp_);
00654       }
00655     }
00656     else
00657     {
00658       HW__EnableStencil(FALSE);
00659       HW__SetFrontFaceStencilFunc(Func_, Ref_, Mask_);
00660       HW__SetFrontFaceStencilOp(FailOp_, ZFailOp_, ZPassOp_);
00661     }
00662   }
00663 
00664   inline void GpuRenderStates::SetStencilBackFace(
00665     bool EnableTwoSideStencil_,                     // GL_TRUE enable Two Sided Stencil test
00666     unsigned int Func_,
00667     unsigned int FailOp_,
00668     unsigned int ZFailOp_,
00669     unsigned int ZPassOp_,
00670     unsigned int Ref_,
00671     unsigned int Mask_)
00672   {
00673     if (EnableTwoSideStencil_)
00674     {
00675       if (!RS_VALUE(render_state_changes_[GFXRS_STENCILENABLE]))
00676       {
00677         HW__EnableStencil(TRUE);
00678       }
00679 
00680       if (!RS_VALUE(render_state_changes_[GFXRS_TWOSIDEDSTENCILENABLE]))
00681       {
00682         HW__EnableTwoSidedStencil(TRUE);
00683       }
00684 
00685       if (
00686         (RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILFUNC]) != Func_) ||
00687         (RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILREF]) != Ref_) ||
00688         (RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILMASK]) != Mask_) ||
00689         (RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILFAIL]) != FailOp_) ||
00690         (RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILZFAIL]) != ZFailOp_) ||
00691         (RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILZPASS]) != ZPassOp_)
00692       )
00693       {
00694         HW__SetBackFaceStencilFunc(Func_, Ref_, Mask_);
00695         HW__SetBackFaceStencilOp(FailOp_, ZFailOp_, ZPassOp_);
00696       }
00697     }
00698     else
00699     {
00700       HW__EnableTwoSidedStencil(FALSE);
00701       HW__SetBackFaceStencilFunc(Func_, Ref_, Mask_);
00702       HW__SetBackFaceStencilOp(FailOp_, ZFailOp_, ZPassOp_);
00703     }
00704   }
00705 
00706   inline void GpuRenderStates::SetFrontFaceStencilWriteMask(
00707     unsigned int WriteMask_)
00708   {
00709     HW__SetStencilFrontFaceWriteMask(WriteMask_);
00710   }
00711 
00712   inline void GpuRenderStates::SetBackFaceStencilWriteMask(
00713     unsigned int WriteMask_)
00714   {
00715     HW__SetStencilBackFaceWriteMask(WriteMask_);
00716   }
00717 #endif
00718 
00719   inline void GpuRenderStates::EnableLineSmooth(
00720     bool EnableLineSmooth,
00721     unsigned int  LineWidth,
00722     unsigned int Hint)
00723   {
00724     if (EnableLineSmooth)
00725     {
00726       if (!RS_VALUE(render_state_changes_[GFXRS_LINESMOOTHENABLE]))
00727       {
00728         HW__EnableLineSmooth(GL_TRUE);
00729       }
00730 
00731       if ((RS_VALUE(render_state_changes_[GFXRS_LINEWIDTH]) != LineWidth) ||
00732            (RS_VALUE(render_state_changes_[GFXRS_LINEHINT]) != Hint))
00733       {
00734         HW__SetLineWidth(LineWidth, Hint);
00735       }
00736     }
00737     else
00738     {
00739       HW__EnableLineSmooth(GL_FALSE);
00740       HW__SetLineWidth(LineWidth, Hint);
00741     }
00742   }
00743 
00744   inline void GpuRenderStates::EnablePointSmooth(
00745     bool EnablePointSmooth,
00746     unsigned int  PointSize,
00747     unsigned int Hint)
00748   {
00749     if (EnablePointSmooth)
00750     {
00751       if (!RS_VALUE(render_state_changes_[GFXRS_POINTSMOOTHENABLE]))
00752       {
00753         HW__EnablePointSmooth(GL_TRUE);
00754       }
00755 
00756       if ((RS_VALUE(render_state_changes_[GFXRS_POINTSIZE]) != PointSize) ||
00757            (RS_VALUE(render_state_changes_[GFXRS_POINTHINT]) != Hint))
00758       {
00759         HW__SetLineWidth(PointSize, Hint);
00760       }
00761     }
00762     else
00763     {
00764       HW__EnablePointSmooth(GL_FALSE);
00765       HW__SetLineWidth(PointSize, Hint);
00766     }
00767   }
00768 
00769   inline void GpuRenderStates::SetColorMask(
00770     unsigned int bRed,
00771     unsigned int bGreen,
00772     unsigned int bBlue,
00773     unsigned int bAlpha)
00774   {
00775     if ((RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_R]) != bRed) ||
00776          (RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_G]) != bGreen) ||
00777          (RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_B]) != bBlue) ||
00778          (RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_A]) != bAlpha))
00779     {
00780       HW__SetColorMask(bRed, bGreen, bBlue, bAlpha);
00781     }
00782 
00783   }
00784 
00785   inline void GpuRenderStates::GetColorMask(
00786     unsigned int& bRed,
00787     unsigned int& bGreen,
00788     unsigned int& bBlue,
00789     unsigned int& bAlpha)
00790   {
00791     bRed    = RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_R]);
00792     bGreen  = RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_G]);
00793     bBlue   = RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_B]);
00794     bAlpha  = RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_A]);
00795   }
00796   
00797   inline void GpuRenderStates::SetDepthMask(unsigned int bDepth)
00798   {
00799     if ((RS_VALUE(render_state_changes_[GFXRS_ZWRITEENABLE]) != bDepth))
00800     {
00801       HW__SetDepthMask(bDepth);
00802     }
00803   }
00804 
00805   inline void GpuRenderStates::EnableScissor(unsigned int bScissor)
00806   {
00807     if ((RS_VALUE(render_state_changes_[GFXRS_SCISSORTESTENABLE]) != bScissor))
00808     {
00809       HW__EnableScissor(bScissor);
00810     }
00811   }
00812 
00813   inline void GpuRenderStates::EnableFog(unsigned int bFog)
00814   {
00815     if ((RS_VALUE(render_state_changes_[GFXRS_FOGENABLE]) != bFog))
00816     {
00817       HW__EnableFog(bFog);
00818     }
00819   }
00820 
00821   inline void GpuRenderStates::SetPolygonMode(unsigned int FrontMode, unsigned int BackMode)
00822   {
00823     if ((RS_VALUE(render_state_changes_[GFXRS_FRONT_POLYGONMODE]) != FrontMode) ||
00824          (RS_VALUE(render_state_changes_[GFXRS_BACK_POLYGONMODE]) != BackMode))
00825     {
00826       HW__SetPolygonMode(FrontMode, BackMode);
00827     }
00828   }
00829 
00830   inline void GpuRenderStates::SetPolygonOffset(unsigned int bEnable,
00831       float Factor, float Units)
00832   {
00833     if (bEnable)
00834     {
00835       if (!RS_VALUE(render_state_changes_[GFXRS_POLYGONOFFSETENABLE]))
00836       {
00837         HW__EnablePolygonOffset(GL_TRUE);
00838       }
00839 
00840       if ((RS_VALUE(render_state_changes_[GFXRS_POLYGONOFFSETFACTOR]) != static_cast<unsigned int> (Factor)) ||
00841            (RS_VALUE(render_state_changes_[GFXRS_POLYGONOFFSETUNITS]) != static_cast<unsigned int> (Units)))
00842       {
00843         HW__SetPolygonOffset(Factor, Units);
00844       }
00845     }
00846     else
00847     {
00848       HW__EnablePolygonOffset(GL_FALSE);
00849     }
00850   }
00851 
00852 
00854   inline void GpuRenderStates::HW__EnableAlphaTest(unsigned int b)
00855   {
00856 #ifndef NUX_OPENGLES_20
00857     if (b)
00858     {
00859       CHECKGL(glEnable(GL_ALPHA_TEST));
00860     }
00861     else
00862     {
00863       CHECKGL(glDisable(GL_ALPHA_TEST));
00864     }
00865 
00866     SET_RS_VALUE(render_state_changes_[GFXRS_ALPHATESTENABLE], b ? GL_TRUE : GL_FALSE);
00867 #endif
00868   }
00869 
00870   inline void GpuRenderStates::HW__SetAlphaTestFunc(unsigned int AlphaTestFunc_,
00871       BYTE  AlphaTestRef_)
00872   {
00873 #ifndef NUX_OPENGLES_20
00874     nuxAssertMsg(
00875       (AlphaTestFunc_ == GL_NEVER) ||
00876       (AlphaTestFunc_ == GL_LESS) ||
00877       (AlphaTestFunc_ == GL_EQUAL) ||
00878       (AlphaTestFunc_ == GL_LEQUAL) ||
00879       (AlphaTestFunc_ == GL_GREATER) ||
00880       (AlphaTestFunc_ == GL_NOTEQUAL) ||
00881       (AlphaTestFunc_ == GL_GEQUAL) ||
00882       (AlphaTestFunc_ == GL_ALWAYS),
00883       "Error(HW__SetAlphaTestFunc): Invalid Alpha Test Function RenderState");
00884 
00885     CHECKGL(glAlphaFunc(AlphaTestFunc_, (float) AlphaTestRef_ * (1.0f / 255.0f)));
00886     SET_RS_VALUE(render_state_changes_[GFXRS_ALPHATESTFUNC], AlphaTestFunc_);
00887     SET_RS_VALUE(render_state_changes_[GFXRS_ALPHATESTREF], AlphaTestRef_);
00888 #endif
00889   }
00890 
00891   inline void GpuRenderStates::HW__EnableAlphaBlend(unsigned int b)
00892   {
00893     if (b)
00894     {
00895       CHECKGL(glEnable(GL_BLEND));
00896     }
00897     else
00898     {
00899       CHECKGL(glDisable(GL_BLEND));
00900     }
00901 
00902     SET_RS_VALUE(render_state_changes_[GFXRS_ALPHABLENDENABLE], b ? GL_TRUE : GL_FALSE);
00903   }
00904 
00905   inline void GpuRenderStates::HW__SetSeparateAlphaBlendFactors(
00906     unsigned int SrcBlendFactor_,
00907     unsigned int DestBlendFactor_,
00908     unsigned int SrcFactorAlpha_,
00909     unsigned int DestFactorAlpha_)
00910   {
00911     nuxAssertMsg((SrcBlendFactor_ == GL_ZERO) || (SrcBlendFactor_ == GL_ONE) || (SrcBlendFactor_ == GL_SRC_COLOR) || (SrcBlendFactor_ == GL_ONE_MINUS_SRC_COLOR) || (SrcBlendFactor_ == GL_DST_COLOR) || (SrcBlendFactor_ == GL_ONE_MINUS_DST_COLOR) || (SrcBlendFactor_ == GL_SRC_ALPHA) || (SrcBlendFactor_ == GL_ONE_MINUS_SRC_ALPHA) || (SrcBlendFactor_ == GL_DST_ALPHA) || (SrcBlendFactor_ == GL_ONE_MINUS_DST_ALPHA) || (SrcBlendFactor_ == GL_CONSTANT_COLOR) || (SrcBlendFactor_ == GL_ONE_MINUS_CONSTANT_COLOR) || (SrcBlendFactor_ == GL_CONSTANT_ALPHA) || (SrcBlendFactor_ == GL_ONE_MINUS_CONSTANT_ALPHA) || (SrcBlendFactor_ == GL_SRC_ALPHA_SATURATE),
00912                    "Error(HW__SetSeparateAlphaBlendFactors): Invalid Blend RenderState");
00913     nuxAssertMsg((DestBlendFactor_ == GL_ZERO) || (DestBlendFactor_ == GL_ONE) || (DestBlendFactor_ == GL_SRC_COLOR) || (DestBlendFactor_ == GL_ONE_MINUS_SRC_COLOR) || (DestBlendFactor_ == GL_DST_COLOR) || (DestBlendFactor_ == GL_ONE_MINUS_DST_COLOR) || (DestBlendFactor_ == GL_SRC_ALPHA) || (DestBlendFactor_ == GL_ONE_MINUS_SRC_ALPHA) || (DestBlendFactor_ == GL_DST_ALPHA) || (DestBlendFactor_ == GL_ONE_MINUS_DST_ALPHA) || (DestBlendFactor_ == GL_CONSTANT_COLOR) || (DestBlendFactor_ == GL_ONE_MINUS_CONSTANT_COLOR) || (DestBlendFactor_ == GL_CONSTANT_ALPHA) || (DestBlendFactor_ == GL_ONE_MINUS_CONSTANT_ALPHA),
00914                    "Error(HW__SetSeparateAlphaBlendFactors): Invalid Blend RenderState");
00915     nuxAssertMsg((SrcFactorAlpha_ == GL_ZERO) || (SrcFactorAlpha_ == GL_ONE) || (SrcFactorAlpha_ == GL_SRC_COLOR) || (SrcFactorAlpha_ == GL_ONE_MINUS_SRC_COLOR) || (SrcFactorAlpha_ == GL_DST_COLOR) || (SrcFactorAlpha_ == GL_ONE_MINUS_DST_COLOR) || (SrcFactorAlpha_ == GL_SRC_ALPHA) || (SrcFactorAlpha_ == GL_ONE_MINUS_SRC_ALPHA) || (SrcFactorAlpha_ == GL_DST_ALPHA) || (SrcFactorAlpha_ == GL_ONE_MINUS_DST_ALPHA) || (SrcFactorAlpha_ == GL_CONSTANT_COLOR) || (SrcFactorAlpha_ == GL_ONE_MINUS_CONSTANT_COLOR) || (SrcFactorAlpha_ == GL_CONSTANT_ALPHA) || (SrcFactorAlpha_ == GL_ONE_MINUS_CONSTANT_ALPHA) || (SrcFactorAlpha_ == GL_SRC_ALPHA_SATURATE),
00916                    "Error(HW__SetSeparateAlphaBlendFactors): Invalid Blend RenderState");
00917     nuxAssertMsg((DestFactorAlpha_ == GL_ZERO) || (DestFactorAlpha_ == GL_ONE) || (DestFactorAlpha_ == GL_SRC_COLOR) || (DestFactorAlpha_ == GL_ONE_MINUS_SRC_COLOR) || (DestFactorAlpha_ == GL_DST_COLOR) || (DestFactorAlpha_ == GL_ONE_MINUS_DST_COLOR) || (DestFactorAlpha_ == GL_SRC_ALPHA) || (DestFactorAlpha_ == GL_ONE_MINUS_SRC_ALPHA) || (DestFactorAlpha_ == GL_DST_ALPHA) || (DestFactorAlpha_ == GL_ONE_MINUS_DST_ALPHA) || (DestFactorAlpha_ == GL_CONSTANT_COLOR) || (DestFactorAlpha_ == GL_ONE_MINUS_CONSTANT_COLOR) || (DestFactorAlpha_ == GL_CONSTANT_ALPHA) || (DestFactorAlpha_ == GL_ONE_MINUS_CONSTANT_ALPHA),
00918                    "Error(HW__SetSeparateAlphaBlendFactors): Invalid Blend RenderState");
00919 
00920     CHECKGL(glBlendFuncSeparate(
00921                SrcBlendFactor_,
00922                DestBlendFactor_,
00923                SrcFactorAlpha_,
00924                DestFactorAlpha_));
00925 
00926     SET_RS_VALUE(render_state_changes_[GFXRS_SRCBLEND], SrcBlendFactor_);
00927     SET_RS_VALUE(render_state_changes_[GFXRS_DESTBLEND], DestBlendFactor_);
00928     SET_RS_VALUE(render_state_changes_[GFXRS_SRCBLENDALPHA], SrcFactorAlpha_);
00929     SET_RS_VALUE(render_state_changes_[GFXRS_DESTBLENDALPHA], DestFactorAlpha_);
00930   }
00931 
00932   inline void GpuRenderStates::HW__SetAlphaBlendOp(
00933     unsigned int BlendOpRGB_,
00934     unsigned int BlendOpAlpha_)
00935   {
00936 #ifdef NUX_OPENGLES_20
00937     nuxAssertMsg(
00938       (BlendOpRGB_ == GL_FUNC_ADD) ||
00939       (BlendOpRGB_ == GL_FUNC_SUBTRACT) ||
00940       (BlendOpRGB_ == GL_FUNC_REVERSE_SUBTRACT),
00941       "Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState");
00942     nuxAssertMsg(
00943       (BlendOpAlpha_ == GL_FUNC_ADD) ||
00944       (BlendOpAlpha_ == GL_FUNC_SUBTRACT) ||
00945       (BlendOpAlpha_ == GL_FUNC_REVERSE_SUBTRACT),
00946       "Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState");
00947 
00948     CHECKGL(glBlendEquationSeparate(BlendOpRGB_, BlendOpAlpha_));
00949 
00950 #else
00951     nuxAssertMsg(
00952       (BlendOpRGB_ == GL_FUNC_ADD) ||
00953       (BlendOpRGB_ == GL_FUNC_SUBTRACT) ||
00954       (BlendOpRGB_ == GL_FUNC_REVERSE_SUBTRACT) ||
00955       (BlendOpRGB_ == GL_MIN) ||
00956       (BlendOpRGB_ == GL_MAX),
00957       "Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState");
00958     nuxAssertMsg(
00959       (BlendOpAlpha_ == GL_FUNC_ADD) ||
00960       (BlendOpAlpha_ == GL_FUNC_SUBTRACT) ||
00961       (BlendOpAlpha_ == GL_FUNC_REVERSE_SUBTRACT) ||
00962       (BlendOpAlpha_ == GL_MIN) ||
00963       (BlendOpAlpha_ == GL_MAX),
00964       "Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState");
00965 
00966     if (_gpu_info->SupportOpenGL20())
00967     {
00968       CHECKGL(glBlendEquationSeparate(BlendOpRGB_, BlendOpAlpha_));
00969     }
00970     else if (_gpu_info->Support_EXT_Blend_Equation_Separate())
00971     {
00972       CHECKGL(glBlendEquationSeparateEXT(BlendOpRGB_, BlendOpAlpha_));
00973     }
00974     else
00975     {
00976       CHECKGL(glBlendEquation(BlendOpRGB_));
00977     }
00978 #endif
00979 
00980     SET_RS_VALUE(render_state_changes_[GFXRS_BLENDOP], BlendOpRGB_);
00981     SET_RS_VALUE(render_state_changes_[GFXRS_BLENDOPALPHA], BlendOpAlpha_);
00982   }
00983 
00984   inline void GpuRenderStates::HW__EnableCulling(unsigned int b)
00985   {
00986     if (b)
00987     {
00988       CHECKGL(glEnable(GL_CULL_FACE));
00989     }
00990     else
00991     {
00992       CHECKGL(glDisable(GL_CULL_FACE));
00993     }
00994 
00995     SET_RS_VALUE(render_state_changes_[GFXRS_CULLFACEENABLE], b ? GL_TRUE : GL_FALSE);
00996   }
00997 
00998 
00999   inline void GpuRenderStates::HW__SetFrontFace(unsigned int FrontFace_)
01000   {
01001     nuxAssertMsg(
01002       (FrontFace_ == GL_CW) ||
01003       (FrontFace_ == GL_CCW),
01004       "Error(HW__SetFrontFace): Invalid Front Face RenderState");
01005 
01006     CHECKGL(glFrontFace(FrontFace_));
01007     SET_RS_VALUE(render_state_changes_[GFXRS_FRONTFACE], FrontFace_);
01008   }
01009 
01010   inline void GpuRenderStates::HW__SetCullFace(unsigned int CullFace_)
01011   {
01012     nuxAssertMsg(
01013       (CullFace_ == GL_FRONT) ||
01014       (CullFace_ == GL_BACK) ||
01015       (CullFace_ == GL_FRONT_AND_BACK),
01016       "Error(HW__SetCullFace): Invalid Cull Face RenderState");
01017 
01018     CHECKGL(glCullFace(CullFace_));
01019     SET_RS_VALUE(render_state_changes_[GFXRS_CULLFACE], CullFace_);
01020   }
01021 
01022   inline void GpuRenderStates::HW__SetEnableDepthTest(unsigned int b)
01023   {
01024     if (b)
01025     {
01026       CHECKGL(glEnable(GL_DEPTH_TEST));
01027     }
01028     else
01029     {
01030       CHECKGL(glDisable(GL_DEPTH_TEST));
01031     }
01032 
01033     SET_RS_VALUE(render_state_changes_[GFXRS_ZTESTENABLE], b ? GL_TRUE : GL_FALSE);
01034   }
01035 
01036   inline void GpuRenderStates::HW__SetDepthRange(float zNear, float zFar)
01037   {
01038     CHECKGL(glDepthRange(zNear, zFar));
01039     SET_RS_VALUE(render_state_changes_[GFXRS_ZNEAR], static_cast<unsigned int> (Clamp(zNear, 0.0f, 1.0f)));
01040     SET_RS_VALUE(render_state_changes_[GFXRS_ZFAR], static_cast<unsigned int> (Clamp(zFar, 0.0f, 1.0f)));
01041   }
01042 
01043   inline void GpuRenderStates::HW__SetDepthFunc(unsigned int Func)
01044   {
01045     nuxAssertMsg(
01046       (Func == GL_NEVER) ||
01047       (Func == GL_LESS) ||
01048       (Func == GL_EQUAL) ||
01049       (Func == GL_LEQUAL) ||
01050       (Func == GL_GREATER) ||
01051       (Func == GL_NOTEQUAL) ||
01052       (Func == GL_GEQUAL) ||
01053       (Func == GL_ALWAYS),
01054       "Error(HW__SetDepthFunc): Invalid Depth Func RenderState");
01055 
01056     CHECKGL(glDepthFunc(Func));
01057     SET_RS_VALUE(render_state_changes_[GFXRS_ZFUNC], Func);
01058   }
01059 
01060   inline void GpuRenderStates::HW__EnableStencil(unsigned int b)
01061   {
01062     if (b)
01063     {
01064       CHECKGL(glEnable(GL_STENCIL_TEST));
01065     }
01066     else
01067     {
01068       CHECKGL(glDisable(GL_STENCIL_TEST));
01069     }
01070 
01071     SET_RS_VALUE(render_state_changes_[GFXRS_STENCILENABLE], b ? GL_TRUE : GL_FALSE);
01072   }
01073 
01074   inline void GpuRenderStates::HW__SetStencilFunc(unsigned int func, int ref, unsigned int mask)
01075   {
01076     nuxAssertMsg(
01077       (func == GL_NEVER) ||
01078       (func == GL_LESS) ||
01079       (func == GL_EQUAL) ||
01080       (func == GL_LEQUAL) ||
01081       (func == GL_GREATER) ||
01082       (func == GL_NOTEQUAL) ||
01083       (func == GL_GEQUAL) ||
01084       (func == GL_ALWAYS),
01085       "Error(HW__SetFrontFaceStencilFunc): Invalid Stencil Function RenderState");
01086 
01087     CHECKGL(glStencilFunc(func, ref, mask));
01088 
01089     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFUNC], func);
01090     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILREF], ref);
01091     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILMASK], mask);
01092   }
01093 
01094   inline void GpuRenderStates::HW__SetStencilOp(unsigned int stencil_fail, unsigned int stencil_pass_depth_fail, unsigned int stencil_pass_depth_pass)
01095   {
01096     nuxAssertMsg(
01097       (stencil_fail == GL_KEEP) ||
01098       (stencil_fail == GL_ZERO) ||
01099       (stencil_fail == GL_REPLACE) ||
01100       (stencil_fail == GL_INCR) ||
01101       (stencil_fail == GL_INCR_WRAP) ||
01102       (stencil_fail == GL_DECR) ||
01103       (stencil_fail == GL_DECR_WRAP) ||
01104       (stencil_fail == GL_INVERT),
01105       "Error(HW__SetFrontFaceStencilOp): Invalid FailOp RenderState");
01106 
01107     nuxAssertMsg(
01108       (stencil_pass_depth_fail == GL_KEEP) ||
01109       (stencil_pass_depth_fail == GL_ZERO) ||
01110       (stencil_pass_depth_fail == GL_REPLACE) ||
01111       (stencil_pass_depth_fail == GL_INCR) ||
01112       (stencil_pass_depth_fail == GL_INCR_WRAP) ||
01113       (stencil_pass_depth_fail == GL_DECR) ||
01114       (stencil_pass_depth_fail == GL_DECR_WRAP) ||
01115       (stencil_pass_depth_fail == GL_INVERT),
01116       "Error(HW__SetFrontFaceStencilOp): Invalid ZFailOp RenderState");
01117 
01118     nuxAssertMsg(
01119       (stencil_pass_depth_pass == GL_KEEP) ||
01120       (stencil_pass_depth_pass == GL_ZERO) ||
01121       (stencil_pass_depth_pass == GL_REPLACE) ||
01122       (stencil_pass_depth_pass == GL_INCR) ||
01123       (stencil_pass_depth_pass == GL_INCR_WRAP) ||
01124       (stencil_pass_depth_pass == GL_DECR) ||
01125       (stencil_pass_depth_pass == GL_DECR_WRAP) ||
01126       (stencil_pass_depth_pass == GL_INVERT),
01127       "Error(HW__SetFrontFaceStencilOp): Invalid ZPassOp RenderState");
01128 
01129     CHECKGL(glStencilOp(stencil_fail, stencil_pass_depth_fail, stencil_pass_depth_pass));
01130 
01131     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFAIL], stencil_fail);
01132     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZFAIL], stencil_pass_depth_fail);
01133     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZPASS], stencil_pass_depth_pass);
01134   }
01135 
01136 #if 0
01137   inline void GpuRenderStates::HW__EnableTwoSidedStencil(unsigned int b)
01138   {
01139     if (b)
01140     {
01141       if (_gpu_brand == GPU_BRAND_AMD)
01142       {
01143         CHECKGL(glEnable(GL_STENCIL_TEST));
01144       }
01145       else
01146       {
01147         CHECKGL(glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT));
01148       }
01149     }
01150     else
01151     {
01152       if (_gpu_brand == GPU_BRAND_AMD)
01153       {
01154         CHECKGL(glDisable(GL_STENCIL_TEST));
01155       }
01156       else
01157       {
01158         CHECKGL(glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT));
01159       }
01160     }
01161 
01162     SET_RS_VALUE(render_state_changes_[GFXRS_TWOSIDEDSTENCILENABLE], b ? GL_TRUE : GL_FALSE);
01163   }
01164 
01165   inline void GpuRenderStates::HW__SetStencilFrontFaceWriteMask(unsigned int WriteMask_)
01166   {
01167     CHECKGL(glActiveStencilFaceEXT(GL_FRONT));
01168     CHECKGL(glStencilMask(WriteMask_));
01169     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILWRITEMASK], WriteMask_);
01170   }
01171 
01172   inline void GpuRenderStates::HW__SetStencilBackFaceWriteMask(unsigned int WriteMask_)
01173   {
01174     CHECKGL(glActiveStencilFaceEXT(GL_BACK));
01175     CHECKGL(glStencilMask(WriteMask_));
01176     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILWRITEMASK], WriteMask_);
01177   }
01178 
01179   inline void GpuRenderStates::HW__SetFrontFaceStencilFunc(unsigned int Func_,
01180       unsigned int Ref_,
01181       unsigned int Mask_)
01182   {
01183     nuxAssertMsg(
01184       (Func_ == GL_NEVER) ||
01185       (Func_ == GL_LESS) ||
01186       (Func_ == GL_EQUAL) ||
01187       (Func_ == GL_LEQUAL) ||
01188       (Func_ == GL_GREATER) ||
01189       (Func_ == GL_NOTEQUAL) ||
01190       (Func_ == GL_GEQUAL) ||
01191       (Func_ == GL_ALWAYS),
01192       "Error(HW__SetFrontFaceStencilFunc): Invalid Stencil Function RenderState");
01193 
01194     CHECKGL(glActiveStencilFaceEXT(GL_FRONT));
01195     CHECKGL(glStencilFunc(Func_, Ref_, Mask_));
01196 
01197     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFUNC], Func_);
01198     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILREF], Ref_);
01199     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILMASK], Mask_);
01200   }
01201 
01202   inline void GpuRenderStates::HW__SetBackFaceStencilFunc(
01203     unsigned int Func_,
01204     unsigned int Ref_,
01205     unsigned int Mask_)
01206   {
01207     nuxAssertMsg(
01208       (Func_ == GL_NEVER) ||
01209       (Func_ == GL_LESS) ||
01210       (Func_ == GL_EQUAL) ||
01211       (Func_ == GL_LEQUAL) ||
01212       (Func_ == GL_GREATER) ||
01213       (Func_ == GL_NOTEQUAL) ||
01214       (Func_ == GL_GEQUAL) ||
01215       (Func_ == GL_ALWAYS),
01216       "Error(HW__SetBackFaceStencilFunc): Invalid Stencil Function RenderState");
01217 
01218     if (_gpu_brand == GPU_BRAND_AMD)
01219     {
01220       CHECKGL(glStencilFuncSeparateATI(Func_/*Front function*/, Func_/*Back function*/, Ref_, Mask_)); // incorrect
01221     }
01222     else
01223     {
01224       CHECKGL(glActiveStencilFaceEXT(GL_BACK));
01225       CHECKGL(glStencilFunc(Func_, Ref_, Mask_));
01226     }
01227 
01228     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILFUNC], Func_);
01229     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILREF], Ref_);
01230     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILMASK], Mask_);
01231   }
01232 
01233   inline void GpuRenderStates::HW__SetFrontFaceStencilOp(
01234     unsigned int FailOp_,
01235     unsigned int ZFailOp_,
01236     unsigned int ZPassOp_)
01237   {
01238     nuxAssertMsg(
01239       (FailOp_ == GL_KEEP) ||
01240       (FailOp_ == GL_ZERO) ||
01241       (FailOp_ == GL_REPLACE) ||
01242       (FailOp_ == GL_INCR) ||
01243       (FailOp_ == GL_INCR_WRAP) ||
01244       (FailOp_ == GL_DECR) ||
01245       (FailOp_ == GL_DECR_WRAP) ||
01246       (FailOp_ == GL_INVERT),
01247       "Error(HW__SetFrontFaceStencilOp): Invalid FailOp RenderState");
01248 
01249     nuxAssertMsg(
01250       (ZFailOp_ == GL_KEEP) ||
01251       (ZFailOp_ == GL_ZERO) ||
01252       (ZFailOp_ == GL_REPLACE) ||
01253       (ZFailOp_ == GL_INCR) ||
01254       (ZFailOp_ == GL_INCR_WRAP) ||
01255       (ZFailOp_ == GL_DECR) ||
01256       (ZFailOp_ == GL_DECR_WRAP) ||
01257       (ZFailOp_ == GL_INVERT),
01258       "Error(HW__SetFrontFaceStencilOp): Invalid ZFailOp RenderState");
01259 
01260     nuxAssertMsg(
01261       (ZPassOp_ == GL_KEEP) ||
01262       (ZPassOp_ == GL_ZERO) ||
01263       (ZPassOp_ == GL_REPLACE) ||
01264       (ZPassOp_ == GL_INCR) ||
01265       (ZPassOp_ == GL_INCR_WRAP) ||
01266       (ZPassOp_ == GL_DECR) ||
01267       (ZPassOp_ == GL_DECR_WRAP) ||
01268       (ZPassOp_ == GL_INVERT),
01269       "Error(HW__SetFrontFaceStencilOp): Invalid ZPassOp RenderState");
01270 
01271     if (_gpu_brand == GPU_BRAND_AMD)
01272     {
01273       CHECKGL(glStencilOpSeparateATI(GL_FRONT, FailOp_, ZFailOp_, ZPassOp_));
01274     }
01275     else
01276     {
01277       CHECKGL(glActiveStencilFaceEXT(GL_FRONT));
01278       CHECKGL(glStencilOp(FailOp_, ZFailOp_, ZPassOp_));
01279     }
01280 
01281     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILFAIL], FailOp_);
01282     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZFAIL], ZFailOp_);
01283     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_STENCILZPASS], ZPassOp_);
01284   }
01285 
01286   inline void GpuRenderStates::HW__SetBackFaceStencilOp(
01287     unsigned int FailOp_,
01288     unsigned int ZFailOp_,
01289     unsigned int ZPassOp_)
01290   {
01291     nuxAssertMsg(
01292       (FailOp_ == GL_KEEP) ||
01293       (FailOp_ == GL_ZERO) ||
01294       (FailOp_ == GL_REPLACE) ||
01295       (FailOp_ == GL_INCR) ||
01296       (FailOp_ == GL_INCR_WRAP) ||
01297       (FailOp_ == GL_DECR) ||
01298       (FailOp_ == GL_DECR_WRAP) ||
01299       (FailOp_ == GL_INVERT),
01300       "Error(HW__SetBackFaceStencilOp): Invalid FailOp RenderState");
01301 
01302     nuxAssertMsg(
01303       (ZFailOp_ == GL_KEEP) ||
01304       (ZFailOp_ == GL_ZERO) ||
01305       (ZFailOp_ == GL_REPLACE) ||
01306       (ZFailOp_ == GL_INCR) ||
01307       (ZFailOp_ == GL_INCR_WRAP) ||
01308       (ZFailOp_ == GL_DECR) ||
01309       (ZFailOp_ == GL_DECR_WRAP) ||
01310       (ZFailOp_ == GL_INVERT),
01311       "Error(HW__SetBackFaceStencilOp): Invalid ZFailOp RenderState");
01312 
01313     nuxAssertMsg(
01314       (ZPassOp_ == GL_KEEP) ||
01315       (ZPassOp_ == GL_ZERO) ||
01316       (ZPassOp_ == GL_REPLACE) ||
01317       (ZPassOp_ == GL_INCR) ||
01318       (ZPassOp_ == GL_INCR_WRAP) ||
01319       (ZPassOp_ == GL_DECR) ||
01320       (ZPassOp_ == GL_DECR_WRAP) ||
01321       (ZPassOp_ == GL_INVERT),
01322       "Error(HW__SetBackFaceStencilOp): Invalid ZPassOp RenderState");
01323 
01324     if (_gpu_brand == GPU_BRAND_AMD)
01325     {
01326       CHECKGL(glStencilOpSeparateATI(GL_BACK, FailOp_, ZFailOp_, ZPassOp_));
01327     }
01328     else
01329     {
01330       CHECKGL(glActiveStencilFaceEXT(GL_BACK));
01331       CHECKGL(glStencilOp(FailOp_, ZFailOp_, ZPassOp_));
01332     }
01333 
01334     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILFAIL], FailOp_);
01335     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILZFAIL], ZFailOp_);
01336     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_STENCILZPASS], ZPassOp_);
01337   }
01338 #endif
01339 
01340   inline void GpuRenderStates::HW__EnableLineSmooth(unsigned int EnableLineSmooth)
01341   {
01342 #ifndef NUX_OPENGLES_20
01343     if (EnableLineSmooth)
01344     {
01345       CHECKGL(glEnable(GL_LINE_SMOOTH));
01346     }
01347     else
01348     {
01349       CHECKGL(glDisable(GL_LINE_SMOOTH));
01350     }
01351 
01352     SET_RS_VALUE(render_state_changes_[GFXRS_LINESMOOTHENABLE], EnableLineSmooth ? GL_TRUE : GL_FALSE);
01353 #endif
01354   }
01355 
01356   inline void GpuRenderStates::HW__SetLineWidth(unsigned int width,  unsigned int Hint)
01357   {
01358     nuxAssertMsg(
01359       (Hint == GL_NICEST) ||
01360       (Hint == GL_FASTEST) ||
01361       (Hint == GL_DONT_CARE),
01362       "Error(HW__SetLineWidth): Invalid Line Hint RenderState");
01363 
01364     CHECKGL(glLineWidth(width));
01365     SET_RS_VALUE(render_state_changes_[GFXRS_LINEWIDTH], width);
01366 
01367 #ifndef NUX_OPENGLES_20
01368     CHECKGL(glHint(GL_LINE_SMOOTH_HINT, Hint));
01369     SET_RS_VALUE(render_state_changes_[GFXRS_LINEHINT], Hint);
01370 #endif
01371   }
01372 
01373   inline void GpuRenderStates::HW__EnablePointSmooth(unsigned int EnablePointSmooth)
01374   {
01375 #ifndef NUX_OPENGLES_20
01376     if (EnablePointSmooth)
01377     {
01378       CHECKGL(glEnable(GL_POINT_SMOOTH));
01379     }
01380     else
01381     {
01382       CHECKGL(glDisable(GL_POINT_SMOOTH));
01383     }
01384 
01385     SET_RS_VALUE(render_state_changes_[GFXRS_POINTSMOOTHENABLE], EnablePointSmooth ? GL_TRUE : GL_FALSE);
01386 #endif
01387   }
01388 
01389   inline void GpuRenderStates::HW__SetPointSize(unsigned int size,  unsigned int Hint)
01390   {
01391 #ifndef NUX_OPENGLES_20
01392     nuxAssertMsg(
01393       (Hint == GL_NICEST) ||
01394       (Hint == GL_FASTEST) ||
01395       (Hint == GL_DONT_CARE),
01396       "Error(HW__SetPointSize): Invalid Point Hint RenderState");
01397 
01398     CHECKGL(glPointSize(size));
01399     CHECKGL(glHint(GL_POINT_SMOOTH_HINT, Hint);)
01400     SET_RS_VALUE(render_state_changes_[GFXRS_POINTSIZE], size);
01401     SET_RS_VALUE(render_state_changes_[GFXRS_POINTHINT], Hint);
01402 #endif
01403   }
01404 
01405   inline void GpuRenderStates::HW__SetColorMask(
01406     unsigned int bRed,
01407     unsigned int bGreen,
01408     unsigned int bBlue,
01409     unsigned int bAlpha)
01410   {
01411     CHECKGL(glColorMask(bRed, bGreen, bBlue, bAlpha));
01412     SET_RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_R], bRed);
01413     SET_RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_G], bGreen);
01414     SET_RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_B], bBlue);
01415     SET_RS_VALUE(render_state_changes_[GFXRS_COLORWRITEENABLE_A], bAlpha);
01416   }
01417 
01418   inline void GpuRenderStates::HW__SetDepthMask(unsigned int bDepth)
01419   {
01420     CHECKGL(glDepthMask(bDepth));
01421     SET_RS_VALUE(render_state_changes_[GFXRS_ZWRITEENABLE], bDepth);
01422   }
01423 
01424   inline void GpuRenderStates::HW__EnableScissor(unsigned int bScissor)
01425   {
01426     if (bScissor)
01427     {
01428       CHECKGL(glEnable(GL_SCISSOR_TEST));
01429     }
01430     else
01431     {
01432       CHECKGL(glDisable(GL_SCISSOR_TEST));
01433     }
01434 
01435     SET_RS_VALUE(render_state_changes_[GFXRS_SCISSORTESTENABLE], bScissor ? GL_TRUE : GL_FALSE);
01436   }
01437 
01438   inline void GpuRenderStates::HW__EnableFog(unsigned int bFog)
01439   {
01440 #ifndef NUX_OPENGLES_20
01441     if (bFog)
01442     {
01443       CHECKGL(glEnable(GL_FOG));
01444     }
01445     else
01446     {
01447       CHECKGL(glDisable(GL_FOG));
01448     }
01449 
01450     SET_RS_VALUE(render_state_changes_[GFXRS_FOGENABLE], bFog ? GL_TRUE : GL_FALSE);
01451 #endif
01452   }
01453 
01454   inline void GpuRenderStates::HW__SetPolygonMode(unsigned int FrontMode, unsigned int BackMode)
01455   {
01456 #ifndef NUX_OPENGLES_20
01457     nuxAssertMsg(
01458       (FrontMode == GL_FILL) ||
01459       (FrontMode == GL_LINE) ||
01460       (FrontMode == GL_POINT),
01461       "Error(HW__SetPolygonMode): Invalid Point Hint RenderState");
01462 
01463     nuxAssertMsg(
01464       (BackMode == GL_FILL) ||
01465       (BackMode == GL_LINE) ||
01466       (BackMode == GL_POINT),
01467       "Error(HW__SetPolygonMode): Invalid Point Hint RenderState");
01468 
01469     CHECKGL(glPolygonMode(GL_FRONT, FrontMode));
01470     CHECKGL(glPolygonMode(GL_BACK, BackMode));
01471 
01472     SET_RS_VALUE(render_state_changes_[GFXRS_FRONT_POLYGONMODE], FrontMode);
01473     SET_RS_VALUE(render_state_changes_[GFXRS_BACK_POLYGONMODE], BackMode);
01474 #endif
01475   }
01476 
01477   inline void GpuRenderStates::HW__EnablePolygonOffset(unsigned int EnablePolygonOffset)
01478   {
01479     if (EnablePolygonOffset)
01480     {
01481       CHECKGL(glEnable(GL_POLYGON_OFFSET_FILL));
01482     }
01483     else
01484     {
01485       CHECKGL(glDisable(GL_POLYGON_OFFSET_FILL));
01486     }
01487 
01488     SET_RS_VALUE(render_state_changes_[GL_POLYGON_OFFSET_FILL], EnablePolygonOffset ? GL_TRUE : GL_FALSE);
01489   }
01490 
01491   inline void GpuRenderStates::HW__SetPolygonOffset(float Factor, float Units)
01492   {
01493     CHECKGL(glPolygonOffset(Factor, Units));
01494 
01495     SET_RS_VALUE(render_state_changes_[GFXRS_POLYGONOFFSETFACTOR], static_cast<unsigned int> (Factor));
01496     SET_RS_VALUE(render_state_changes_[GFXRS_POLYGONOFFSETUNITS], static_cast<unsigned int> (Units));
01497   }
01498 
01499 #undef SET_RS_VALUE
01500 #undef RS_VALUE
01501 
01502 //#undef SET_RS_VALUE_FLOAT
01503 //#undef RS_VALUE_FLOAT
01504 
01505 }
01506 
01507 #endif // GLRENDERSTATES_H
01508