# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Shader.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.com                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    00029 /*                                                                                    */
    00030 /**************************************************************************************/
    00031
    00032 #ifndef Shader_INCLUDE_ONCE
    00033 #define Shader_INCLUDE_ONCE
    00034
    00035 #include <vlCore/Vector4.hpp>
    00036 #include <vlCore/Matrix4.hpp>
    00037 #include <vlGraphics/link_config.hpp>
    00038 #include <vlGraphics/RenderState.hpp>
    00039 #include <vlGraphics/RenderStateSet.hpp>
    00040 #include <vlGraphics/EnableSet.hpp>
    00041 #include <vlGraphics/UniformSet.hpp>
    00042 #include <vlGraphics/Texture.hpp>
    00043 #include <vlGraphics/Scissor.hpp>
    00044 #include <vector>
    00045
    00046 namespace vl
    00047 {
    00048   class Light;
    00049   class ClipPlane;
    00050   class Shader;
    00051   //------------------------------------------------------------------------------
    00052   // PixelTransfer
    00053   //------------------------------------------------------------------------------
    00057   class VLGRAPHICS_EXPORT PixelTransfer: public RenderState
    00058   {
    00059   public:
    00060     PixelTransfer()
    00061     {
    00062       VL_DEBUG_SET_OBJECT_NAME()
    00063       mMapColor    = false;
    00064       mMapStencil  = false;
    00065       mIndexShift  = 0;
    00066       mIndexOffset = 0;
    00067       mRedScale    = 1;
    00068       mGreenScale  = 1;
    00069       mBlueScale   = 1;
    00070       mAlphaScale  = 1;
    00071       mDepthScale  = 1;
    00072       mRedBias     = 0;
    00073       mGreenBias   = 0;
    00074       mBlueBias    = 0;
    00075       mAlphaBias   = 0;
    00076       mDepthBias   = 0;
    00077       mPostColorMatrixRedScale   = 1;
    00078       mPostColorMatrixGreenScale = 1;
    00079       mPostColorMatrixBlueScale  = 1;
    00080       mPostColorMatrixAlphaScale = 1;
    00081       mPostColorMatrixRedBias    = 0;
    00082       mPostColorMatrixGreenBias  = 0;
    00083       mPostColorMatrixBlueBias   = 0;
    00084       mPostColorMatrixAlphaBias  = 0;
    00085       mPostConvolutionRedScale   = 1;
    00086       mPostConvolutionGreenScale = 1;
    00087       mPostConvolutionBlueScale  = 1;
    00088       mPostConvolutionAlphaScale = 1;
    00089       mPostConvolutionRedBias    = 0;
    00090       mPostConvolutionGreenBias  = 0;
    00091       mPostConvolutionBlueBias   = 0;
    00092       mPostConvolutionAlphaBias  = 0;
    00093     }
    00094
    00095     virtual const char* className() { return "vl::PixelTransfer"; }
    00096
    00097     virtual ERenderState type() const { return RS_PixelTransfer; }
    00098
    00099     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00100
    00101     bool mapColor() const { return mMapColor; }
    00102     bool mapStencil() const { return mMapStencil; }
    00103     int indexShift() const { return mIndexShift; }
    00104     int indexOffset() const { return mIndexOffset; }
    00105     float redScale() const { return mRedScale; }
    00106     float greenScale() const { return mGreenScale; }
    00107     float blueScale() const { return mBlueScale; }
    00108     float alphaScale() const { return mAlphaScale; }
    00109     float depthScale() const { return mDepthScale; }
    00110     float redBias() const { return mRedBias; }
    00111     float greenBias() const { return mGreenBias; }
    00112     float blueBias() const { return mBlueBias; }
    00113     float alphaBias() const { return mAlphaBias; }
    00114     float depthBias() const { return mDepthBias; }
    00115     float postColorMatrixRedScale() const { return mPostColorMatrixRedScale; }
    00116     float postColorMatrixGreenScale() const { return mPostColorMatrixGreenScale; }
    00117     float postColorMatrixBlueScale() const { return mPostColorMatrixBlueScale; }
    00118     float postColorMatrixAlphaScale() const { return mPostColorMatrixAlphaScale; }
    00119     float postColorMatrixRedBias() const { return mPostColorMatrixRedBias; }
    00120     float postColorMatrixGreenBias() const { return mPostColorMatrixGreenBias; }
    00121     float postColorMatrixBlueBias() const { return mPostColorMatrixBlueBias; }
    00122     float postColorMatrixAlphaBias() const { return mPostColorMatrixAlphaBias; }
    00123     float postConvolutionRedScale() const { return mPostConvolutionRedScale; }
    00124     float postConvolutionGreenScale() const { return mPostConvolutionGreenScale; }
    00125     float postConvolutionBlueScale() const { return mPostConvolutionBlueScale; }
    00126     float postConvolutionAlphaScale() const { return mPostConvolutionAlphaScale; }
    00127     float postConvolutionRedBias() const { return mPostConvolutionRedBias; }
    00128     float postConvolutionGreenBias() const { return mPostConvolutionGreenBias; }
    00129     float postConvolutionBlueBias() const { return mPostConvolutionBlueBias; }
    00130     float postConvolutionAlphaBias() const { return mPostConvolutionAlphaBias; }
    00131
    00132     void setMapColor(bool map_color) {  mMapColor = map_color; }
    00133     void setMapStencil(bool map_stencil) {  mMapStencil = map_stencil; }
    00134     void setIndexShift(int index_shift) {  mIndexShift = index_shift; }
    00135     void setIndexOffset(int index_offset) {  mIndexOffset = index_offset; }
    00136     void setRedScale(float red_scale) {  mRedScale = red_scale; }
    00137     void setGreenScale(float green_scale) {  mGreenScale = green_scale; }
    00138     void setBlueScale(float blue_scale) {  mBlueScale = blue_scale; }
    00139     void setAlphaScale(float alpha_scale) {  mAlphaScale = alpha_scale; }
    00140     void setDepthScale(float depth_scale) {  mDepthScale = depth_scale; }
    00141     void setRedBias(float red_bias) {  mRedBias = red_bias; }
    00142     void setGreenBias(float green_bias) {  mGreenBias = green_bias; }
    00143     void setBlueBias(float blue_bias) {  mBlueBias = blue_bias; }
    00144     void setAlphaBias(float alpha_bias) {  mAlphaBias = alpha_bias; }
    00145     void setDepthBias(float depth_bias) {  mDepthBias = depth_bias; }
    00146     void setPostColorMatrixRedScale(float scale) {  mPostColorMatrixRedScale = scale; }
    00147     void setPostColorMatrixGreenScale(float scale) {  mPostColorMatrixGreenScale = scale; }
    00148     void setPostColorMatrixBlueScale(float scale) {  mPostColorMatrixBlueScale = scale; }
    00149     void setPostColorMatrixAlphaScale(float scale) {  mPostColorMatrixAlphaScale = scale; }
    00150     void setPostColorMatrixRedBias(float bias) {  mPostColorMatrixRedBias = bias; }
    00151     void setPostColorMatrixGreenBias(float bias) {  mPostColorMatrixGreenBias = bias; }
    00152     void setPostColorMatrixBlueBias(float bias) {  mPostColorMatrixBlueBias = bias; }
    00153     void setPostColorMatrixAlphaBias(float bias) {  mPostColorMatrixAlphaBias = bias; }
    00154     void setPostConvolutionRedScale(float scale) {  mPostConvolutionRedScale = scale; }
    00155     void setPostConvolutionGreenScale(float scale) {  mPostConvolutionGreenScale = scale; }
    00156     void setPostConvolutionBlueScale(float scale) {  mPostConvolutionBlueScale = scale; }
    00157     void setPostConvolutionAlphaScale(float scale) {  mPostConvolutionAlphaScale = scale; }
    00158     void setPostConvolutionRedBias(float bias) {  mPostConvolutionRedBias = bias; }
    00159     void setPostConvolutionGreenBias(float bias) {  mPostConvolutionGreenBias = bias; }
    00160     void setPostConvolutionBlueBias(float bias) {  mPostConvolutionBlueBias = bias; }
    00161     void setPostConvolutionAlphaBias(float bias) {  mPostConvolutionAlphaBias = bias; }
    00162
    00163   protected:
    00164     bool mMapColor;
    00165     bool mMapStencil;
    00166     int mIndexShift;
    00167     int mIndexOffset;
    00168     float mRedScale;
    00169     float mGreenScale;
    00170     float mBlueScale;
    00171     float mAlphaScale;
    00172     float mDepthScale;
    00173     float mRedBias;
    00174     float mGreenBias;
    00175     float mBlueBias;
    00176     float mAlphaBias;
    00177     float mDepthBias;
    00178     float mPostColorMatrixRedScale;
    00179     float mPostColorMatrixGreenScale;
    00180     float mPostColorMatrixBlueScale;
    00181     float mPostColorMatrixAlphaScale;
    00182     float mPostColorMatrixRedBias;
    00183     float mPostColorMatrixGreenBias;
    00184     float mPostColorMatrixBlueBias;
    00185     float mPostColorMatrixAlphaBias;
    00186     float mPostConvolutionRedScale;
    00187     float mPostConvolutionGreenScale;
    00188     float mPostConvolutionBlueScale;
    00189     float mPostConvolutionAlphaScale;
    00190     float mPostConvolutionRedBias;
    00191     float mPostConvolutionGreenBias;
    00192     float mPostConvolutionBlueBias;
    00193     float mPostConvolutionAlphaBias;
    00194
    00195   };
    00196   //------------------------------------------------------------------------------
    00197   // Hint
    00198   //------------------------------------------------------------------------------
    00201   class VLGRAPHICS_EXPORT Hint: public RenderState
    00202   {
    00203   public:
    00204     Hint(): mPerspectiveCorrectionHint(HM_DONT_CARE), mPointSmoothHint(HM_DONT_CARE), mLineSmoothHint(HM_DONT_CARE),
    00205             mPolygonSmoothHint(HM_DONT_CARE), mFogHint(HM_DONT_CARE), mGenerateMipmapHint(HM_DONT_CARE)
    00206     {
    00207       VL_DEBUG_SET_OBJECT_NAME()
    00208     }
    00209
    00210     virtual const char* className() { return "vl::Hint"; }
    00211
    00212     virtual ERenderState type() const { return RS_Hint; }
    00213
    00214     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00215
    00216     void setPerspectiveCorrectionHint(EHintMode mode) { mPerspectiveCorrectionHint = mode; }
    00217     void setPolygonSmoohtHint(EHintMode mode) { mPolygonSmoothHint = mode; }
    00218     void setLineSmoothHint(EHintMode mode) { mLineSmoothHint = mode; }
    00219     void setPointSmoothHint(EHintMode mode) { mPointSmoothHint = mode; }
    00220     void setFogHint(EHintMode mode) { mFogHint = mode; }
    00221     void setGenerateMipmapHint(EHintMode mode) { mGenerateMipmapHint = mode; }
    00222
    00223     EHintMode perspectiveCorrectionHint() const { return mPerspectiveCorrectionHint; }
    00224     EHintMode polygonSmoohtHint() const { return mPolygonSmoothHint; }
    00225     EHintMode lineSmoothHint() const { return mLineSmoothHint; }
    00226     EHintMode pointSmoothHint() const { return mPointSmoothHint; }
    00227     EHintMode fogHint() const { return mFogHint; }
    00228     EHintMode generateMipmapHint() const { return mGenerateMipmapHint; }
    00229
    00230   protected:
    00231     EHintMode mPerspectiveCorrectionHint;
    00232     EHintMode mPointSmoothHint;
    00233     EHintMode mLineSmoothHint;
    00234     EHintMode mPolygonSmoothHint;
    00235     EHintMode mFogHint;
    00236     EHintMode mGenerateMipmapHint;
    00237   };
    00238   //------------------------------------------------------------------------------
    00239   // CullFace
    00240   //------------------------------------------------------------------------------
    00243   class VLGRAPHICS_EXPORT CullFace: public RenderState
    00244   {
    00245   public:
    00246     CullFace(EPolygonFace cullface=PF_BACK): mFaceMode(cullface)
    00247     {
    00248       VL_DEBUG_SET_OBJECT_NAME()
    00249     }
    00250     virtual const char* className() { return "vl::CullFace"; }
    00251     virtual ERenderState type() const { return RS_CullFace; }
    00252     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00253     void set(EPolygonFace facemode) { mFaceMode = facemode; }
    00254     EPolygonFace faceMode() const { return mFaceMode; }
    00255   protected:
    00256     EPolygonFace mFaceMode;
    00257   };
    00258   //------------------------------------------------------------------------------
    00259   // FrontFace
    00260   //------------------------------------------------------------------------------
    00263   class VLGRAPHICS_EXPORT FrontFace: public RenderState
    00264   {
    00265   public:
    00266     FrontFace(EFrontFace frontface=FF_CCW): mFrontFace(frontface)
    00267     {
    00268       VL_DEBUG_SET_OBJECT_NAME()
    00269     }
    00270     virtual const char* className() { return "vl::FrontFace"; }
    00271     virtual ERenderState type() const { return RS_FrontFace; }
    00272     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00273     void set(EFrontFace frontface) { mFrontFace = frontface; }
    00274     EFrontFace frontFace() const { return mFrontFace; }
    00275   protected:
    00276     EFrontFace mFrontFace;
    00277   };
    00278   //------------------------------------------------------------------------------
    00279   // DepthFunc
    00280   //------------------------------------------------------------------------------
    00283   class VLGRAPHICS_EXPORT DepthFunc: public RenderState
    00284   {
    00285   public:
    00286     DepthFunc(EFunction depthfunc=FU_LESS): mDepthFunc(depthfunc)
    00287     {
    00288       VL_DEBUG_SET_OBJECT_NAME()
    00289     }
    00290     virtual const char* className() { return "vl::DepthFunc"; }
    00291     virtual ERenderState type() const { return RS_DepthFunc; }
    00292     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00293     void set(EFunction depthfunc) { mDepthFunc = depthfunc; }
    00294     EFunction depthFunc() const { return mDepthFunc; }
    00295   protected:
    00296     EFunction mDepthFunc;
    00297   };
    00298   //------------------------------------------------------------------------------
    00299   // DepthMask
    00300   //------------------------------------------------------------------------------
    00303   class VLGRAPHICS_EXPORT DepthMask: public RenderState
    00304   {
    00305   public:
    00306     DepthMask(bool depthmask=true): mDepthMask(depthmask)
    00307     {
    00308       VL_DEBUG_SET_OBJECT_NAME()
    00309     }
    00310     virtual const char* className() { return "vl::DepthMask"; }
    00311     virtual ERenderState type() const { return RS_DepthMask; }
    00312     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00313     void set(bool depthmask) { mDepthMask = depthmask; }
    00314     bool depthMask() const { return mDepthMask; }
    00315   protected:
    00316     bool mDepthMask;
    00317   };
    00318   //------------------------------------------------------------------------------
    00319   // PolygonMode
    00320   //------------------------------------------------------------------------------
    00323   class VLGRAPHICS_EXPORT PolygonMode: public RenderState
    00324   {
    00325   public:
    00326     PolygonMode(EPolygonMode frontface=PM_FILL, EPolygonMode backface=PM_FILL): mFrontFace(frontface), mBackFace(backface)
    00327     {
    00328       VL_DEBUG_SET_OBJECT_NAME()
    00329     }
    00330     virtual const char* className() { return "vl::PlygonMode"; }
    00331     virtual ERenderState type() const { return RS_PolygonMode; }
    00332     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00333     void set(EPolygonMode frontface, EPolygonMode backface) { mFrontFace = frontface; mBackFace = backface; }
    00334     void setFrontFace(EPolygonMode frontface) { mFrontFace = frontface; }
    00335     void setBackFace(EPolygonMode backface) { mBackFace = backface; }
    00336     EPolygonMode frontFace() const { return mFrontFace; }
    00337     EPolygonMode backFace() const { return mBackFace; }
    00338   protected:
    00339     EPolygonMode mFrontFace;
    00340     EPolygonMode mBackFace;
    00341   };
    00342   //------------------------------------------------------------------------------
    00343   // ShadeModel
    00344   //------------------------------------------------------------------------------
    00347   class VLGRAPHICS_EXPORT ShadeModel: public RenderState
    00348   {
    00349   public:
    00350     ShadeModel(EShadeModel shademodel=SM_SMOOTH): mShadeModel(shademodel)
    00351     {
    00352       VL_DEBUG_SET_OBJECT_NAME()
    00353     }
    00354     virtual const char* className() { return "vl::ShadeModel"; }
    00355     virtual ERenderState type() const { return RS_ShadeModel; }
    00356     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00357     void set(EShadeModel shademodel) { mShadeModel = shademodel; }
    00358     EShadeModel shadeModel() const { return mShadeModel; }
    00359   protected:
    00360     EShadeModel mShadeModel;
    00361   };
    00362   //------------------------------------------------------------------------------
    00363   // BlendFunc
    00364   //------------------------------------------------------------------------------
    00367   class VLGRAPHICS_EXPORT BlendFunc: public RenderState
    00368   {
    00369   public:
    00370     BlendFunc(EBlendFactor src_rgb=BF_SRC_ALPHA, EBlendFactor dst_rgb=BF_ONE_MINUS_SRC_ALPHA, EBlendFactor src_alpha=BF_SRC_ALPHA, EBlendFactor dst_alpha=BF_ONE_MINUS_SRC_ALPHA):
    00371       mSrcRGB(src_rgb), mDstRGB(dst_rgb), mSrcAlpha(src_alpha), mDstAlpha(dst_alpha)
    00372     {
    00373       VL_DEBUG_SET_OBJECT_NAME()
    00374     }
    00375     virtual const char* className() { return "vl::BlendFunc"; }
    00376     virtual ERenderState type() const { return RS_BlendFunc; }
    00377     // if glBlendFuncSeparate is not supported uses RGB factor for both RGB and Alpha
    00378     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00379     void set(EBlendFactor src_rgb, EBlendFactor dst_rgb, EBlendFactor src_alpha, EBlendFactor dst_alpha) { mSrcRGB = src_rgb; mSrcAlpha = src_alpha; mDstRGB = dst_rgb; mDstAlpha = dst_alpha; }
    00380     void set(EBlendFactor src_rgba, EBlendFactor dst_rgba) { mSrcRGB = src_rgba; mSrcAlpha = src_rgba; mDstRGB = dst_rgba; mDstAlpha = dst_rgba; }
    00381     void setSrcRGB(EBlendFactor factor) { mSrcRGB = factor; }
    00382     void setDstRGB(EBlendFactor factor) { mDstRGB = factor; }
    00383     void setSrcAlpha(EBlendFactor factor) { mSrcAlpha = factor; }
    00384     void setDstAlpha(EBlendFactor factor) { mDstAlpha = factor; }
    00385     EBlendFactor srcRGB() const { return mSrcRGB; }
    00386     EBlendFactor dstRGB() const { return mDstRGB; }
    00387     EBlendFactor srcAlpha() const { return mSrcAlpha; }
    00388     EBlendFactor dstAlpha() const { return mDstAlpha; }
    00389   protected:
    00390     EBlendFactor mSrcRGB;
    00391     EBlendFactor mDstRGB;
    00392     EBlendFactor mSrcAlpha;
    00393     EBlendFactor mDstAlpha;
    00394   };
    00395   //------------------------------------------------------------------------------
    00396   // BlendEquation
    00397   //------------------------------------------------------------------------------
    00402   class VLGRAPHICS_EXPORT BlendEquation: public RenderState
    00403   {
    00404   public:
    00405     BlendEquation(EBlendEquation mode_rgb=BE_FUNC_ADD, EBlendEquation mode_alpha=BE_FUNC_ADD): mModeRGB(mode_rgb), mModeAlpha(mode_alpha)
    00406     {
    00407       VL_DEBUG_SET_OBJECT_NAME()
    00408     }
    00409     virtual const char* className() { return "vl::BlendEquation"; }
    00410     virtual ERenderState type() const { return RS_BlendEquation; }
    00411     // if glBlendEquationSeparate is not supported uses RGB mode for both RGB and Alpha
    00412     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00413     void set(EBlendEquation mode_rgba) { mModeRGB = mode_rgba; mModeAlpha = mode_rgba; }
    00414     void set(EBlendEquation mode_rgb, EBlendEquation mode_alpha) { mModeRGB = mode_rgb; mModeAlpha = mode_alpha; }
    00415     EBlendEquation modeRGB() const { return mModeRGB; }
    00416     EBlendEquation modeAlpha() const { return mModeAlpha; }
    00417   protected:
    00418     EBlendEquation mModeRGB;
    00419     EBlendEquation mModeAlpha;
    00420   };
    00421   //------------------------------------------------------------------------------
    00422   // SampleCoverage
    00423   //------------------------------------------------------------------------------
    00426   class VLGRAPHICS_EXPORT SampleCoverage: public RenderState
    00427   {
    00428   public:
    00429     SampleCoverage(GLclampf value=1.0f, bool invert=false): mValue(value), mInvert(invert)
    00430     {
    00431       VL_DEBUG_SET_OBJECT_NAME()
    00432     }
    00433     virtual const char* className() { return "vl::SampleCoverage"; }
    00434     virtual ERenderState type() const { return RS_SampleCoverage; }
    00435     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00436     void set(GLclampf value, bool invert) { mValue = value; mInvert = invert; }
    00437     void setValue(GLclampf value) { mValue = value; }
    00438     void setInvert(bool invert) { mInvert = invert; }
    00439     GLclampf value() const { return mValue; }
    00440     bool invert() const { return mInvert; }
    00441   protected:
    00442     GLclampf mValue;
    00443     bool mInvert;
    00444   };
    00445   //------------------------------------------------------------------------------
    00446   // AlphaFunc
    00447   //------------------------------------------------------------------------------
    00450   class VLGRAPHICS_EXPORT AlphaFunc: public RenderState
    00451   {
    00452   public:
    00453     AlphaFunc(EFunction alphafunc=FU_ALWAYS, float refvalue=0): mRefValue(refvalue), mAlphaFunc(alphafunc)
    00454     {
    00455       VL_DEBUG_SET_OBJECT_NAME()
    00456     }
    00457     virtual const char* className() { return "vl::AlphaFunc"; }
    00458     virtual ERenderState type() const { return RS_AlphaFunc; }
    00459     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00460     void set(EFunction alphafunc, float ref_value) { mAlphaFunc = alphafunc; mRefValue = ref_value; }
    00461     EFunction alphaFunc() const { return mAlphaFunc; }
    00462     float refValue() const { return mRefValue; }
    00463   protected:
    00464     float mRefValue;
    00465     EFunction mAlphaFunc;
    00466   };
    00467   //------------------------------------------------------------------------------
    00468   // Material
    00469   //------------------------------------------------------------------------------
    00472   class VLGRAPHICS_EXPORT Material: public RenderState
    00473   {
    00474   public:
    00475     Material();
    00476     virtual const char* className() { return "vl::Material"; }
    00477     virtual ERenderState type() const { return RS_Material; }
    00478     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00479
    00480     void setTransparency(float alpha);
    00481     void setFrontTransparency(float alpha);
    00482     void setBackTransparency(float alpha);
    00483     void setFrontFlatColor(const fvec4& color);
    00484     void setBackFlatColor(const fvec4& color);
    00485     void setFlatColor(const fvec4& color);
    00486
    00487     void setAmbient(fvec4 color)          { mFrontAmbient   = mBackAmbient   = color; }
    00488     void setDiffuse(fvec4 color)          { mFrontDiffuse   = mBackDiffuse   = color; }
    00489     void setSpecular(fvec4 color)         { mFrontSpecular  = mBackSpecular  = color; }
    00490     void setEmission(fvec4 color)         { mFrontEmission  = mBackEmission  = color; }
    00491     void setShininess(float shininess) { mFrontShininess = mBackShininess = shininess; }
    00492
    00493     void setFrontAmbient(fvec4 color) { mFrontAmbient = color; }
    00494     void setFrontDiffuse(fvec4 color) { mFrontDiffuse = color; }
    00495     void setFrontSpecular(fvec4 color) { mFrontSpecular = color; }
    00496     void setFrontEmission(fvec4 color) { mFrontEmission = color; }
    00497     void setFrontShininess(float shininess) { mFrontShininess=shininess; }
    00498     fvec4 frontAmbient() const { return mFrontAmbient; }
    00499     fvec4 frontDiffuse() const { return mFrontDiffuse; }
    00500     fvec4 frontSpecular() const { return mFrontSpecular; }
    00501     fvec4 frontEmission() const { return mFrontEmission; }
    00502     float frontShininess() const { return mFrontShininess; }
    00503
    00504     void setBackAmbient(fvec4 color) { mBackAmbient = color; }
    00505     void setBackDiffuse(fvec4 color) { mBackDiffuse = color; }
    00506     void setBackSpecular(fvec4 color) { mBackSpecular = color; }
    00507     void setBackEmission(fvec4 color) { mBackEmission = color; }
    00508     void setBackShininess(float shininess) { mBackShininess=shininess; }
    00509     fvec4 backAmbient() const { return mBackAmbient; }
    00510     fvec4 backDiffuse() const { return mBackDiffuse; }
    00511     fvec4 backSpecular() const { return mBackSpecular; }
    00512     fvec4 backEmission() const { return mBackEmission; }
    00513     float backShininess() const { return mBackShininess; }
    00514
    00515     // color material
    00516
    00517     void setColorMaterial(EPolygonFace face, EColorMaterial color) { mColorMaterialFace = face; mColorMaterial = color; }
    00518     EPolygonFace colorMaterialFace() const { return mColorMaterialFace; }
    00519     EColorMaterial colorMaterial() const { return mColorMaterial; }
    00520     void setColorMaterialEnabled(bool enabled) { mColorMaterialEnabled = enabled; }
    00521     bool colorMaterialEnabled() const { return mColorMaterialEnabled; }
    00522
    00523   protected:
    00524     fvec4 mFrontAmbient;
    00525     fvec4 mFrontDiffuse;
    00526     fvec4 mFrontSpecular;
    00527     fvec4 mFrontEmission;
    00528     fvec4 mBackAmbient;
    00529     fvec4 mBackDiffuse;
    00530     fvec4 mBackSpecular;
    00531     fvec4 mBackEmission;
    00532     float mBackShininess;
    00533     float mFrontShininess;
    00534     // color material
    00535     EPolygonFace mColorMaterialFace;
    00536     EColorMaterial mColorMaterial;
    00537     bool mColorMaterialEnabled;
    00538   };
    00539   //------------------------------------------------------------------------------
    00540   // LightModel
    00541   //------------------------------------------------------------------------------
    00544   class VLGRAPHICS_EXPORT LightModel: public RenderState
    00545   {
    00546   public:
    00547     LightModel(): mAmbientColor(0.2f,0.2f,0.2f,1.0f), mColorControl(CC_SINGLE_COLOR), mLocalViewer(false), mTwoSide(false)
    00548     {
    00549       VL_DEBUG_SET_OBJECT_NAME()
    00550     }
    00551     virtual const char* className() { return "vl::LightModel"; }
    00552     virtual ERenderState type() const { return RS_LightModel; }
    00553     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00554     void setLocalViewer(bool localviewer) { mLocalViewer = localviewer; }
    00555     void setTwoSide(bool twoside) { mTwoSide = twoside; }
    00556     void setColorControl(EColorControl colorcontrol) { mColorControl = colorcontrol; }
    00557     void setAmbientColor(fvec4 ambientcolor) { mAmbientColor = ambientcolor; }
    00558     bool localViewer() const { return mLocalViewer; }
    00559     bool twoSide() const { return mTwoSide; }
    00560     EColorControl colorControl() const { return mColorControl; }
    00561     fvec4 ambientColor() const { return mAmbientColor; }
    00562   protected:
    00563     fvec4 mAmbientColor;
    00564     EColorControl mColorControl;
    00565     bool mLocalViewer;
    00566     bool mTwoSide;
    00567   };
    00568   //------------------------------------------------------------------------------
    00569   // Fog
    00570   //------------------------------------------------------------------------------
    00573   class VLGRAPHICS_EXPORT Fog: public RenderState
    00574   {
    00575   public:
    00576     Fog(EFogMode mode=FM_LINEAR, fvec4 color=fvec4(0,0,0,0), float density=1, float start=0, float end=1):
    00577       mColor(color), mMode(mode), mDensity(density), mStart(start), mEnd(end)
    00578     {
    00579       VL_DEBUG_SET_OBJECT_NAME()
    00580     }
    00581     virtual const char* className() { return "vl::Fog"; }
    00582     virtual ERenderState type() const { return RS_Fog; }
    00583     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00584     void set(EFogMode mode, fvec4 color, float density, float start, float end) { mColor = color; mMode = mode; mDensity = density; mStart = start; mEnd = end; }
    00585     void setColor(fvec4 color) { mColor = color; }
    00586     void setMode(EFogMode mode) { mMode = mode; }
    00587     void setDensity(float density) { mDensity = density; }
    00588     void setStart(float start) { mStart = start; }
    00589     void setEnd(float end) { mEnd = end; }
    00590     fvec4 color() const { return mColor; }
    00591     EFogMode mode() const { return mMode; }
    00592     float density() const { return mDensity; }
    00593     float start() const { return mStart; }
    00594     float end() const { return mEnd; }
    00595   protected:
    00596     fvec4 mColor;
    00597     EFogMode mMode;
    00598     float mDensity;
    00599     float mStart;
    00600     float mEnd;
    00601   };
    00602   //------------------------------------------------------------------------------
    00603   // PolygonOffset
    00604   //------------------------------------------------------------------------------
    00607   class VLGRAPHICS_EXPORT PolygonOffset: public RenderState
    00608   {
    00609   public:
    00610     PolygonOffset(): mFactor(0.0f), mUnits(0.0f)
    00611     {
    00612       VL_DEBUG_SET_OBJECT_NAME()
    00613     }
    00614     virtual const char* className() { return "vl::PolygonOffset"; }
    00615     virtual ERenderState type() const { return RS_PolygonOffset; }
    00616     PolygonOffset(float factor, float units): mFactor(factor), mUnits(units) {}
    00617     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00618     void set(float factor, float units) { mFactor = factor; mUnits = units; }
    00619     void setFactor(float factor) { mFactor = factor; }
    00620     void setUnits(float units) { mUnits = units; }
    00621     float factor() const { return mFactor; }
    00622     float units() const { return mUnits; }
    00623   protected:
    00624     float mFactor;
    00625     float mUnits;
    00626   };
    00627   //------------------------------------------------------------------------------
    00628   // LogicOp
    00629   //------------------------------------------------------------------------------
    00632   class VLGRAPHICS_EXPORT LogicOp: public RenderState
    00633   {
    00634   public:
    00635     LogicOp(ELogicOp logicop=LO_COPY): mLogicOp(logicop)
    00636     {
    00637       VL_DEBUG_SET_OBJECT_NAME()
    00638     }
    00639     virtual const char* className() { return "vl::LogicOp"; }
    00640     virtual ERenderState type() const { return RS_LogicOp; }
    00641     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00642     void set(ELogicOp logicop) { mLogicOp = logicop; }
    00643     ELogicOp logicOp() const { return mLogicOp; }
    00644   protected:
    00645     ELogicOp mLogicOp;
    00646   };
    00647   //------------------------------------------------------------------------------
    00648   // DepthRange
    00649   //------------------------------------------------------------------------------
    00652   class VLGRAPHICS_EXPORT DepthRange: public RenderState
    00653   {
    00654   public:
    00655     DepthRange(): mZNear(0), mZFar(1.0f)
    00656     {
    00657       VL_DEBUG_SET_OBJECT_NAME()
    00658     }
    00659     DepthRange(float znear, float zfar): mZNear(znear), mZFar(zfar)
    00660     {
    00661       VL_DEBUG_SET_OBJECT_NAME()
    00662     }
    00663     virtual const char* className() { return "vl::DepthRange"; }
    00664     virtual ERenderState type() const { return RS_DepthRange; }
    00665     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00666     void set(float znear, float zfar) { mZNear = znear; mZFar = zfar; }
    00667     void setZNear(float znear) { mZNear = znear; }
    00668     void setZFar(float zfar) { mZFar = zfar; }
    00669     float zNear() const { return mZNear; }
    00670     float zFar() const { return mZFar; }
    00671   protected:
    00672     float mZNear;
    00673     float mZFar;
    00674   };
    00675   //------------------------------------------------------------------------------
    00676   // LineWidth
    00677   //------------------------------------------------------------------------------
    00680   class VLGRAPHICS_EXPORT LineWidth: public RenderState
    00681   {
    00682   public:
    00683     LineWidth(float linewidth=1.0f): mLineWidth(linewidth)
    00684     {
    00685       VL_DEBUG_SET_OBJECT_NAME()
    00686     }
    00687     virtual const char* className() { return "vl::LineWidth"; }
    00688     virtual ERenderState type() const { return RS_LineWidth; }
    00689     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00690     void set(float linewidth) { mLineWidth = linewidth; }
    00691     float lineWidth() const { return mLineWidth; }
    00692   protected:
    00693     float mLineWidth;
    00694   };
    00695   //------------------------------------------------------------------------------
    00696   // PointSize
    00697   //------------------------------------------------------------------------------
    00700   class VLGRAPHICS_EXPORT PointSize: public RenderState
    00701   {
    00702   public:
    00703     PointSize(float pointsize=1.0f): mPointSize(pointsize)
    00704     {
    00705       VL_DEBUG_SET_OBJECT_NAME()
    00706     }
    00707     virtual const char* className() { return "vl::PointSize"; }
    00708     virtual ERenderState type() const { return RS_PointSize; }
    00709     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00710     void set(float pointsize) { mPointSize = pointsize; }
    00711     float pointSize() const { return mPointSize; }
    00712   protected:
    00713     float mPointSize;
    00714   };
    00715   //------------------------------------------------------------------------------
    00716   // PolygonStipple
    00717   //------------------------------------------------------------------------------
    00720   class VLGRAPHICS_EXPORT PolygonStipple: public RenderState
    00721   {
    00722   public:
    00723     PolygonStipple();
    00724     PolygonStipple(const unsigned char* mask);
    00725     virtual const char* className() { return "vl::PolygonStipple"; }
    00726     virtual ERenderState type() const { return RS_PolygonStipple; }
    00727     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00728     void set(const unsigned char* mask);
    00729     const unsigned char* mask() const { return mMask; }
    00730   protected:
    00731     unsigned char mMask[32*32/8];
    00732   };
    00733   //------------------------------------------------------------------------------
    00734   // LineStipple
    00735   //------------------------------------------------------------------------------
    00738   class VLGRAPHICS_EXPORT LineStipple: public RenderState
    00739   {
    00740   public:
    00741     LineStipple(int factor=1, GLushort pattern=~(GLushort)0): mFactor(factor), mPattern(pattern)
    00742     {
    00743       VL_DEBUG_SET_OBJECT_NAME()
    00744     }
    00745     virtual const char* className() { return "vl::LineStipple"; }
    00746     virtual ERenderState type() const { return RS_LineStipple; }
    00747     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00748     void set(int factor, GLushort pattern) { mFactor = factor; mPattern = pattern; }
    00749     void setFactor(int factor) { mFactor = factor; }
    00750     void setPattern(GLushort pattern) { mPattern = pattern; }
    00751     int factor() const { return mFactor; }
    00752     GLushort pattern() const { return mPattern; }
    00753   protected:
    00754     int mFactor;
    00755     GLushort mPattern;
    00756   };
    00757   //------------------------------------------------------------------------------
    00758   // PointParameter
    00759   //------------------------------------------------------------------------------
    00762   class VLGRAPHICS_EXPORT PointParameter: public RenderState
    00763   {
    00764   public:
    00765     PointParameter(float sizemin=0, float sizemax=1024.0f, float fadethresholdsize=1.0f, fvec3 distanceattenuation=fvec3(1,0,0)):
    00766       mDistanceAttenuation(distanceattenuation), mSizeMin(sizemin), mSizeMax(sizemax), mFadeThresholdSize(fadethresholdsize),
    00767       mPointSpriteCoordOrigin(PPCO_UPPER_LEFT)
    00768     {
    00769       VL_DEBUG_SET_OBJECT_NAME()
    00770     }
    00771     virtual const char* className() { return "vl::PointParameter"; }
    00772     virtual ERenderState type() const { return RS_PointParameter; }
    00773     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00774     void set(float sizemin, float sizemax, float fadethresholdsize, fvec3 distanceattenuation) { mDistanceAttenuation = distanceattenuation; mSizeMin = sizemin; mSizeMax = sizemax; mFadeThresholdSize = fadethresholdsize; }
    00775     void setDistanceAttenuation(fvec3 attenuation) { mDistanceAttenuation = attenuation; }
    00776     void setSizeMin(float sizemin) { mSizeMin = sizemin; }
    00777     void setSizeMax(float sizemax) { mSizeMax = sizemax; }
    00778     void setFadeThresholdSize(float threshold) { mFadeThresholdSize = threshold; }
    00779     fvec3 distanceAttenuation() const { return mDistanceAttenuation; }
    00780     float sizeMin() const { return mSizeMin; }
    00781     float sizeMax() const { return mSizeMax; }
    00782     float fadeThresholdSize() const { return mFadeThresholdSize; }
    00783     EPointSpriteCoordOrigin pointSpriteCoordOrigin() const { return mPointSpriteCoordOrigin; }
    00784     void setPointSpriteCoordOrigin(EPointSpriteCoordOrigin orig) { mPointSpriteCoordOrigin = orig; }
    00785   protected:
    00786     fvec3 mDistanceAttenuation;
    00787     float mSizeMin;
    00788     float mSizeMax;
    00789     float mFadeThresholdSize;
    00790     EPointSpriteCoordOrigin mPointSpriteCoordOrigin;
    00791   };
    00792   //------------------------------------------------------------------------------
    00793   // StencilFunc
    00794   //------------------------------------------------------------------------------
    00799   class VLGRAPHICS_EXPORT StencilFunc: public RenderState
    00800   {
    00801   public:
    00802     StencilFunc(EFunction function=FU_ALWAYS, int refvalue=0, unsigned int mask=~(unsigned int)0):
    00803         mFunction_Front(function), mFunction_Back(function),
    00804         mRefValue_Front(refvalue), mRefValue_Back(refvalue),
    00805         mMask_Front(mask),         mMask_Back(mask)
    00806     {
    00807       VL_DEBUG_SET_OBJECT_NAME()
    00808     }
    00809     virtual const char* className() { return "vl::StencilFunc"; }
    00810     virtual ERenderState type() const { return RS_StencilFunc; }
    00811     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00812     void set(EPolygonFace face, EFunction function, int refvalue, unsigned int mask)
    00813     {
    00814       if (face == PF_FRONT || face == PF_FRONT_AND_BACK)
    00815       {
    00816         mFunction_Front = function;
    00817         mRefValue_Front = refvalue;
    00818         mMask_Front     = mask;
    00819       }
    00820       if (face == PF_BACK || face == PF_FRONT_AND_BACK)
    00821       {
    00822         mFunction_Back = function;
    00823         mRefValue_Back = refvalue;
    00824         mMask_Back     = mask;
    00825       }
    00826     }
    00827     EFunction function_Front() const { return mFunction_Front; }
    00828     int refValue_Front() const { return mRefValue_Front; }
    00829     unsigned int mask_Front() const { return mMask_Front; }
    00830     EFunction function_Back() const { return mFunction_Back; }
    00831     int refValue_Back() const { return mRefValue_Back; }
    00832     unsigned int mask_Back() const { return mMask_Back; }
    00833   protected:
    00834     EFunction mFunction_Front;
    00835     EFunction mFunction_Back;
    00836     int     mRefValue_Front;
    00837     int     mRefValue_Back;
    00838     unsigned int    mMask_Front;
    00839     unsigned int    mMask_Back;
    00840   };
    00841   //------------------------------------------------------------------------------
    00842   // StencilOp
    00843   //------------------------------------------------------------------------------
    00848   class VLGRAPHICS_EXPORT StencilOp: public RenderState
    00849   {
    00850   public:
    00851     StencilOp(EStencilOp sfail=SO_KEEP, EStencilOp dpfail=SO_KEEP, EStencilOp dppass=SO_KEEP):
    00852         mSFail_Front(sfail),   mSFail_Back(sfail),
    00853         mDpFail_Front(dpfail), mDpFail_Back(dpfail),
    00854         mDpPass_Front(dppass), mDpPass_Back(dppass)
    00855     {
    00856       VL_DEBUG_SET_OBJECT_NAME()
    00857     }
    00858     virtual const char* className() { return "vl::StencilOp"; }
    00859     virtual ERenderState type() const { return RS_StencilOp; }
    00860     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00861     void set(EPolygonFace face, EStencilOp sfail, EStencilOp dpfail, EStencilOp dppass)
    00862     {
    00863       if (face == PF_FRONT || face == PF_FRONT_AND_BACK)
    00864       {
    00865         mSFail_Front  = sfail;
    00866         mDpFail_Front = dpfail;
    00867         mDpPass_Front = dppass;
    00868       }
    00869       if (face == PF_BACK || face == PF_FRONT_AND_BACK)
    00870       {
    00871         mSFail_Back  = sfail;
    00872         mDpFail_Back = dpfail;
    00873         mDpPass_Back = dppass;
    00874       }
    00875     }
    00876     EStencilOp sFail_Front()  const { return mSFail_Front;  }
    00877     EStencilOp dpFail_Front() const { return mDpFail_Front; }
    00878     EStencilOp dpPass_Front() const { return mDpPass_Front; }
    00879     EStencilOp sFail_Back()   const { return mSFail_Front;  }
    00880     EStencilOp dpFail_Back()  const { return mDpFail_Front; }
    00881     EStencilOp dpPass_Back()  const { return mDpPass_Front; }
    00882   protected:
    00883     EStencilOp mSFail_Front;
    00884     EStencilOp mSFail_Back;
    00885     EStencilOp mDpFail_Front;
    00886     EStencilOp mDpFail_Back;
    00887     EStencilOp mDpPass_Front;
    00888     EStencilOp mDpPass_Back;
    00889   };
    00890   //------------------------------------------------------------------------------
    00891   // StencilMask
    00892   //------------------------------------------------------------------------------
    00897   class VLGRAPHICS_EXPORT StencilMask: public RenderState
    00898   {
    00899   public:
    00900     StencilMask(unsigned int mask=~(unsigned int)0): mMask_Front(mask), mMask_Back(mask)
    00901     {
    00902       VL_DEBUG_SET_OBJECT_NAME()
    00903     }
    00904     virtual const char* className() { return "vl::StencilMask"; }
    00905     virtual ERenderState type() const { return RS_StencilMask; }
    00906     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00907     void set(EPolygonFace face, unsigned int mask)
    00908     {
    00909       if (face == PF_FRONT || face == PF_FRONT_AND_BACK)
    00910         mMask_Front = mask;
    00911       if (face == PF_BACK  || face == PF_FRONT_AND_BACK)
    00912         mMask_Back = mask;
    00913     }
    00914     unsigned int mask_Front() const { return mMask_Front; }
    00915     unsigned int mask_Back() const { return mMask_Back; }
    00916   protected:
    00917     unsigned int mMask_Front;
    00918     unsigned int mMask_Back;
    00919   };
    00920   //------------------------------------------------------------------------------
    00921   // BlendColor
    00922   //------------------------------------------------------------------------------
    00925   class VLGRAPHICS_EXPORT BlendColor: public RenderState
    00926   {
    00927   public:
    00928     BlendColor(fvec4 blendcolor=fvec4(0,0,0,0)): mBlendColor(blendcolor)
    00929     {
    00930       VL_DEBUG_SET_OBJECT_NAME()
    00931     }
    00932     virtual const char* className() { return "vl::BlendColor"; }
    00933     virtual ERenderState type() const { return RS_BlendColor; }
    00934     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00935     void set(fvec4 blendcolor) { mBlendColor = blendcolor; }
    00936     fvec4 blendColor() const { return mBlendColor; }
    00937   protected:
    00938     fvec4 mBlendColor;
    00939   };
    00940   //------------------------------------------------------------------------------
    00941   // ColorMask
    00942   //------------------------------------------------------------------------------
    00945   class VLGRAPHICS_EXPORT ColorMask: public RenderState
    00946   {
    00947   public:
    00948     ColorMask(bool red=true, bool green=true, bool blue=true, bool alpha=true): mRed(red), mGreen(green), mBlue(blue), mAlpha(alpha)
    00949     {
    00950       VL_DEBUG_SET_OBJECT_NAME()
    00951     }
    00952     virtual const char* className() { return "vl::ColorMask"; }
    00953     virtual ERenderState type() const { return RS_ColorMask; }
    00954     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00955     void set(bool red, bool green, bool blue, bool alpha) { mRed = red; mGreen = green; mBlue = blue; mAlpha = alpha; }
    00956     void setRed(bool red) { mRed = red; }
    00957     void setGreen(bool green) { mGreen = green; }
    00958     void setBlue(bool blue) { mBlue = blue; }
    00959     void setAlpha(bool alpha) { mAlpha = alpha; }
    00960     bool red() const { return mRed; }
    00961     bool green() const { return mGreen; }
    00962     bool blue() const { return mBlue; }
    00963     bool alpha() const { return mAlpha; }
    00964   protected:
    00965     bool mRed;
    00966     bool mGreen;
    00967     bool mBlue;
    00968     bool mAlpha;
    00969   };
    00970   //------------------------------------------------------------------------------
    00971   // TextureMatrix
    00972   //------------------------------------------------------------------------------
    00976   class VLGRAPHICS_EXPORT TextureMatrix: public TextureState
    00977   {
    00978   public:
    00979     virtual const char* className() { return "vl::TextureMatrix"; }
    00980     TextureMatrix(int texunit) { mTextureUnit=texunit; mUseCameraRotationInverse = false; }
    00981     virtual ERenderState type() const { return (ERenderState)(RS_TextureMatrix0 + mTextureUnit); }
    00982     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    00983     const mat4& matrix() const { return mMatrix; }
    00984     const TextureMatrix& setMatrix(const mat4& matrix)
    00985     {
    00986       mMatrix = matrix;
    00987       return *this;
    00988     }
    00995     void setUseCameraRotationInverse(bool use) { mUseCameraRotationInverse = use; }
    00996     bool useCameraRotationInverse() const { return mUseCameraRotationInverse; }
    00997   protected:
    00998     mat4 mMatrix;
    00999     bool mUseCameraRotationInverse;
    01000   };
    01001   //------------------------------------------------------------------------------
    01002   // TexEnv
    01003   //------------------------------------------------------------------------------
    01011   class VLGRAPHICS_EXPORT TexEnv: public TextureState
    01012   {
    01013   public:
    01014     TexEnv(int texunit);
    01015     virtual const char* className() { return "vl::TexEnv"; }
    01016     virtual ERenderState type() const { return (ERenderState)(RS_TexEnv0 + mTextureUnit); }
    01017     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    01018
    01019     void setMode(ETexEnvMode mode) { mMode = mode; }
    01020     ETexEnvMode mode() const { return mMode; }
    01021     void setCombineRGB(ETexEnvMode combineRGB) { mCombineRGB = combineRGB; }
    01022     ETexEnvMode combineRGB() const { return mCombineRGB; }
    01023     void setCombineAlpha(ETexEnvMode combineAlpha) { mCombineAlpha = combineAlpha; }
    01024     ETexEnvMode combineAlpha() const { return mCombineAlpha; }
    01025     void setColor(fvec4 color) { mColor = color; }
    01026     fvec4 color() const { return mColor; }
    01027     void setRGBScale(float rgbscale) { mRGBScale = rgbscale; }
    01028     float rgbScale() const { return mRGBScale; }
    01029     void setAlphaScale(float alphascale) { mAlphaScale = alphascale; }
    01030     float alphaScale() const { return mAlphaScale; }
    01031
    01032     void setSource0RGB(ETexEnvSource source) { mSource0RGB = source; }
    01033     void setSource1RGB(ETexEnvSource source) { mSource1RGB = source; }
    01034     void setSource2RGB(ETexEnvSource source) { mSource2RGB = source; }
    01035     ETexEnvSource source0RGB() const { return mSource0RGB; }
    01036     ETexEnvSource source1RGB() const { return mSource1RGB; }
    01037     ETexEnvSource source2RGB() const { return mSource2RGB; }
    01038     void setSource0Alpha(ETexEnvSource source) { mSource0Alpha = source; }
    01039     void setSource1Alpha(ETexEnvSource source) { mSource1Alpha = source; }
    01040     void setSource2Alpha(ETexEnvSource source) { mSource2Alpha = source; }
    01041     ETexEnvSource source0Alpha() const { return mSource0Alpha; }
    01042     ETexEnvSource source1Alpha() const { return mSource1Alpha; }
    01043     ETexEnvSource source2Alpha() const { return mSource2Alpha; }
    01044
    01045     void setOperand0RGB(ETexEnvOperand operand) { mOperand0RGB = operand; }
    01046     void setOperand1RGB(ETexEnvOperand operand) { mOperand1RGB = operand; }
    01047     void setOperand2RGB(ETexEnvOperand operand) { mOperand2RGB = operand; }
    01048     ETexEnvOperand operand0RGB() const { return mOperand0RGB; }
    01049     ETexEnvOperand operand1RGB() const { return mOperand1RGB; }
    01050     ETexEnvOperand operand2RGB() const { return mOperand2RGB; }
    01051     void setOperand0Alpha(ETexEnvOperand operand) { mOperand0Alpha = operand; }
    01052     void setOperand1Alpha(ETexEnvOperand operand) { mOperand1Alpha = operand; }
    01053     void setOperand2Alpha(ETexEnvOperand operand) { mOperand2Alpha = operand; }
    01054     ETexEnvOperand operand0Alpha() const { return mOperand0Alpha; }
    01055     ETexEnvOperand operand1Alpha() const { return mOperand1Alpha; }
    01056     ETexEnvOperand operand2Alpha() const { return mOperand2Alpha; }
    01057
    01058     void setPointSpriteCoordReplace(bool replace) { mPointSpriteCoordReplace = replace; }
    01059     bool pointSpriteCoordReplace() const { return mPointSpriteCoordReplace; }
    01060
    01061     void setLodBias(float lodbias) { mLodBias = lodbias; }
    01062     float lodBias() const { return mLodBias; }
    01063
    01064   public:
    01065     fvec4 mColor;
    01066     float mRGBScale;
    01067     float mAlphaScale;
    01068     ETexEnvMode mMode;
    01069     ETexEnvMode mCombineRGB;
    01070     ETexEnvMode mCombineAlpha;
    01071     ETexEnvSource mSource0RGB;
    01072     ETexEnvSource mSource1RGB;
    01073     ETexEnvSource mSource2RGB;
    01074     ETexEnvSource mSource0Alpha;
    01075     ETexEnvSource mSource1Alpha;
    01076     ETexEnvSource mSource2Alpha;
    01077     ETexEnvOperand mOperand0RGB;
    01078     ETexEnvOperand mOperand1RGB;
    01079     ETexEnvOperand mOperand2RGB;
    01080     ETexEnvOperand mOperand0Alpha;
    01081     ETexEnvOperand mOperand1Alpha;
    01082     ETexEnvOperand mOperand2Alpha;
    01083     float mLodBias;
    01084     bool mPointSpriteCoordReplace;
    01085   };
    01086   //------------------------------------------------------------------------------
    01087   // TexGen
    01088   //------------------------------------------------------------------------------
    01096   class VLGRAPHICS_EXPORT TexGen: public TextureState
    01097   {
    01098   public:
    01099     TexGen(int texunit);
    01100     virtual const char* className() { return "vl::TexGen"; }
    01101
    01102     virtual ERenderState type() const { return (ERenderState)(RS_TexGen0 + mTextureUnit); }
    01103     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    01104
    01105     void setEyePlaneS(fvec4 plane) { mEyePlaneS = plane; }
    01106     void setObjectPlaneS(fvec4 plane) { mObjectPlaneS = plane; }
    01107     void setGenModeS(ETexGenMode mode) { mGenModeS = mode; }
    01108     fvec4 eyePlaneS() const { return mEyePlaneS; }
    01109     fvec4 objectPlaneS() const { return mObjectPlaneS; }
    01110     ETexGenMode genModeS() const { return mGenModeS; }
    01111
    01112     void setEyePlaneT(fvec4 plane) { mEyePlaneT = plane; }
    01113     void setObjectPlaneT(fvec4 plane) { mObjectPlaneT = plane; }
    01114     void setGenModeT(ETexGenMode mode) { mGenModeT = mode; }
    01115     fvec4 eyePlaneT() const { return mEyePlaneT; }
    01116     fvec4 objectPlaneT() const { return mObjectPlaneT; }
    01117     ETexGenMode genModeT() const { return mGenModeT; }
    01118
    01119     void setEyePlaneR(fvec4 plane) { mEyePlaneR = plane; }
    01120     void setObjectPlaneR(fvec4 plane) { mObjectPlaneR = plane; }
    01121     void setGenModeR(ETexGenMode mode) { mGenModeR = mode; }
    01122     fvec4 eyePlaneR() const { return mEyePlaneR; }
    01123     fvec4 objectPlaneR() const { return mObjectPlaneR; }
    01124     ETexGenMode genModeR() const { return mGenModeR; }
    01125
    01126     void setEyePlaneQ(fvec4 plane) { mEyePlaneQ = plane; }
    01127     void setObjectPlaneQ(fvec4 plane) { mObjectPlaneQ = plane; }
    01128     void setGenModeQ(ETexGenMode mode) { mGenModeQ = mode; }
    01129     fvec4 eyePlaneQ() const { return mEyePlaneQ; }
    01130     fvec4 objectPlaneQ() const { return mObjectPlaneQ; }
    01131     ETexGenMode genModeQ() const { return mGenModeQ; }
    01132
    01133   public:
    01134     fvec4 mEyePlaneS;
    01135     fvec4 mObjectPlaneS;
    01136     fvec4 mEyePlaneT;
    01137     fvec4 mObjectPlaneT;
    01138     fvec4 mEyePlaneR;
    01139     fvec4 mObjectPlaneR;
    01140     fvec4 mEyePlaneQ;
    01141     fvec4 mObjectPlaneQ;
    01142     ETexGenMode mGenModeS;
    01143     ETexGenMode mGenModeT;
    01144     ETexGenMode mGenModeR;
    01145     ETexGenMode mGenModeQ;
    01146   };
    01147   //------------------------------------------------------------------------------
    01148   // TextureUnit
    01149   //------------------------------------------------------------------------------
    01153   class VLGRAPHICS_EXPORT TextureUnit: public TextureState
    01154   {
    01155   public:
    01156     virtual const char* className() { return "vl::TextureUnit"; }
    01157     TextureUnit(int texunit)
    01158     {
    01159       VL_DEBUG_SET_OBJECT_NAME()
    01160       mTextureUnit = texunit;
    01161     }
    01162
    01163     virtual ERenderState type() const { return (ERenderState)(RS_TextureUnit0 + textureUnit()); }
    01164     virtual void apply(const Camera*, OpenGLContext* ctx) const;
    01165
    01166     void setTexture(Texture* texture) { mTexture = texture; }
    01167     Texture* texture() { return mTexture.get(); }
    01168     const Texture* texture() const { return mTexture.get(); }
    01169
    01170     bool hasTexture() const;
    01171
    01172   protected:
    01173     ref<Texture> mTexture;
    01174   };
    01175   //------------------------------------------------------------------------------
    01176   // ShaderAnimator
    01177   //------------------------------------------------------------------------------
    01182   class VLGRAPHICS_EXPORT ShaderAnimator: public Object
    01183   {
    01184   public:
    01185     ShaderAnimator(): mEnabled(true) {}
    01186
    01192     virtual void updateShader(Shader* shader, Camera* camera, Real cur_time) = 0;
    01193
    01195     void setEnabled(bool enable) { mEnabled = enable; }
    01196
    01198     bool isEnabled() const { return mEnabled; }
    01199
    01200   protected:
    01201     bool mEnabled;
    01202   };
    01203   //------------------------------------------------------------------------------
    01204   // Shader
    01205   //------------------------------------------------------------------------------
    01218   class VLGRAPHICS_EXPORT Shader: public Object
    01219   {
    01220   public:
    01221     virtual const char* className() { return "vl::Shader"; }
    01222
    01224     Shader();
    01225
    01227     Shader(const Shader& other): Object(other) { operator=(other); }
    01228
    01230     virtual ~Shader();
    01231
    01234     Shader& operator=(const Shader& other)
    01235     {
    01236       Object::operator=(other);
    01237
    01238       // we don't copy the update time
    01239       // mLastUpdateTime = other.mLastUpdateTime;
    01240
    01241       if (other.mRenderStateSet.get())
    01242       {
    01243         if (mRenderStateSet.get() == NULL)
    01244           mRenderStateSet = new RenderStateSet;
    01245         *mRenderStateSet = *other.mRenderStateSet;
    01246       }
    01247       else
    01248         mRenderStateSet = NULL;
    01249
    01250       if (other.mEnableSet.get())
    01251       {
    01252         if (mEnableSet.get() == NULL)
    01253           mEnableSet = new EnableSet;
    01254         *mEnableSet = *other.mEnableSet;
    01255       }
    01256       else
    01257         mEnableSet = NULL;
    01258
    01259       if (other.mUniformSet.get())
    01260       {
    01261         if (mUniformSet.get() == NULL)
    01262           mUniformSet = new UniformSet;
    01263         *mUniformSet = *other.mUniformSet;
    01264       }
    01265       else
    01266         mUniformSet = NULL;
    01267
    01268       mScissor = other.mScissor;
    01269       mShaderAnimator = other.mShaderAnimator;
    01270
    01271       #if VL_SHADER_USER_DATA
    01272         mShaderUserData = other.mShaderUserData;
    01273       #endif
    01274
    01275       return *this;
    01276     }
    01277
    01279     Shader& copy(const Shader& other)
    01280     {
    01281       return operator=(other);
    01282     }
    01283
    01285     void reset()
    01286     {
    01287       disableAll();
    01288       eraseAllRenderStates();
    01289       eraseAllUniforms();
    01290     }
    01291
    01292     // state getters
    01293
    01295     GLSLProgram* gocGLSLProgram();
    01296
    01298     const GLSLProgram* getGLSLProgram() const;
    01299
    01301     GLSLProgram* getGLSLProgram();
    01302
    01303     PixelTransfer* gocPixelTransfer();
    01304     const PixelTransfer* getPixelTransfer() const { return dynamic_cast<const PixelTransfer*>( getRenderStateSet()->renderState( RS_PixelTransfer) ); }
    01305     PixelTransfer* getPixelTransfer() { return dynamic_cast<PixelTransfer*>( getRenderStateSet()->renderState( RS_PixelTransfer) ); }
    01306
    01307     Hint* gocHint();
    01308     const Hint* getHint() const { return dynamic_cast<const Hint*>( getRenderStateSet()->renderState( RS_Hint) ); }
    01309     Hint* getHint() { return dynamic_cast<Hint*>( getRenderStateSet()->renderState( RS_Hint) ); }
    01310
    01311     CullFace* gocCullFace();
    01312     const CullFace* getCullFace() const { return dynamic_cast<const CullFace*>( getRenderStateSet()->renderState( RS_CullFace ) ); }
    01313     CullFace* getCullFace() { return dynamic_cast<CullFace*>( getRenderStateSet()->renderState( RS_CullFace ) ); }
    01314
    01315     FrontFace* gocFrontFace();
    01316     const FrontFace* getFrontFace() const { return dynamic_cast<const FrontFace*>( getRenderStateSet()->renderState( RS_FrontFace ) ); }
    01317     FrontFace* getFrontFace() { return dynamic_cast<FrontFace*>( getRenderStateSet()->renderState( RS_FrontFace ) ); }
    01318
    01319     DepthFunc* gocDepthFunc();
    01320     const DepthFunc* getDepthFunc() const { return dynamic_cast<const DepthFunc*>( getRenderStateSet()->renderState( RS_DepthFunc ) ); }
    01321     DepthFunc* getDepthFunc() { return dynamic_cast<DepthFunc*>( getRenderStateSet()->renderState( RS_DepthFunc ) ); }
    01322
    01323     DepthMask* gocDepthMask();
    01324     const DepthMask* getDepthMask() const { return dynamic_cast<const DepthMask*>( getRenderStateSet()->renderState( RS_DepthMask ) ); }
    01325     DepthMask* getDepthMask() { return dynamic_cast<DepthMask*>( getRenderStateSet()->renderState( RS_DepthMask ) ); }
    01326
    01327     ColorMask* gocColorMask();
    01328     const ColorMask* getColorMask() const { return dynamic_cast<const ColorMask*>( getRenderStateSet()->renderState( RS_ColorMask ) ); }
    01329     ColorMask* getColorMask() { return dynamic_cast<ColorMask*>( getRenderStateSet()->renderState( RS_ColorMask ) ); }
    01330
    01331     PolygonMode* gocPolygonMode();
    01332     const PolygonMode* getPolygonMode() const { return dynamic_cast<const PolygonMode*>( getRenderStateSet()->renderState( RS_PolygonMode ) ); }
    01333     PolygonMode* getPolygonMode() { return dynamic_cast<PolygonMode*>( getRenderStateSet()->renderState( RS_PolygonMode ) ); }
    01334
    01335     ShadeModel* gocShadeModel();
    01336     const ShadeModel* getShadeModel() const { return dynamic_cast<const ShadeModel*>( getRenderStateSet()->renderState( RS_ShadeModel ) ); }
    01337     ShadeModel* getShadeModel() { return dynamic_cast<ShadeModel*>( getRenderStateSet()->renderState( RS_ShadeModel ) ); }
    01338
    01339     BlendEquation* gocBlendEquation();
    01340     const BlendEquation* getBlendEquation() const { return dynamic_cast<const BlendEquation*>( getRenderStateSet()->renderState( RS_BlendEquation ) ); }
    01341     BlendEquation* getBlendEquation() { return dynamic_cast<BlendEquation*>( getRenderStateSet()->renderState( RS_BlendEquation ) ); }
    01342
    01343     AlphaFunc* gocAlphaFunc();
    01344     const AlphaFunc* getAlphaFunc() const { return dynamic_cast<const AlphaFunc*>( getRenderStateSet()->renderState( RS_AlphaFunc ) ); }
    01345     AlphaFunc* getAlphaFunc() { return dynamic_cast<AlphaFunc*>( getRenderStateSet()->renderState( RS_AlphaFunc ) ); }
    01346
    01347     Material* gocMaterial();
    01348     const Material* getMaterial() const { return dynamic_cast<const Material*>( getRenderStateSet()->renderState( RS_Material ) ); }
    01349     Material* getMaterial() { return dynamic_cast<Material*>( getRenderStateSet()->renderState( RS_Material ) ); }
    01350
    01351     LightModel* gocLightModel();
    01352     const LightModel* getLightModel() const { return dynamic_cast<const LightModel*>( getRenderStateSet()->renderState( RS_LightModel ) ); }
    01353     LightModel* getLightModel() { return dynamic_cast<LightModel*>( getRenderStateSet()->renderState( RS_LightModel ) ); }
    01354
    01355     Fog* gocFog();
    01356     const Fog* getFog() const { return dynamic_cast<const Fog*>( getRenderStateSet()->renderState( RS_Fog ) ); }
    01357     Fog* getFog() { return dynamic_cast<Fog*>( getRenderStateSet()->renderState( RS_Fog ) ); }
    01358
    01359     PolygonOffset* gocPolygonOffset();
    01360     const PolygonOffset* getPolygonOffset() const { return dynamic_cast<const PolygonOffset*>( getRenderStateSet()->renderState( RS_PolygonOffset ) ); }
    01361     PolygonOffset* getPolygonOffset() { return dynamic_cast<PolygonOffset*>( getRenderStateSet()->renderState( RS_PolygonOffset ) ); }
    01362
    01363     LogicOp* gocLogicOp();
    01364     const LogicOp* getLogicOp() const { return dynamic_cast<const LogicOp*>( getRenderStateSet()->renderState( RS_LogicOp ) ); }
    01365     LogicOp* getLogicOp() { return dynamic_cast<LogicOp*>( getRenderStateSet()->renderState( RS_LogicOp ) ); }
    01366
    01367     DepthRange* gocDepthRange();
    01368     const DepthRange* getDepthRange() const { return dynamic_cast<const DepthRange*>( getRenderStateSet()->renderState( RS_DepthRange ) ); }
    01369     DepthRange* getDepthRange() { return dynamic_cast<DepthRange*>( getRenderStateSet()->renderState( RS_DepthRange ) ); }
    01370
    01371     LineWidth* gocLineWidth();
    01372     const LineWidth* getLineWidth() const { return dynamic_cast<const LineWidth*>( getRenderStateSet()->renderState( RS_LineWidth ) ); }
    01373     LineWidth* getLineWidth() { return dynamic_cast<LineWidth*>( getRenderStateSet()->renderState( RS_LineWidth ) ); }
    01374
    01375     PointSize* gocPointSize();
    01376     const PointSize* getPointSize() const { return dynamic_cast<const PointSize*>( getRenderStateSet()->renderState( RS_PointSize ) ); }
    01377     PointSize* getPointSize() { return dynamic_cast<PointSize*>( getRenderStateSet()->renderState( RS_PointSize ) ); }
    01378
    01379     LineStipple* gocLineStipple();
    01380     const LineStipple* getLineStipple() const { return dynamic_cast<const LineStipple*>( getRenderStateSet()->renderState( RS_LineStipple ) ); }
    01381     LineStipple* getLineStipple() { return dynamic_cast<LineStipple*>( getRenderStateSet()->renderState( RS_LineStipple ) ); }
    01382
    01383     PolygonStipple* gocPolygonStipple();
    01384     const PolygonStipple* getPolygonStipple() const { return dynamic_cast<const PolygonStipple*>( getRenderStateSet()->renderState( RS_PolygonStipple ) ); }
    01385     PolygonStipple* getPolygonStipple() { return dynamic_cast<PolygonStipple*>( getRenderStateSet()->renderState( RS_PolygonStipple ) ); }
    01386
    01387     PointParameter* gocPointParameter();
    01388     const PointParameter* getPointParameter() const { return dynamic_cast<const PointParameter*>( getRenderStateSet()->renderState( RS_PointParameter ) ); }
    01389     PointParameter* getPointParameter() { return dynamic_cast<PointParameter*>( getRenderStateSet()->renderState( RS_PointParameter ) ); }
    01390
    01391     StencilFunc* gocStencilFunc();
    01392     const StencilFunc* getStencilFunc() const { return dynamic_cast<const StencilFunc*>( getRenderStateSet()->renderState( RS_StencilFunc ) ); }
    01393     StencilFunc* getStencilFunc() { return dynamic_cast<StencilFunc*>( getRenderStateSet()->renderState( RS_StencilFunc ) ); }
    01394
    01395     StencilOp* gocStencilOp();
    01396     const StencilOp* getStencilOp() const { return dynamic_cast<const StencilOp*>( getRenderStateSet()->renderState( RS_StencilOp ) ); }
    01397     StencilOp* getStencilOp() { return dynamic_cast<StencilOp*>( getRenderStateSet()->renderState( RS_StencilOp ) ); }
    01398
    01399     StencilMask* gocStencilMask();
    01400     const StencilMask* getStencilMask() const { return dynamic_cast<const StencilMask*>( getRenderStateSet()->renderState( RS_StencilMask ) ); }
    01401     StencilMask* getStencilMask() { return dynamic_cast<StencilMask*>( getRenderStateSet()->renderState( RS_StencilMask ) ); }
    01402
    01403     BlendColor* gocBlendColor();
    01404     const BlendColor* getBlendColor() const { return dynamic_cast<const BlendColor*>( getRenderStateSet()->renderState( RS_BlendColor ) ); }
    01405     BlendColor* getBlendColor() { return dynamic_cast<BlendColor*>( getRenderStateSet()->renderState( RS_BlendColor ) ); }
    01406
    01407     BlendFunc* gocBlendFunc();
    01408     const BlendFunc* getBlendFunc() const { return dynamic_cast<const BlendFunc*>( getRenderStateSet()->renderState( RS_BlendFunc ) ); }
    01409     BlendFunc* getBlendFunc() { return dynamic_cast<BlendFunc*>( getRenderStateSet()->renderState( RS_BlendFunc ) ); }
    01410
    01411     SampleCoverage* gocSampleCoverage();
    01412     const SampleCoverage* getSampleCoverage() const { return dynamic_cast<const SampleCoverage*>( getRenderStateSet()->renderState( RS_SampleCoverage ) ); }
    01413     SampleCoverage* getSampleCoverage() { return dynamic_cast<SampleCoverage*>( getRenderStateSet()->renderState( RS_SampleCoverage ) ); }
    01414
    01415     // indexed render states
    01416
    01417     // lights
    01418
    01419     Light* gocLight(int light_index);
    01420
    01421     const Light* getLight(int light_index) const;
    01422
    01423     Light* getLight(int light_index);
    01424
    01425     // clip planes
    01426
    01427     ClipPlane* gocClipPlane(int plane_index);
    01428
    01429     const ClipPlane* getClipPlane(int plane_index) const;
    01430
    01431     ClipPlane* getClipPlane(int plane_index);
    01432
    01433     // texture unit
    01434
    01435     TextureUnit* gocTextureUnit(int unit_index);
    01436
    01437     const TextureUnit* getTextureUnit(int unit_index) const { return dynamic_cast<const TextureUnit*>( getRenderStateSet()->renderState( (ERenderState)(RS_TextureUnit0+unit_index) ) ); }
    01438
    01439     TextureUnit* getTextureUnit(int unit_index) { return dynamic_cast<TextureUnit*>( getRenderStateSet()->renderState( (ERenderState)(RS_TextureUnit0+unit_index) ) ); }
    01440
    01441     // tex env
    01442
    01443     TexEnv* gocTexEnv(int unit_index);
    01444
    01445     const TexEnv* getTexEnv(int unit_index) const { return dynamic_cast<const TexEnv*>( getRenderStateSet()->renderState( (ERenderState)(RS_TexEnv0+unit_index) ) ); }
    01446
    01447     TexEnv* getTexEnv(int unit_index) { return dynamic_cast<TexEnv*>( getRenderStateSet()->renderState( (ERenderState)(RS_TexEnv0+unit_index) ) ); }
    01448
    01449     // tex gen
    01450
    01451     TexGen* gocTexGen(int unit_index);
    01452
    01453     const TexGen* getTexGen(int unit_index) const { return dynamic_cast<const TexGen*>( getRenderStateSet()->renderState( (ERenderState)(RS_TexGen0+unit_index) ) ); }
    01454
    01455     TexGen* getTexGen(int unit_index) { return dynamic_cast<TexGen*>( getRenderStateSet()->renderState( (ERenderState)(RS_TexGen0+unit_index) ) ); }
    01456
    01457     // texture matrix
    01458
    01459     TextureMatrix* gocTextureMatrix(int unit_index);
    01460
    01461     const TextureMatrix* getTextureMatrix(int unit_index) const { return dynamic_cast<const TextureMatrix*>( getRenderStateSet()->renderState( (ERenderState)(RS_TextureMatrix0+unit_index) ) ); }
    01462
    01463     TextureMatrix* getTextureMatrix(int unit_index) { return dynamic_cast<TextureMatrix*>( getRenderStateSet()->renderState( (ERenderState)(RS_TextureMatrix0+unit_index) ) ); }
    01464
    01465     // enable methods
    01466
    01467     void enable(EEnable capability)  { gocEnableSet()->enable(capability); }
    01468
    01469     void disable(EEnable capability) { gocEnableSet()->disable(capability); }
    01470
    01471     const std::vector<EEnable>& enables() const { return getEnableSet()->enables(); }
    01472
    01473     int isEnabled(EEnable capability) const { if (!getEnableSet()) return false; return getEnableSet()->isEnabled(capability); }
    01474
    01475     void disableAll() { if (getEnableSet()) getEnableSet()->disableAll(); }
    01476
    01477     bool blendingEnabled() const { if (!getEnableSet()) return false; return getEnableSet()->blendingEnabled(); }
    01478
    01479     // render states methods
    01480
    01481     void setRenderState(RenderState* renderstate) { gocRenderStateSet()->setRenderState(renderstate); }
    01482
    01483     const RenderState* renderState( ERenderState type ) const { if (!getRenderStateSet()) return NULL; return getRenderStateSet()->renderState(type); }
    01484
    01485     RenderState* renderState( ERenderState type ) { return gocRenderStateSet()->renderState(type); }
    01486
    01487     const std::vector< ref<RenderState> >& renderStates() const { return getRenderStateSet()->renderStates(); }
    01488
    01489     void eraseRenderState(ERenderState type) { gocRenderStateSet()->eraseRenderState(type); }
    01490
    01491     void eraseRenderState(RenderState* rs) { if (rs) gocRenderStateSet()->eraseRenderState(rs->type()); }
    01492
    01493     void eraseAllRenderStates() { if(getRenderStateSet()) getRenderStateSet()->eraseAllRenderStates(); }
    01494
    01496     const GLSLProgram* glslProgram() const { if (!getRenderStateSet()) return NULL; return getRenderStateSet()->glslProgram(); }
    01497
    01499     GLSLProgram* glslProgram() { return gocRenderStateSet()->glslProgram(); }
    01500
    01501     // uniforms methods
    01502
    01504     void setUniform(Uniform* uniform) { VL_CHECK(uniform); gocUniformSet()->setUniform(uniform); }
    01505
    01507     const std::vector< ref<Uniform> >& uniforms() const { return getUniformSet()->uniforms(); }
    01508
    01510     void eraseUniform(const std::string& name) { gocUniformSet()->eraseUniform(name); }
    01511
    01513     void eraseUniform(const Uniform* uniform) { gocUniformSet()->eraseUniform(uniform); }
    01514
    01516     void eraseAllUniforms() { if (getUniformSet()) getUniformSet()->eraseAllUniforms(); }
    01517
    01519     Uniform* gocUniform(const std::string& name) { return gocUniformSet()->gocUniform(name); }
    01520
    01522     Uniform* getUniform(const std::string& name) { return getUniformSet()->getUniform(name); }
    01523
    01525     const Uniform* getUniform(const std::string& name) const { return getUniformSet()->getUniform(name); }
    01526
    01527     // sets
    01528
    01529     EnableSet* gocEnableSet() { if (!mEnableSet) mEnableSet = new EnableSet; return mEnableSet.get(); }
    01530
    01531     EnableSet* getEnableSet() { return mEnableSet.get(); }
    01532
    01533     const EnableSet* getEnableSet() const { return mEnableSet.get(); }
    01534
    01535     RenderStateSet* gocRenderStateSet() { if (!mRenderStateSet) mRenderStateSet = new RenderStateSet; return mRenderStateSet.get(); }
    01536
    01537     RenderStateSet* getRenderStateSet() { return mRenderStateSet.get(); }
    01538
    01539     const RenderStateSet* getRenderStateSet() const { return mRenderStateSet.get(); }
    01540
    01551     UniformSet* gocUniformSet() { if (!mUniformSet) mUniformSet = new UniformSet; return mUniformSet.get(); }
    01552
    01563     UniformSet* getUniformSet() { return mUniformSet.get(); }
    01564
    01575     const UniformSet* getUniformSet() const { return mUniformSet.get(); }
    01576
    01577     void setEnableSet(EnableSet* es) { mEnableSet = es; }
    01578
    01579     void setRenderStateSet(RenderStateSet* rss) { mRenderStateSet = rss; }
    01580
    01591     void setUniformSet(UniformSet* us) { mUniformSet = us; }
    01592
    01602     void setScissor(Scissor* scissor) { mScissor = scissor; }
    01603
    01611     const Scissor* scissor() const { return mScissor.get(); }
    01612
    01620     Scissor* scissor() { return mScissor.get(); }
    01621
    01623     void setShaderAnimator(ShaderAnimator* animator) { mShaderAnimator = animator; }
    01624
    01626     ShaderAnimator* shaderAnimator() { return mShaderAnimator.get(); }
    01627
    01629     const ShaderAnimator* shaderAnimator() const { return mShaderAnimator.get(); }
    01630
    01632     Real lastUpdateTime() const { return mLastUpdateTime; }
    01633
    01635     void setLastUpdateTime(Real time) { mLastUpdateTime = time; }
    01636
    01637 #if VL_SHADER_USER_DATA
    01638   public:
    01639     void* shaderUserData() { return mShaderUserData; }
    01640     const void* shaderUserData() const { return mShaderUserData; }
    01641     void setShaderUserData(void* user_data) { mShaderUserData = user_data; }
    01642
    01643   private:
    01644     void* mShaderUserData;
    01645 #endif
    01646
    01647   protected:
    01648     ref<RenderStateSet> mRenderStateSet;
    01649     ref<EnableSet> mEnableSet;
    01650     ref<UniformSet> mUniformSet;
    01651     ref<Scissor> mScissor;
    01652     ref<ShaderAnimator> mShaderAnimator;
    01653     Real mLastUpdateTime;
    01654   };
    01655 }
    01656
    01657 #endif

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:25.
Permission is granted to use this page to write and publish articles regarding Visualization Library.