00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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 <vlGraphics/Light.hpp>
00045 #include <vlGraphics/ClipPlane.hpp>
00046 #include <vector>
00047
00048 namespace vl
00049 {
00050 class Light;
00051 class ClipPlane;
00052 class Shader;
00053
00054
00055
00059
00060 class VLGRAPHICS_EXPORT VertexAttrib: public RenderStateIndexed
00061 {
00062 VL_INSTRUMENT_CLASS(vl::VertexAttrib, RenderStateIndexed)
00063
00064 public:
00065 VertexAttrib(): mValue( fvec4(0,0,0,0) )
00066 {
00067 VL_DEBUG_SET_OBJECT_NAME()
00068 }
00069
00070 virtual ERenderState type() const { return RS_VertexAttrib; }
00071
00072 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00073
00074 void setValue(const fvec4& value) { mValue = value; }
00075
00076 const fvec4& value() const { return mValue; }
00077
00078 virtual ref<RenderState> clone() const
00079 {
00080 ref<VertexAttrib> rs = new VertexAttrib;
00081 *rs = *this;
00082 return rs;
00083 }
00084
00085 protected:
00086 fvec4 mValue;
00087 };
00088
00089
00090
00094 class VLGRAPHICS_EXPORT Color: public RenderStateNonIndexed
00095 {
00096 VL_INSTRUMENT_CLASS(vl::Color, RenderStateNonIndexed)
00097
00098 public:
00099 Color(): mColor( fvec4(1,1,1,1) )
00100 {
00101 VL_DEBUG_SET_OBJECT_NAME()
00102 }
00103
00104 virtual ERenderState type() const { return RS_Color; }
00105
00106 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00107
00108 void setValue(const fvec4& color) { mColor = color; }
00109
00110 const fvec4& value() const { return mColor; }
00111
00112 virtual ref<RenderState> clone() const
00113 {
00114 ref<Color> rs = new Color;
00115 *rs = *this;
00116 return rs;
00117 }
00118
00119 protected:
00120 fvec4 mColor;
00121 };
00122
00123
00124
00128 class VLGRAPHICS_EXPORT SecondaryColor: public RenderStateNonIndexed
00129 {
00130 VL_INSTRUMENT_CLASS(vl::SecondaryColor, RenderStateNonIndexed)
00131
00132 public:
00133 SecondaryColor(): mSecondaryColor( fvec3(1,1,1) )
00134 {
00135 VL_DEBUG_SET_OBJECT_NAME()
00136 }
00137
00138 virtual ERenderState type() const { return RS_SecondaryColor; }
00139
00140 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00141
00142 void setValue(const fvec3& color) { mSecondaryColor = color; }
00143
00144 const fvec3& value() const { return mSecondaryColor; }
00145
00146 virtual ref<RenderState> clone() const
00147 {
00148 ref<SecondaryColor> rs = new SecondaryColor;
00149 *rs = *this;
00150 return rs;
00151 }
00152
00153 protected:
00154 fvec3 mSecondaryColor;
00155 };
00156
00157
00158
00162 class VLGRAPHICS_EXPORT Normal: public RenderStateNonIndexed
00163 {
00164 VL_INSTRUMENT_CLASS(vl::Normal, RenderStateNonIndexed)
00165
00166 public:
00167 Normal(): mNormal( fvec3(0,1,0) )
00168 {
00169 VL_DEBUG_SET_OBJECT_NAME()
00170 }
00171
00172 virtual ERenderState type() const { return RS_Normal; }
00173
00174 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00175
00176 void setValue(const fvec3& color) { mNormal = color; }
00177
00178 const fvec3& value() const { return mNormal; }
00179
00180 virtual ref<RenderState> clone() const
00181 {
00182 ref<Normal> rs = new Normal;
00183 *rs = *this;
00184 return rs;
00185 }
00186
00187 protected:
00188 fvec3 mNormal;
00189 };
00190
00191
00192
00196 class VLGRAPHICS_EXPORT PixelTransfer: public RenderStateNonIndexed
00197 {
00198 VL_INSTRUMENT_CLASS(vl::PixelTransfer, RenderStateNonIndexed)
00199
00200 public:
00201 PixelTransfer()
00202 {
00203 VL_DEBUG_SET_OBJECT_NAME()
00204 mMapColor = false;
00205 mMapStencil = false;
00206 mIndexShift = 0;
00207 mIndexOffset = 0;
00208 mRedScale = 1;
00209 mGreenScale = 1;
00210 mBlueScale = 1;
00211 mAlphaScale = 1;
00212 mDepthScale = 1;
00213 mRedBias = 0;
00214 mGreenBias = 0;
00215 mBlueBias = 0;
00216 mAlphaBias = 0;
00217 mDepthBias = 0;
00218 mPostColorMatrixRedScale = 1;
00219 mPostColorMatrixGreenScale = 1;
00220 mPostColorMatrixBlueScale = 1;
00221 mPostColorMatrixAlphaScale = 1;
00222 mPostColorMatrixRedBias = 0;
00223 mPostColorMatrixGreenBias = 0;
00224 mPostColorMatrixBlueBias = 0;
00225 mPostColorMatrixAlphaBias = 0;
00226 mPostConvolutionRedScale = 1;
00227 mPostConvolutionGreenScale = 1;
00228 mPostConvolutionBlueScale = 1;
00229 mPostConvolutionAlphaScale = 1;
00230 mPostConvolutionRedBias = 0;
00231 mPostConvolutionGreenBias = 0;
00232 mPostConvolutionBlueBias = 0;
00233 mPostConvolutionAlphaBias = 0;
00234 }
00235
00236 virtual ERenderState type() const { return RS_PixelTransfer; }
00237
00238 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00239
00240 bool mapColor() const { return mMapColor; }
00241 bool mapStencil() const { return mMapStencil; }
00242 int indexShift() const { return mIndexShift; }
00243 int indexOffset() const { return mIndexOffset; }
00244 float redScale() const { return mRedScale; }
00245 float greenScale() const { return mGreenScale; }
00246 float blueScale() const { return mBlueScale; }
00247 float alphaScale() const { return mAlphaScale; }
00248 float depthScale() const { return mDepthScale; }
00249 float redBias() const { return mRedBias; }
00250 float greenBias() const { return mGreenBias; }
00251 float blueBias() const { return mBlueBias; }
00252 float alphaBias() const { return mAlphaBias; }
00253 float depthBias() const { return mDepthBias; }
00254 float postColorMatrixRedScale() const { return mPostColorMatrixRedScale; }
00255 float postColorMatrixGreenScale() const { return mPostColorMatrixGreenScale; }
00256 float postColorMatrixBlueScale() const { return mPostColorMatrixBlueScale; }
00257 float postColorMatrixAlphaScale() const { return mPostColorMatrixAlphaScale; }
00258 float postColorMatrixRedBias() const { return mPostColorMatrixRedBias; }
00259 float postColorMatrixGreenBias() const { return mPostColorMatrixGreenBias; }
00260 float postColorMatrixBlueBias() const { return mPostColorMatrixBlueBias; }
00261 float postColorMatrixAlphaBias() const { return mPostColorMatrixAlphaBias; }
00262 float postConvolutionRedScale() const { return mPostConvolutionRedScale; }
00263 float postConvolutionGreenScale() const { return mPostConvolutionGreenScale; }
00264 float postConvolutionBlueScale() const { return mPostConvolutionBlueScale; }
00265 float postConvolutionAlphaScale() const { return mPostConvolutionAlphaScale; }
00266 float postConvolutionRedBias() const { return mPostConvolutionRedBias; }
00267 float postConvolutionGreenBias() const { return mPostConvolutionGreenBias; }
00268 float postConvolutionBlueBias() const { return mPostConvolutionBlueBias; }
00269 float postConvolutionAlphaBias() const { return mPostConvolutionAlphaBias; }
00270
00271 void setMapColor(bool map_color) { mMapColor = map_color; }
00272 void setMapStencil(bool map_stencil) { mMapStencil = map_stencil; }
00273 void setIndexShift(int index_shift) { mIndexShift = index_shift; }
00274 void setIndexOffset(int index_offset) { mIndexOffset = index_offset; }
00275 void setRedScale(float red_scale) { mRedScale = red_scale; }
00276 void setGreenScale(float green_scale) { mGreenScale = green_scale; }
00277 void setBlueScale(float blue_scale) { mBlueScale = blue_scale; }
00278 void setAlphaScale(float alpha_scale) { mAlphaScale = alpha_scale; }
00279 void setDepthScale(float depth_scale) { mDepthScale = depth_scale; }
00280 void setRedBias(float red_bias) { mRedBias = red_bias; }
00281 void setGreenBias(float green_bias) { mGreenBias = green_bias; }
00282 void setBlueBias(float blue_bias) { mBlueBias = blue_bias; }
00283 void setAlphaBias(float alpha_bias) { mAlphaBias = alpha_bias; }
00284 void setDepthBias(float depth_bias) { mDepthBias = depth_bias; }
00285 void setPostColorMatrixRedScale(float scale) { mPostColorMatrixRedScale = scale; }
00286 void setPostColorMatrixGreenScale(float scale) { mPostColorMatrixGreenScale = scale; }
00287 void setPostColorMatrixBlueScale(float scale) { mPostColorMatrixBlueScale = scale; }
00288 void setPostColorMatrixAlphaScale(float scale) { mPostColorMatrixAlphaScale = scale; }
00289 void setPostColorMatrixRedBias(float bias) { mPostColorMatrixRedBias = bias; }
00290 void setPostColorMatrixGreenBias(float bias) { mPostColorMatrixGreenBias = bias; }
00291 void setPostColorMatrixBlueBias(float bias) { mPostColorMatrixBlueBias = bias; }
00292 void setPostColorMatrixAlphaBias(float bias) { mPostColorMatrixAlphaBias = bias; }
00293 void setPostConvolutionRedScale(float scale) { mPostConvolutionRedScale = scale; }
00294 void setPostConvolutionGreenScale(float scale) { mPostConvolutionGreenScale = scale; }
00295 void setPostConvolutionBlueScale(float scale) { mPostConvolutionBlueScale = scale; }
00296 void setPostConvolutionAlphaScale(float scale) { mPostConvolutionAlphaScale = scale; }
00297 void setPostConvolutionRedBias(float bias) { mPostConvolutionRedBias = bias; }
00298 void setPostConvolutionGreenBias(float bias) { mPostConvolutionGreenBias = bias; }
00299 void setPostConvolutionBlueBias(float bias) { mPostConvolutionBlueBias = bias; }
00300 void setPostConvolutionAlphaBias(float bias) { mPostConvolutionAlphaBias = bias; }
00301
00302 virtual ref<RenderState> clone() const
00303 {
00304 ref<PixelTransfer> rs = new PixelTransfer;
00305 *rs = *this;
00306 return rs;
00307 }
00308
00309 protected:
00310 bool mMapColor;
00311 bool mMapStencil;
00312 int mIndexShift;
00313 int mIndexOffset;
00314 float mRedScale;
00315 float mGreenScale;
00316 float mBlueScale;
00317 float mAlphaScale;
00318 float mDepthScale;
00319 float mRedBias;
00320 float mGreenBias;
00321 float mBlueBias;
00322 float mAlphaBias;
00323 float mDepthBias;
00324 float mPostColorMatrixRedScale;
00325 float mPostColorMatrixGreenScale;
00326 float mPostColorMatrixBlueScale;
00327 float mPostColorMatrixAlphaScale;
00328 float mPostColorMatrixRedBias;
00329 float mPostColorMatrixGreenBias;
00330 float mPostColorMatrixBlueBias;
00331 float mPostColorMatrixAlphaBias;
00332 float mPostConvolutionRedScale;
00333 float mPostConvolutionGreenScale;
00334 float mPostConvolutionBlueScale;
00335 float mPostConvolutionAlphaScale;
00336 float mPostConvolutionRedBias;
00337 float mPostConvolutionGreenBias;
00338 float mPostConvolutionBlueBias;
00339 float mPostConvolutionAlphaBias;
00340 };
00341
00342
00343
00346 class VLGRAPHICS_EXPORT Hint: public RenderStateNonIndexed
00347 {
00348 VL_INSTRUMENT_CLASS(vl::Hint, RenderStateNonIndexed)
00349
00350 public:
00351 Hint(): mPerspectiveCorrectionHint(HM_DONT_CARE), mPointSmoothHint(HM_DONT_CARE), mLineSmoothHint(HM_DONT_CARE),
00352 mPolygonSmoothHint(HM_DONT_CARE), mFogHint(HM_DONT_CARE), mGenerateMipmapHint(HM_DONT_CARE)
00353 {
00354 VL_DEBUG_SET_OBJECT_NAME()
00355 }
00356
00357 virtual ERenderState type() const { return RS_Hint; }
00358
00359 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00360
00361 void setPerspectiveCorrectionHint(EHintMode mode) { mPerspectiveCorrectionHint = mode; }
00362 void setPolygonSmoohtHint(EHintMode mode) { mPolygonSmoothHint = mode; }
00363 void setLineSmoothHint(EHintMode mode) { mLineSmoothHint = mode; }
00364 void setPointSmoothHint(EHintMode mode) { mPointSmoothHint = mode; }
00365 void setFogHint(EHintMode mode) { mFogHint = mode; }
00366 void setGenerateMipmapHint(EHintMode mode) { mGenerateMipmapHint = mode; }
00367
00368 EHintMode perspectiveCorrectionHint() const { return mPerspectiveCorrectionHint; }
00369 EHintMode polygonSmoohtHint() const { return mPolygonSmoothHint; }
00370 EHintMode lineSmoothHint() const { return mLineSmoothHint; }
00371 EHintMode pointSmoothHint() const { return mPointSmoothHint; }
00372 EHintMode fogHint() const { return mFogHint; }
00373 EHintMode generateMipmapHint() const { return mGenerateMipmapHint; }
00374
00375 virtual ref<RenderState> clone() const
00376 {
00377 ref<Hint> rs = new Hint;
00378 *rs = *this;
00379 return rs;
00380 }
00381
00382 protected:
00383 EHintMode mPerspectiveCorrectionHint;
00384 EHintMode mPointSmoothHint;
00385 EHintMode mLineSmoothHint;
00386 EHintMode mPolygonSmoothHint;
00387 EHintMode mFogHint;
00388 EHintMode mGenerateMipmapHint;
00389 };
00390
00391
00392
00395 class VLGRAPHICS_EXPORT CullFace: public RenderStateNonIndexed
00396 {
00397 VL_INSTRUMENT_CLASS(vl::CullFace, RenderStateNonIndexed)
00398
00399 public:
00400 CullFace(EPolygonFace cullface=PF_BACK): mFaceMode(cullface)
00401 {
00402 VL_DEBUG_SET_OBJECT_NAME()
00403 }
00404
00405 virtual ERenderState type() const { return RS_CullFace; }
00406
00407 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00408
00409 void set(EPolygonFace facemode) { mFaceMode = facemode; }
00410
00411 EPolygonFace faceMode() const { return mFaceMode; }
00412
00413 virtual ref<RenderState> clone() const
00414 {
00415 ref<CullFace> rs = new CullFace;
00416 *rs = *this;
00417 return rs;
00418 }
00419
00420 protected:
00421 EPolygonFace mFaceMode;
00422 };
00423
00424
00425
00428 class VLGRAPHICS_EXPORT FrontFace: public RenderStateNonIndexed
00429 {
00430 VL_INSTRUMENT_CLASS(vl::FrontFace, RenderStateNonIndexed)
00431
00432 public:
00433 FrontFace(EFrontFace frontface=FF_CCW): mFrontFace(frontface)
00434 {
00435 VL_DEBUG_SET_OBJECT_NAME()
00436 }
00437
00438 virtual ERenderState type() const { return RS_FrontFace; }
00439
00440 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00441
00442 void set(EFrontFace frontface) { mFrontFace = frontface; }
00443
00444 EFrontFace frontFace() const { return mFrontFace; }
00445
00446 virtual ref<RenderState> clone() const
00447 {
00448 ref<FrontFace> rs = new FrontFace;
00449 *rs = *this;
00450 return rs;
00451 }
00452
00453 protected:
00454 EFrontFace mFrontFace;
00455 };
00456
00457
00458
00461 class VLGRAPHICS_EXPORT DepthFunc: public RenderStateNonIndexed
00462 {
00463 VL_INSTRUMENT_CLASS(vl::DepthFunc, RenderStateNonIndexed)
00464
00465 public:
00466 DepthFunc(EFunction depthfunc=FU_LESS): mDepthFunc(depthfunc)
00467 {
00468 VL_DEBUG_SET_OBJECT_NAME()
00469 }
00470
00471 virtual ERenderState type() const { return RS_DepthFunc; }
00472
00473 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00474
00475 void set(EFunction depthfunc) { mDepthFunc = depthfunc; }
00476
00477 EFunction depthFunc() const { return mDepthFunc; }
00478
00479 virtual ref<RenderState> clone() const
00480 {
00481 ref<DepthFunc> rs = new DepthFunc;
00482 *rs = *this;
00483 return rs;
00484 }
00485
00486 protected:
00487 EFunction mDepthFunc;
00488 };
00489
00490
00491
00494 class VLGRAPHICS_EXPORT DepthMask: public RenderStateNonIndexed
00495 {
00496 VL_INSTRUMENT_CLASS(vl::DepthMask, RenderStateNonIndexed)
00497
00498 public:
00499 DepthMask(bool depthmask=true): mDepthMask(depthmask)
00500 {
00501 VL_DEBUG_SET_OBJECT_NAME()
00502 }
00503
00504 virtual ERenderState type() const { return RS_DepthMask; }
00505
00506 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00507
00508 void set(bool depthmask) { mDepthMask = depthmask; }
00509
00510 bool depthMask() const { return mDepthMask; }
00511
00512 virtual ref<RenderState> clone() const
00513 {
00514 ref<DepthMask> rs = new DepthMask;
00515 *rs = *this;
00516 return rs;
00517 }
00518
00519 protected:
00520 bool mDepthMask;
00521 };
00522
00523
00524
00527 class VLGRAPHICS_EXPORT PolygonMode: public RenderStateNonIndexed
00528 {
00529 VL_INSTRUMENT_CLASS(vl::PolygonMode, RenderStateNonIndexed)
00530
00531 public:
00532 PolygonMode(EPolygonMode frontface=PM_FILL, EPolygonMode backface=PM_FILL): mFrontFace(frontface), mBackFace(backface)
00533 {
00534 VL_DEBUG_SET_OBJECT_NAME()
00535 }
00536
00537 virtual ERenderState type() const { return RS_PolygonMode; }
00538
00539 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00540
00541 void set(EPolygonMode frontface, EPolygonMode backface) { mFrontFace = frontface; mBackFace = backface; }
00542
00543 void setFrontFace(EPolygonMode frontface) { mFrontFace = frontface; }
00544
00545 void setBackFace(EPolygonMode backface) { mBackFace = backface; }
00546
00547 EPolygonMode frontFace() const { return mFrontFace; }
00548
00549 EPolygonMode backFace() const { return mBackFace; }
00550
00551 virtual ref<RenderState> clone() const
00552 {
00553 ref<PolygonMode> rs = new PolygonMode;
00554 *rs = *this;
00555 return rs;
00556 }
00557
00558 protected:
00559 EPolygonMode mFrontFace;
00560 EPolygonMode mBackFace;
00561 };
00562
00563
00564
00567 class VLGRAPHICS_EXPORT ShadeModel: public RenderStateNonIndexed
00568 {
00569 VL_INSTRUMENT_CLASS(vl::ShadeModel, RenderStateNonIndexed)
00570
00571 public:
00572 ShadeModel(EShadeModel shademodel=SM_SMOOTH): mShadeModel(shademodel)
00573 {
00574 VL_DEBUG_SET_OBJECT_NAME()
00575 }
00576
00577 virtual ERenderState type() const { return RS_ShadeModel; }
00578
00579 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00580
00581 void set(EShadeModel shademodel) { mShadeModel = shademodel; }
00582
00583 EShadeModel shadeModel() const { return mShadeModel; }
00584
00585 virtual ref<RenderState> clone() const
00586 {
00587 ref<ShadeModel> rs = new ShadeModel;
00588 *rs = *this;
00589 return rs;
00590 }
00591
00592 protected:
00593 EShadeModel mShadeModel;
00594 };
00595
00596
00597
00600 class VLGRAPHICS_EXPORT BlendFunc: public RenderStateNonIndexed
00601 {
00602 VL_INSTRUMENT_CLASS(vl::BlendFunc, RenderStateNonIndexed)
00603
00604 public:
00605 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):
00606 mSrcRGB(src_rgb), mDstRGB(dst_rgb), mSrcAlpha(src_alpha), mDstAlpha(dst_alpha)
00607 {
00608 VL_DEBUG_SET_OBJECT_NAME()
00609 }
00610
00611 virtual ERenderState type() const { return RS_BlendFunc; }
00612
00613
00614
00615 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00616
00617 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; }
00618
00619 void set(EBlendFactor src_rgba, EBlendFactor dst_rgba) { mSrcRGB = src_rgba; mSrcAlpha = src_rgba; mDstRGB = dst_rgba; mDstAlpha = dst_rgba; }
00620
00621 void setSrcRGB(EBlendFactor factor) { mSrcRGB = factor; }
00622
00623 void setDstRGB(EBlendFactor factor) { mDstRGB = factor; }
00624
00625 void setSrcAlpha(EBlendFactor factor) { mSrcAlpha = factor; }
00626
00627 void setDstAlpha(EBlendFactor factor) { mDstAlpha = factor; }
00628
00629 EBlendFactor srcRGB() const { return mSrcRGB; }
00630
00631 EBlendFactor dstRGB() const { return mDstRGB; }
00632
00633 EBlendFactor srcAlpha() const { return mSrcAlpha; }
00634
00635 EBlendFactor dstAlpha() const { return mDstAlpha; }
00636
00637 virtual ref<RenderState> clone() const
00638 {
00639 ref<BlendFunc> rs = new BlendFunc;
00640 *rs = *this;
00641 return rs;
00642 }
00643
00644 protected:
00645 EBlendFactor mSrcRGB;
00646 EBlendFactor mDstRGB;
00647 EBlendFactor mSrcAlpha;
00648 EBlendFactor mDstAlpha;
00649 };
00650
00651
00652
00657 class VLGRAPHICS_EXPORT BlendEquation: public RenderStateNonIndexed
00658 {
00659 VL_INSTRUMENT_CLASS(vl::BlendEquation, RenderStateNonIndexed)
00660
00661 public:
00662 BlendEquation(EBlendEquation mode_rgb=BE_FUNC_ADD, EBlendEquation mode_alpha=BE_FUNC_ADD): mModeRGB(mode_rgb), mModeAlpha(mode_alpha)
00663 {
00664 VL_DEBUG_SET_OBJECT_NAME()
00665 }
00666
00667 virtual ERenderState type() const { return RS_BlendEquation; }
00668
00669
00670
00671 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00672
00673 void set(EBlendEquation mode_rgba) { mModeRGB = mode_rgba; mModeAlpha = mode_rgba; }
00674
00675 void set(EBlendEquation mode_rgb, EBlendEquation mode_alpha) { mModeRGB = mode_rgb; mModeAlpha = mode_alpha; }
00676
00677 EBlendEquation modeRGB() const { return mModeRGB; }
00678
00679 EBlendEquation modeAlpha() const { return mModeAlpha; }
00680
00681 virtual ref<RenderState> clone() const
00682 {
00683 ref<BlendEquation> rs = new BlendEquation;
00684 *rs = *this;
00685 return rs;
00686 }
00687
00688 protected:
00689 EBlendEquation mModeRGB;
00690 EBlendEquation mModeAlpha;
00691 };
00692
00693
00694
00697 class VLGRAPHICS_EXPORT SampleCoverage: public RenderStateNonIndexed
00698 {
00699 VL_INSTRUMENT_CLASS(vl::SampleCoverage, RenderStateNonIndexed)
00700
00701 public:
00702 SampleCoverage(GLclampf value=1.0f, bool invert=false): mValue(value), mInvert(invert)
00703 {
00704 VL_DEBUG_SET_OBJECT_NAME()
00705 }
00706
00707 virtual ERenderState type() const { return RS_SampleCoverage; }
00708
00709 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00710
00711 void set(GLclampf value, bool invert) { mValue = value; mInvert = invert; }
00712
00713 void setValue(GLclampf value) { mValue = value; }
00714
00715 void setInvert(bool invert) { mInvert = invert; }
00716
00717 GLclampf value() const { return mValue; }
00718
00719 bool invert() const { return mInvert; }
00720
00721 virtual ref<RenderState> clone() const
00722 {
00723 ref<SampleCoverage> rs = new SampleCoverage;
00724 *rs = *this;
00725 return rs;
00726 }
00727
00728 protected:
00729 GLclampf mValue;
00730 bool mInvert;
00731 };
00732
00733
00734
00737 class VLGRAPHICS_EXPORT AlphaFunc: public RenderStateNonIndexed
00738 {
00739 VL_INSTRUMENT_CLASS(vl::AlphaFunc, RenderStateNonIndexed)
00740
00741 public:
00742 AlphaFunc(EFunction alphafunc=FU_ALWAYS, float refvalue=0): mRefValue(refvalue), mAlphaFunc(alphafunc)
00743 {
00744 VL_DEBUG_SET_OBJECT_NAME()
00745 }
00746
00747 virtual ERenderState type() const { return RS_AlphaFunc; }
00748
00749 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00750
00751 void set(EFunction alphafunc, float ref_value) { mAlphaFunc = alphafunc; mRefValue = ref_value; }
00752
00753 EFunction alphaFunc() const { return mAlphaFunc; }
00754
00755 float refValue() const { return mRefValue; }
00756
00757 virtual ref<RenderState> clone() const
00758 {
00759 ref<AlphaFunc> rs = new AlphaFunc;
00760 *rs = *this;
00761 return rs;
00762 }
00763
00764 protected:
00765 float mRefValue;
00766 EFunction mAlphaFunc;
00767 };
00768
00769
00770
00774 class VLGRAPHICS_EXPORT Material: public RenderStateNonIndexed
00775 {
00776 VL_INSTRUMENT_CLASS(vl::Material, RenderStateNonIndexed)
00777
00778 public:
00779 Material();
00780 virtual ERenderState type() const { return RS_Material; }
00781 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00782
00783 void multiplyTransparency(float alpha);
00784 float getMinimumAlpha() const;
00785
00786 void setTransparency(float alpha);
00787 void setFrontTransparency(float alpha);
00788 void setBackTransparency(float alpha);
00789 void setFrontFlatColor(const fvec4& color);
00790 void setBackFlatColor(const fvec4& color);
00791 void setFlatColor(const fvec4& color);
00792
00793 void setAmbient(fvec4 color) { mFrontAmbient = mBackAmbient = color; }
00794 void setDiffuse(fvec4 color) { mFrontDiffuse = mBackDiffuse = color; }
00795 void setSpecular(fvec4 color) { mFrontSpecular = mBackSpecular = color; }
00796 void setEmission(fvec4 color) { mFrontEmission = mBackEmission = color; }
00797 void setShininess(float shininess) { mFrontShininess = mBackShininess = shininess; }
00798
00799 void setFrontAmbient(fvec4 color) { mFrontAmbient = color; }
00800 void setFrontDiffuse(fvec4 color) { mFrontDiffuse = color; }
00801 void setFrontSpecular(fvec4 color) { mFrontSpecular = color; }
00802 void setFrontEmission(fvec4 color) { mFrontEmission = color; }
00803 void setFrontShininess(float shininess) { mFrontShininess=shininess; }
00804
00805 fvec4 frontAmbient() const { return mFrontAmbient; }
00806 fvec4 frontDiffuse() const { return mFrontDiffuse; }
00807 fvec4 frontSpecular() const { return mFrontSpecular; }
00808 fvec4 frontEmission() const { return mFrontEmission; }
00809 float frontShininess() const { return mFrontShininess; }
00810
00811 void setBackAmbient(fvec4 color) { mBackAmbient = color; }
00812 void setBackDiffuse(fvec4 color) { mBackDiffuse = color; }
00813 void setBackSpecular(fvec4 color) { mBackSpecular = color; }
00814 void setBackEmission(fvec4 color) { mBackEmission = color; }
00815 void setBackShininess(float shininess) { mBackShininess=shininess; }
00816
00817 fvec4 backAmbient() const { return mBackAmbient; }
00818 fvec4 backDiffuse() const { return mBackDiffuse; }
00819 fvec4 backSpecular() const { return mBackSpecular; }
00820 fvec4 backEmission() const { return mBackEmission; }
00821 float backShininess() const { return mBackShininess; }
00822
00823
00824
00825 void setColorMaterial(EPolygonFace face, EColorMaterial color) { mColorMaterialFace = face; mColorMaterial = color; }
00826 EPolygonFace colorMaterialFace() const { return mColorMaterialFace; }
00827 EColorMaterial colorMaterial() const { return mColorMaterial; }
00828 void setColorMaterialEnabled(bool enabled) { mColorMaterialEnabled = enabled; }
00829 bool colorMaterialEnabled() const { return mColorMaterialEnabled; }
00830
00831 virtual ref<RenderState> clone() const
00832 {
00833 ref<Material> rs = new Material;
00834 *rs = *this;
00835 return rs;
00836 }
00837
00838 protected:
00839 fvec4 mFrontAmbient;
00840 fvec4 mFrontDiffuse;
00841 fvec4 mFrontSpecular;
00842 fvec4 mFrontEmission;
00843 fvec4 mBackAmbient;
00844 fvec4 mBackDiffuse;
00845 fvec4 mBackSpecular;
00846 fvec4 mBackEmission;
00847 float mBackShininess;
00848 float mFrontShininess;
00849
00850 EPolygonFace mColorMaterialFace;
00851 EColorMaterial mColorMaterial;
00852 bool mColorMaterialEnabled;
00853 };
00854
00855
00856
00859 class VLGRAPHICS_EXPORT LightModel: public RenderStateNonIndexed
00860 {
00861 VL_INSTRUMENT_CLASS(vl::LightModel, RenderStateNonIndexed)
00862
00863 public:
00864 LightModel(): mAmbientColor(0.2f,0.2f,0.2f,1.0f), mColorControl(CC_SINGLE_COLOR), mLocalViewer(false), mTwoSide(false)
00865 {
00866 VL_DEBUG_SET_OBJECT_NAME()
00867 }
00868
00869 virtual ERenderState type() const { return RS_LightModel; }
00870
00871 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00872
00873 void setLocalViewer(bool localviewer) { mLocalViewer = localviewer; }
00874
00875 void setTwoSide(bool twoside) { mTwoSide = twoside; }
00876
00877 void setColorControl(EColorControl colorcontrol) { mColorControl = colorcontrol; }
00878
00879 void setAmbientColor(fvec4 ambientcolor) { mAmbientColor = ambientcolor; }
00880
00881 bool localViewer() const { return mLocalViewer; }
00882
00883 bool twoSide() const { return mTwoSide; }
00884
00885 EColorControl colorControl() const { return mColorControl; }
00886
00887 fvec4 ambientColor() const { return mAmbientColor; }
00888
00889 virtual ref<RenderState> clone() const
00890 {
00891 ref<LightModel> rs = new LightModel;
00892 *rs = *this;
00893 return rs;
00894 }
00895
00896 protected:
00897 fvec4 mAmbientColor;
00898 EColorControl mColorControl;
00899 bool mLocalViewer;
00900 bool mTwoSide;
00901 };
00902
00903
00904
00907 class VLGRAPHICS_EXPORT Fog: public RenderStateNonIndexed
00908 {
00909 VL_INSTRUMENT_CLASS(vl::Fog, RenderStateNonIndexed)
00910
00911 public:
00912 Fog(EFogMode mode=FM_LINEAR, fvec4 color=fvec4(0,0,0,0), float density=1, float start=0, float end=1):
00913 mColor(color), mMode(mode), mDensity(density), mStart(start), mEnd(end)
00914 {
00915 VL_DEBUG_SET_OBJECT_NAME()
00916 }
00917
00918 virtual ERenderState type() const { return RS_Fog; }
00919
00920 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00921
00922 void set(EFogMode mode, fvec4 color, float density, float start, float end) { mColor = color; mMode = mode; mDensity = density; mStart = start; mEnd = end; }
00923
00924 void setColor(fvec4 color) { mColor = color; }
00925
00926 void setMode(EFogMode mode) { mMode = mode; }
00927
00928 void setDensity(float density) { mDensity = density; }
00929
00930 void setStart(float start) { mStart = start; }
00931
00932 void setEnd(float end) { mEnd = end; }
00933
00934 fvec4 color() const { return mColor; }
00935
00936 EFogMode mode() const { return mMode; }
00937
00938 float density() const { return mDensity; }
00939
00940 float start() const { return mStart; }
00941
00942 float end() const { return mEnd; }
00943
00944 virtual ref<RenderState> clone() const
00945 {
00946 ref<Fog> rs = new Fog;
00947 *rs = *this;
00948 return rs;
00949 }
00950
00951 protected:
00952 fvec4 mColor;
00953 EFogMode mMode;
00954 float mDensity;
00955 float mStart;
00956 float mEnd;
00957 };
00958
00959
00960
00963 class VLGRAPHICS_EXPORT PolygonOffset: public RenderStateNonIndexed
00964 {
00965 VL_INSTRUMENT_CLASS(vl::PolygonOffset, RenderStateNonIndexed)
00966
00967 public:
00968 PolygonOffset(): mFactor(0.0f), mUnits(0.0f)
00969 {
00970 VL_DEBUG_SET_OBJECT_NAME()
00971 }
00972
00973 virtual ERenderState type() const { return RS_PolygonOffset; }
00974
00975 PolygonOffset(float factor, float units): mFactor(factor), mUnits(units) {}
00976
00977 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
00978
00979 void set(float factor, float units) { mFactor = factor; mUnits = units; }
00980
00981 void setFactor(float factor) { mFactor = factor; }
00982
00983 void setUnits(float units) { mUnits = units; }
00984
00985 float factor() const { return mFactor; }
00986
00987 float units() const { return mUnits; }
00988
00989 virtual ref<RenderState> clone() const
00990 {
00991 ref<PolygonOffset> rs = new PolygonOffset;
00992 *rs = *this;
00993 return rs;
00994 }
00995
00996 protected:
00997 float mFactor;
00998 float mUnits;
00999 };
01000
01001
01002
01005 class VLGRAPHICS_EXPORT LogicOp: public RenderStateNonIndexed
01006 {
01007 VL_INSTRUMENT_CLASS(vl::LogicOp, RenderStateNonIndexed)
01008
01009 public:
01010 LogicOp(ELogicOp logicop=LO_COPY): mLogicOp(logicop)
01011 {
01012 VL_DEBUG_SET_OBJECT_NAME()
01013 }
01014
01015 virtual ERenderState type() const { return RS_LogicOp; }
01016
01017 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01018
01019 void set(ELogicOp logicop) { mLogicOp = logicop; }
01020
01021 ELogicOp logicOp() const { return mLogicOp; }
01022
01023 virtual ref<RenderState> clone() const
01024 {
01025 ref<LogicOp> rs = new LogicOp;
01026 *rs = *this;
01027 return rs;
01028 }
01029
01030 protected:
01031 ELogicOp mLogicOp;
01032 };
01033
01034
01035
01038 class VLGRAPHICS_EXPORT DepthRange: public RenderStateNonIndexed
01039 {
01040 VL_INSTRUMENT_CLASS(vl::DepthRange, RenderStateNonIndexed)
01041
01042 public:
01043 DepthRange(): mZNear(0), mZFar(1.0f)
01044 {
01045 VL_DEBUG_SET_OBJECT_NAME()
01046 }
01047
01048 DepthRange(float znear, float zfar): mZNear(znear), mZFar(zfar)
01049 {
01050 VL_DEBUG_SET_OBJECT_NAME()
01051 }
01052
01053 virtual ERenderState type() const { return RS_DepthRange; }
01054
01055 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01056
01057 void set(float znear, float zfar) { mZNear = znear; mZFar = zfar; }
01058
01059 void setZNear(float znear) { mZNear = znear; }
01060
01061 void setZFar(float zfar) { mZFar = zfar; }
01062
01063 float zNear() const { return mZNear; }
01064
01065 float zFar() const { return mZFar; }
01066
01067 virtual ref<RenderState> clone() const
01068 {
01069 ref<DepthRange> rs = new DepthRange;
01070 *rs = *this;
01071 return rs;
01072 }
01073
01074 protected:
01075 float mZNear;
01076 float mZFar;
01077 };
01078
01079
01080
01083 class VLGRAPHICS_EXPORT LineWidth: public RenderStateNonIndexed
01084 {
01085 VL_INSTRUMENT_CLASS(vl::LineWidth, RenderStateNonIndexed)
01086
01087 public:
01088 LineWidth(float linewidth=1.0f): mLineWidth(linewidth)
01089 {
01090 VL_DEBUG_SET_OBJECT_NAME()
01091 }
01092
01093 virtual ERenderState type() const { return RS_LineWidth; }
01094
01095 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01096
01097 void set(float linewidth) { mLineWidth = linewidth; }
01098
01099 float lineWidth() const { return mLineWidth; }
01100
01101 virtual ref<RenderState> clone() const
01102 {
01103 ref<LineWidth> rs = new LineWidth;
01104 *rs = *this;
01105 return rs;
01106 }
01107
01108 protected:
01109 float mLineWidth;
01110 };
01111
01112
01113
01116 class VLGRAPHICS_EXPORT PointSize: public RenderStateNonIndexed
01117 {
01118 VL_INSTRUMENT_CLASS(vl::PointSize, RenderStateNonIndexed)
01119
01120 public:
01121 PointSize(float pointsize=1.0f): mPointSize(pointsize)
01122 {
01123 VL_DEBUG_SET_OBJECT_NAME()
01124 }
01125
01126 virtual ERenderState type() const { return RS_PointSize; }
01127
01128 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01129
01130 void set(float pointsize) { mPointSize = pointsize; }
01131
01132 float pointSize() const { return mPointSize; }
01133
01134 virtual ref<RenderState> clone() const
01135 {
01136 ref<PointSize> rs = new PointSize;
01137 *rs = *this;
01138 return rs;
01139 }
01140
01141 protected:
01142 float mPointSize;
01143 };
01144
01145
01146
01149 class VLGRAPHICS_EXPORT PolygonStipple: public RenderStateNonIndexed
01150 {
01151 VL_INSTRUMENT_CLASS(vl::PolygonStipple, RenderStateNonIndexed)
01152
01153 public:
01154 PolygonStipple();
01155
01156 PolygonStipple(const unsigned char* mask);
01157
01158 virtual ERenderState type() const { return RS_PolygonStipple; }
01159
01160 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01161
01162 void set(const unsigned char* mask);
01163
01164 const unsigned char* mask() const { return mMask; }
01165
01166 virtual ref<RenderState> clone() const
01167 {
01168 ref<PolygonStipple> rs = new PolygonStipple;
01169 *rs = *this;
01170 return rs;
01171 }
01172
01173 protected:
01174 unsigned char mMask[32*32/8];
01175 };
01176
01177
01178
01181 class VLGRAPHICS_EXPORT LineStipple: public RenderStateNonIndexed
01182 {
01183 VL_INSTRUMENT_CLASS(vl::LineStipple, RenderStateNonIndexed)
01184
01185 public:
01186 LineStipple(int factor=1, GLushort pattern=~(GLushort)0): mFactor(factor), mPattern(pattern)
01187 {
01188 VL_DEBUG_SET_OBJECT_NAME()
01189 }
01190
01191 virtual ERenderState type() const { return RS_LineStipple; }
01192
01193 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01194
01195 void set(int factor, GLushort pattern) { mFactor = factor; mPattern = pattern; }
01196
01197 void setFactor(int factor) { mFactor = factor; }
01198
01199 void setPattern(GLushort pattern) { mPattern = pattern; }
01200
01201 int factor() const { return mFactor; }
01202
01203 GLushort pattern() const { return mPattern; }
01204
01205 virtual ref<RenderState> clone() const
01206 {
01207 ref<LineStipple> rs = new LineStipple;
01208 *rs = *this;
01209 return rs;
01210 }
01211
01212 protected:
01213 int mFactor;
01214 GLushort mPattern;
01215 };
01216
01217
01218
01221 class VLGRAPHICS_EXPORT PointParameter: public RenderStateNonIndexed
01222 {
01223 VL_INSTRUMENT_CLASS(vl::PointParameter, RenderStateNonIndexed)
01224
01225 public:
01226 PointParameter(float sizemin=0, float sizemax=1024.0f, float fadethresholdsize=1.0f, fvec3 distanceattenuation=fvec3(1,0,0)):
01227 mDistanceAttenuation(distanceattenuation), mSizeMin(sizemin), mSizeMax(sizemax), mFadeThresholdSize(fadethresholdsize),
01228 mPointSpriteCoordOrigin(PPCO_UPPER_LEFT)
01229 {
01230 VL_DEBUG_SET_OBJECT_NAME()
01231 }
01232 virtual ERenderState type() const { return RS_PointParameter; }
01233
01234 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01235
01236 void set(float sizemin, float sizemax, float fadethresholdsize, fvec3 distanceattenuation) { mDistanceAttenuation = distanceattenuation; mSizeMin = sizemin; mSizeMax = sizemax; mFadeThresholdSize = fadethresholdsize; }
01237
01238 void setDistanceAttenuation(fvec3 attenuation) { mDistanceAttenuation = attenuation; }
01239
01240 void setSizeMin(float sizemin) { mSizeMin = sizemin; }
01241
01242 void setSizeMax(float sizemax) { mSizeMax = sizemax; }
01243
01244 void setFadeThresholdSize(float threshold) { mFadeThresholdSize = threshold; }
01245
01246 fvec3 distanceAttenuation() const { return mDistanceAttenuation; }
01247
01248 float sizeMin() const { return mSizeMin; }
01249
01250 float sizeMax() const { return mSizeMax; }
01251
01252 float fadeThresholdSize() const { return mFadeThresholdSize; }
01253
01254 EPointSpriteCoordOrigin pointSpriteCoordOrigin() const { return mPointSpriteCoordOrigin; }
01255
01256 void setPointSpriteCoordOrigin(EPointSpriteCoordOrigin orig) { mPointSpriteCoordOrigin = orig; }
01257
01258 virtual ref<RenderState> clone() const
01259 {
01260 ref<PointParameter> rs = new PointParameter;
01261 *rs = *this;
01262 return rs;
01263 }
01264
01265 protected:
01266 fvec3 mDistanceAttenuation;
01267 float mSizeMin;
01268 float mSizeMax;
01269 float mFadeThresholdSize;
01270 EPointSpriteCoordOrigin mPointSpriteCoordOrigin;
01271 };
01272
01273
01274
01279 class VLGRAPHICS_EXPORT StencilFunc: public RenderStateNonIndexed
01280 {
01281 VL_INSTRUMENT_CLASS(vl::StencilFunc, RenderStateNonIndexed)
01282
01283 public:
01284 StencilFunc(EFunction function=FU_ALWAYS, int refvalue=0, unsigned int mask=~(unsigned int)0):
01285 mFunction_Front(function), mFunction_Back(function),
01286 mRefValue_Front(refvalue), mRefValue_Back(refvalue),
01287 mMask_Front(mask), mMask_Back(mask)
01288 {
01289 VL_DEBUG_SET_OBJECT_NAME()
01290 }
01291
01292 virtual ERenderState type() const { return RS_StencilFunc; }
01293
01294 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01295
01296 void set(EPolygonFace face, EFunction function, int refvalue, unsigned int mask)
01297 {
01298 if (face == PF_FRONT || face == PF_FRONT_AND_BACK)
01299 {
01300 mFunction_Front = function;
01301 mRefValue_Front = refvalue;
01302 mMask_Front = mask;
01303 }
01304 if (face == PF_BACK || face == PF_FRONT_AND_BACK)
01305 {
01306 mFunction_Back = function;
01307 mRefValue_Back = refvalue;
01308 mMask_Back = mask;
01309 }
01310 }
01311
01312 EFunction function_Front() const { return mFunction_Front; }
01313
01314 int refValue_Front() const { return mRefValue_Front; }
01315
01316 unsigned int mask_Front() const { return mMask_Front; }
01317
01318 EFunction function_Back() const { return mFunction_Back; }
01319
01320 int refValue_Back() const { return mRefValue_Back; }
01321
01322 unsigned int mask_Back() const { return mMask_Back; }
01323
01324 virtual ref<RenderState> clone() const
01325 {
01326 ref<StencilFunc> rs = new StencilFunc;
01327 *rs = *this;
01328 return rs;
01329 }
01330
01331 protected:
01332 EFunction mFunction_Front;
01333 EFunction mFunction_Back;
01334 int mRefValue_Front;
01335 int mRefValue_Back;
01336 unsigned int mMask_Front;
01337 unsigned int mMask_Back;
01338 };
01339
01340
01341
01346 class VLGRAPHICS_EXPORT StencilOp: public RenderStateNonIndexed
01347 {
01348 VL_INSTRUMENT_CLASS(vl::StencilOp, RenderStateNonIndexed)
01349
01350 public:
01351 StencilOp(EStencilOp sfail=SO_KEEP, EStencilOp dpfail=SO_KEEP, EStencilOp dppass=SO_KEEP):
01352 mSFail_Front(sfail), mSFail_Back(sfail),
01353 mDpFail_Front(dpfail), mDpFail_Back(dpfail),
01354 mDpPass_Front(dppass), mDpPass_Back(dppass)
01355 {
01356 VL_DEBUG_SET_OBJECT_NAME()
01357 }
01358
01359 virtual ERenderState type() const { return RS_StencilOp; }
01360
01361 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01362
01363 void set(EPolygonFace face, EStencilOp sfail, EStencilOp dpfail, EStencilOp dppass)
01364 {
01365 if (face == PF_FRONT || face == PF_FRONT_AND_BACK)
01366 {
01367 mSFail_Front = sfail;
01368 mDpFail_Front = dpfail;
01369 mDpPass_Front = dppass;
01370 }
01371 if (face == PF_BACK || face == PF_FRONT_AND_BACK)
01372 {
01373 mSFail_Back = sfail;
01374 mDpFail_Back = dpfail;
01375 mDpPass_Back = dppass;
01376 }
01377 }
01378
01379 EStencilOp sFail_Front() const { return mSFail_Front; }
01380
01381 EStencilOp dpFail_Front() const { return mDpFail_Front; }
01382
01383 EStencilOp dpPass_Front() const { return mDpPass_Front; }
01384
01385 EStencilOp sFail_Back() const { return mSFail_Front; }
01386
01387 EStencilOp dpFail_Back() const { return mDpFail_Front; }
01388
01389 EStencilOp dpPass_Back() const { return mDpPass_Front; }
01390
01391 virtual ref<RenderState> clone() const
01392 {
01393 ref<StencilOp> rs = new StencilOp;
01394 *rs = *this;
01395 return rs;
01396 }
01397
01398 protected:
01399 EStencilOp mSFail_Front;
01400 EStencilOp mSFail_Back;
01401 EStencilOp mDpFail_Front;
01402 EStencilOp mDpFail_Back;
01403 EStencilOp mDpPass_Front;
01404 EStencilOp mDpPass_Back;
01405 };
01406
01407
01408
01413 class VLGRAPHICS_EXPORT StencilMask: public RenderStateNonIndexed
01414 {
01415 VL_INSTRUMENT_CLASS(vl::StencilMask, RenderStateNonIndexed)
01416
01417 public:
01418 StencilMask(unsigned int mask=~(unsigned int)0): mMask_Front(mask), mMask_Back(mask)
01419 {
01420 VL_DEBUG_SET_OBJECT_NAME()
01421 }
01422
01423 virtual ERenderState type() const { return RS_StencilMask; }
01424
01425 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01426
01427 void set(EPolygonFace face, unsigned int mask)
01428 {
01429 if (face == PF_FRONT || face == PF_FRONT_AND_BACK)
01430 mMask_Front = mask;
01431 if (face == PF_BACK || face == PF_FRONT_AND_BACK)
01432 mMask_Back = mask;
01433 }
01434
01435 unsigned int mask_Front() const { return mMask_Front; }
01436
01437 unsigned int mask_Back() const { return mMask_Back; }
01438
01439 virtual ref<RenderState> clone() const
01440 {
01441 ref<StencilMask> rs = new StencilMask;
01442 *rs = *this;
01443 return rs;
01444 }
01445
01446 protected:
01447 unsigned int mMask_Front;
01448 unsigned int mMask_Back;
01449 };
01450
01451
01452
01455 class VLGRAPHICS_EXPORT BlendColor: public RenderStateNonIndexed
01456 {
01457 VL_INSTRUMENT_CLASS(vl::BlendColor, RenderStateNonIndexed)
01458
01459 public:
01460 BlendColor(fvec4 blendcolor=fvec4(0,0,0,0)): mBlendColor(blendcolor)
01461 {
01462 VL_DEBUG_SET_OBJECT_NAME()
01463 }
01464
01465 virtual ERenderState type() const { return RS_BlendColor; }
01466
01467 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01468
01469 void set(fvec4 blendcolor) { mBlendColor = blendcolor; }
01470
01471 fvec4 blendColor() const { return mBlendColor; }
01472
01473 virtual ref<RenderState> clone() const
01474 {
01475 ref<BlendColor> rs = new BlendColor;
01476 *rs = *this;
01477 return rs;
01478 }
01479
01480 protected:
01481 fvec4 mBlendColor;
01482 };
01483
01484
01485
01488 class VLGRAPHICS_EXPORT ColorMask: public RenderStateNonIndexed
01489 {
01490 VL_INSTRUMENT_CLASS(vl::ColorMask, RenderStateNonIndexed)
01491
01492 public:
01493 ColorMask(bool red=true, bool green=true, bool blue=true, bool alpha=true): mRed(red), mGreen(green), mBlue(blue), mAlpha(alpha)
01494 {
01495 VL_DEBUG_SET_OBJECT_NAME()
01496 }
01497
01498 virtual ERenderState type() const { return RS_ColorMask; }
01499
01500 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01501
01502 void set(bool red, bool green, bool blue, bool alpha) { mRed = red; mGreen = green; mBlue = blue; mAlpha = alpha; }
01503
01504 void setRed(bool red) { mRed = red; }
01505
01506 void setGreen(bool green) { mGreen = green; }
01507
01508 void setBlue(bool blue) { mBlue = blue; }
01509
01510 void setAlpha(bool alpha) { mAlpha = alpha; }
01511
01512 bool red() const { return mRed; }
01513
01514 bool green() const { return mGreen; }
01515
01516 bool blue() const { return mBlue; }
01517
01518 bool alpha() const { return mAlpha; }
01519
01520 virtual ref<RenderState> clone() const
01521 {
01522 ref<ColorMask> rs = new ColorMask;
01523 *rs = *this;
01524 return rs;
01525 }
01526
01527 protected:
01528 bool mRed;
01529 bool mGreen;
01530 bool mBlue;
01531 bool mAlpha;
01532 };
01533
01534
01535
01539 class VLGRAPHICS_EXPORT TextureMatrix: public RenderStateIndexed
01540 {
01541 VL_INSTRUMENT_CLASS(vl::TextureMatrix, RenderStateIndexed)
01542
01543 public:
01544 TextureMatrix() { mUseCameraRotationInverse = false; }
01545
01546 virtual ERenderState type() const { return RS_TextureMatrix; }
01547
01548 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01549
01550 const fmat4& matrix() const { return mMatrix; }
01551
01552 const TextureMatrix& setMatrix(const fmat4& matrix)
01553 {
01554 mMatrix = matrix;
01555 return *this;
01556 }
01557
01564 void setUseCameraRotationInverse(bool use) { mUseCameraRotationInverse = use; }
01565
01566 bool useCameraRotationInverse() const { return mUseCameraRotationInverse; }
01567
01568 virtual ref<RenderState> clone() const
01569 {
01570 ref<TextureMatrix> rs = new TextureMatrix;
01571 *rs = *this;
01572 return rs;
01573 }
01574
01575 protected:
01576 fmat4 mMatrix;
01577 bool mUseCameraRotationInverse;
01578 };
01579
01580
01581
01589 class VLGRAPHICS_EXPORT TexEnv: public RenderStateIndexed
01590 {
01591 VL_INSTRUMENT_CLASS(vl::TexEnv, RenderStateIndexed)
01592
01593 public:
01594 TexEnv();
01595 virtual ERenderState type() const { return RS_TexEnv; }
01596 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01597
01598 void setMode(ETexEnvMode mode) { mMode = mode; }
01599 ETexEnvMode mode() const { return mMode; }
01600 void setCombineRGB(ETexEnvMode combineRGB) { mCombineRGB = combineRGB; }
01601 ETexEnvMode combineRGB() const { return mCombineRGB; }
01602 void setCombineAlpha(ETexEnvMode combineAlpha) { mCombineAlpha = combineAlpha; }
01603 ETexEnvMode combineAlpha() const { return mCombineAlpha; }
01604 void setColor(fvec4 color) { mColor = color; }
01605 fvec4 color() const { return mColor; }
01606 void setRGBScale(float rgbscale) { mRGBScale = rgbscale; }
01607 float rgbScale() const { return mRGBScale; }
01608 void setAlphaScale(float alphascale) { mAlphaScale = alphascale; }
01609 float alphaScale() const { return mAlphaScale; }
01610
01611 void setSource0RGB(ETexEnvSource source) { mSource0RGB = source; }
01612 void setSource1RGB(ETexEnvSource source) { mSource1RGB = source; }
01613 void setSource2RGB(ETexEnvSource source) { mSource2RGB = source; }
01614 ETexEnvSource source0RGB() const { return mSource0RGB; }
01615 ETexEnvSource source1RGB() const { return mSource1RGB; }
01616 ETexEnvSource source2RGB() const { return mSource2RGB; }
01617 void setSource0Alpha(ETexEnvSource source) { mSource0Alpha = source; }
01618 void setSource1Alpha(ETexEnvSource source) { mSource1Alpha = source; }
01619 void setSource2Alpha(ETexEnvSource source) { mSource2Alpha = source; }
01620 ETexEnvSource source0Alpha() const { return mSource0Alpha; }
01621 ETexEnvSource source1Alpha() const { return mSource1Alpha; }
01622 ETexEnvSource source2Alpha() const { return mSource2Alpha; }
01623
01624 void setOperand0RGB(ETexEnvOperand operand) { mOperand0RGB = operand; }
01625 void setOperand1RGB(ETexEnvOperand operand) { mOperand1RGB = operand; }
01626 void setOperand2RGB(ETexEnvOperand operand) { mOperand2RGB = operand; }
01627 ETexEnvOperand operand0RGB() const { return mOperand0RGB; }
01628 ETexEnvOperand operand1RGB() const { return mOperand1RGB; }
01629 ETexEnvOperand operand2RGB() const { return mOperand2RGB; }
01630 void setOperand0Alpha(ETexEnvOperand operand) { mOperand0Alpha = operand; }
01631 void setOperand1Alpha(ETexEnvOperand operand) { mOperand1Alpha = operand; }
01632 void setOperand2Alpha(ETexEnvOperand operand) { mOperand2Alpha = operand; }
01633 ETexEnvOperand operand0Alpha() const { return mOperand0Alpha; }
01634 ETexEnvOperand operand1Alpha() const { return mOperand1Alpha; }
01635 ETexEnvOperand operand2Alpha() const { return mOperand2Alpha; }
01636
01637 void setPointSpriteCoordReplace(bool replace) { mPointSpriteCoordReplace = replace; }
01638 bool pointSpriteCoordReplace() const { return mPointSpriteCoordReplace; }
01639
01640 void setLodBias(float lodbias) { mLodBias = lodbias; }
01641 float lodBias() const { return mLodBias; }
01642
01643 virtual ref<RenderState> clone() const
01644 {
01645 ref<TexEnv> rs = new TexEnv;
01646 *rs = *this;
01647 return rs;
01648 }
01649
01650 public:
01651 fvec4 mColor;
01652 float mRGBScale;
01653 float mAlphaScale;
01654 ETexEnvMode mMode;
01655 ETexEnvMode mCombineRGB;
01656 ETexEnvMode mCombineAlpha;
01657 ETexEnvSource mSource0RGB;
01658 ETexEnvSource mSource1RGB;
01659 ETexEnvSource mSource2RGB;
01660 ETexEnvSource mSource0Alpha;
01661 ETexEnvSource mSource1Alpha;
01662 ETexEnvSource mSource2Alpha;
01663 ETexEnvOperand mOperand0RGB;
01664 ETexEnvOperand mOperand1RGB;
01665 ETexEnvOperand mOperand2RGB;
01666 ETexEnvOperand mOperand0Alpha;
01667 ETexEnvOperand mOperand1Alpha;
01668 ETexEnvOperand mOperand2Alpha;
01669 float mLodBias;
01670 bool mPointSpriteCoordReplace;
01671 };
01672
01673
01674
01682 class VLGRAPHICS_EXPORT TexGen: public RenderStateIndexed
01683 {
01684 VL_INSTRUMENT_CLASS(vl::TexGen, RenderStateIndexed)
01685
01686 public:
01687 TexGen();
01688
01689 virtual ERenderState type() const { return RS_TexGen; }
01690 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01691
01692 void setEyePlaneS(fvec4 plane) { mEyePlaneS = plane; }
01693 void setObjectPlaneS(fvec4 plane) { mObjectPlaneS = plane; }
01694 void setGenModeS(ETexGenMode mode) { mGenModeS = mode; }
01695 fvec4 eyePlaneS() const { return mEyePlaneS; }
01696 fvec4 objectPlaneS() const { return mObjectPlaneS; }
01697 ETexGenMode genModeS() const { return mGenModeS; }
01698
01699 void setEyePlaneT(fvec4 plane) { mEyePlaneT = plane; }
01700 void setObjectPlaneT(fvec4 plane) { mObjectPlaneT = plane; }
01701 void setGenModeT(ETexGenMode mode) { mGenModeT = mode; }
01702 fvec4 eyePlaneT() const { return mEyePlaneT; }
01703 fvec4 objectPlaneT() const { return mObjectPlaneT; }
01704 ETexGenMode genModeT() const { return mGenModeT; }
01705
01706 void setEyePlaneR(fvec4 plane) { mEyePlaneR = plane; }
01707 void setObjectPlaneR(fvec4 plane) { mObjectPlaneR = plane; }
01708 void setGenModeR(ETexGenMode mode) { mGenModeR = mode; }
01709 fvec4 eyePlaneR() const { return mEyePlaneR; }
01710 fvec4 objectPlaneR() const { return mObjectPlaneR; }
01711 ETexGenMode genModeR() const { return mGenModeR; }
01712
01713 void setEyePlaneQ(fvec4 plane) { mEyePlaneQ = plane; }
01714 void setObjectPlaneQ(fvec4 plane) { mObjectPlaneQ = plane; }
01715 void setGenModeQ(ETexGenMode mode) { mGenModeQ = mode; }
01716 fvec4 eyePlaneQ() const { return mEyePlaneQ; }
01717 fvec4 objectPlaneQ() const { return mObjectPlaneQ; }
01718 ETexGenMode genModeQ() const { return mGenModeQ; }
01719
01720 virtual ref<RenderState> clone() const
01721 {
01722 ref<TexGen> rs = new TexGen;
01723 *rs = *this;
01724 return rs;
01725 }
01726
01727 public:
01728 fvec4 mEyePlaneS;
01729 fvec4 mObjectPlaneS;
01730 fvec4 mEyePlaneT;
01731 fvec4 mObjectPlaneT;
01732 fvec4 mEyePlaneR;
01733 fvec4 mObjectPlaneR;
01734 fvec4 mEyePlaneQ;
01735 fvec4 mObjectPlaneQ;
01736 ETexGenMode mGenModeS;
01737 ETexGenMode mGenModeT;
01738 ETexGenMode mGenModeR;
01739 ETexGenMode mGenModeQ;
01740 };
01741
01742
01743
01747 class VLGRAPHICS_EXPORT TextureSampler: public RenderStateIndexed
01748 {
01749 VL_INSTRUMENT_CLASS(vl::TextureSampler, RenderStateIndexed)
01750
01751 public:
01752 TextureSampler()
01753 {
01754 VL_DEBUG_SET_OBJECT_NAME()
01755 }
01756
01757 virtual ERenderState type() const { return RS_TextureSampler; }
01758 virtual void apply(int index, const Camera*, OpenGLContext* ctx) const;
01759
01762 void setTexture(Texture* texture) { mTexture = texture; }
01763
01765 Texture* texture() { return mTexture.get(); }
01766
01768 const Texture* texture() const { return mTexture.get(); }
01769
01772 void setTexParameter(TexParameter* tex_param) { mTexParameter = tex_param; }
01773
01775 TexParameter* getTexParameter() { return mTexParameter.get(); }
01776
01778 const TexParameter* getTexParameter() const { return mTexParameter.get(); }
01779
01780 bool hasTexture() const;
01781
01782 virtual ref<RenderState> clone() const
01783 {
01784 ref<TextureSampler> rs = new TextureSampler;
01785 *rs = *this;
01786 return rs;
01787 }
01788
01789 protected:
01790 ref<Texture> mTexture;
01791 ref<TexParameter> mTexParameter;
01792 };
01793
01794
01795
01800 class VLGRAPHICS_EXPORT ShaderAnimator: public Object
01801 {
01802 VL_INSTRUMENT_ABSTRACT_CLASS(vl::ShaderAnimator, Object)
01803
01804 public:
01805 ShaderAnimator(): mEnabled(true) {}
01806
01812 virtual void updateShader(Shader* shader, Camera* camera, real cur_time) = 0;
01813
01815 void setEnabled(bool enable) { mEnabled = enable; }
01816
01818 bool isEnabled() const { return mEnabled; }
01819
01820 protected:
01821 bool mEnabled;
01822 };
01823
01824
01825
01838 class VLGRAPHICS_EXPORT Shader: public Object
01839 {
01840 VL_INSTRUMENT_CLASS(vl::Shader, Object)
01841
01842
01843 Shader(const Shader& other): Object(other) { }
01844 Shader& operator=(const Shader&) { return *this; }
01845
01846 public:
01848 Shader();
01849
01851 virtual ~Shader();
01852
01854 ref<Shader> shallowCopy() const
01855 {
01856 ref<Shader> sh = new Shader;
01857 sh->shallowCopyFrom(*this);
01858 return sh;
01859 }
01860
01863 Shader& shallowCopyFrom(const Shader& other)
01864 {
01865 super::operator=(other);
01866
01867
01868
01869
01870 if (other.mRenderStateSet.get())
01871 {
01872 if (mRenderStateSet.get() == NULL)
01873 mRenderStateSet = new RenderStateSet;
01874 mRenderStateSet->shallowCopyFrom( *other.mRenderStateSet );
01875 }
01876 else
01877 mRenderStateSet = NULL;
01878
01879 if (other.mEnableSet.get())
01880 {
01881 if (mEnableSet.get() == NULL)
01882 mEnableSet = new EnableSet;
01883 *mEnableSet = *other.mEnableSet;
01884 }
01885 else
01886 mEnableSet = NULL;
01887
01888 if (other.mUniformSet.get())
01889 {
01890 if (mUniformSet.get() == NULL)
01891 mUniformSet = new UniformSet;
01892 mUniformSet->shallowCopyFrom( *other.mUniformSet );
01893 }
01894 else
01895 mUniformSet = NULL;
01896
01897 mScissor = other.mScissor;
01898
01899 mShaderAnimator = other.mShaderAnimator;
01900
01901 #if VL_SHADER_USER_DATA
01902 mShaderUserData = other.mShaderUserData;
01903 #endif
01904
01905 return *this;
01906 }
01907
01909 ref<Shader> deepCopy() const
01910 {
01911 ref<Shader> sh = new Shader;
01912 sh->deepCopyFrom(*this);
01913 return sh;
01914 }
01915
01917 Shader& deepCopyFrom(const Shader& other)
01918 {
01919 super::operator=(other);
01920
01921
01922
01923
01924 if (other.mRenderStateSet.get())
01925 {
01926 if (mRenderStateSet.get() == NULL)
01927 mRenderStateSet = new RenderStateSet;
01928 mRenderStateSet->deepCopyFrom( *other.mRenderStateSet.get() );
01929 }
01930 else
01931 mRenderStateSet = NULL;
01932
01933 if (other.mEnableSet.get())
01934 {
01935 if (mEnableSet.get() == NULL)
01936 mEnableSet = new EnableSet;
01937 *mEnableSet = *other.mEnableSet;
01938 }
01939 else
01940 mEnableSet = NULL;
01941
01942 if (other.mUniformSet.get())
01943 {
01944 if (mUniformSet.get() == NULL)
01945 mUniformSet = new UniformSet;
01946 mUniformSet->deepCopyFrom( *other.mUniformSet.get() );
01947 }
01948 else
01949 mUniformSet = NULL;
01950
01951 mScissor = new Scissor(*other.mScissor);
01952
01953
01954 mShaderAnimator = other.mShaderAnimator;
01955
01956 #if VL_SHADER_USER_DATA
01957 mShaderUserData = other.mShaderUserData;
01958 #endif
01959
01960 return *this;
01961 }
01962
01964 void reset()
01965 {
01966 disableAll();
01967 eraseAllRenderStates();
01968 eraseAllUniforms();
01969 }
01970
01971
01972
01974 GLSLProgram* gocGLSLProgram();
01975
01977 const GLSLProgram* getGLSLProgram() const;
01978
01980 GLSLProgram* getGLSLProgram();
01981
01982 PixelTransfer* gocPixelTransfer();
01983 const PixelTransfer* getPixelTransfer() const { if (!getRenderStateSet()) return NULL; else return static_cast<const PixelTransfer*>( getRenderStateSet()->renderState( RS_PixelTransfer ) ); }
01984 PixelTransfer* getPixelTransfer() { if (!getRenderStateSet()) return NULL; else return static_cast<PixelTransfer*>( getRenderStateSet()->renderState( RS_PixelTransfer ) ); }
01985
01986 Hint* gocHint();
01987 const Hint* getHint() const { if (!getRenderStateSet()) return NULL; else return static_cast<const Hint*>( getRenderStateSet()->renderState( RS_Hint ) ); }
01988 Hint* getHint() { if (!getRenderStateSet()) return NULL; else return static_cast<Hint*>( getRenderStateSet()->renderState( RS_Hint ) ); }
01989
01990 CullFace* gocCullFace();
01991 const CullFace* getCullFace() const { if (!getRenderStateSet()) return NULL; else return static_cast<const CullFace*>( getRenderStateSet()->renderState( RS_CullFace ) ); }
01992 CullFace* getCullFace() { if (!getRenderStateSet()) return NULL; else return static_cast<CullFace*>( getRenderStateSet()->renderState( RS_CullFace ) ); }
01993
01994 FrontFace* gocFrontFace();
01995 const FrontFace* getFrontFace() const { if (!getRenderStateSet()) return NULL; else return static_cast<const FrontFace*>( getRenderStateSet()->renderState( RS_FrontFace ) ); }
01996 FrontFace* getFrontFace() { if (!getRenderStateSet()) return NULL; else return static_cast<FrontFace*>( getRenderStateSet()->renderState( RS_FrontFace ) ); }
01997
01998 DepthFunc* gocDepthFunc();
01999 const DepthFunc* getDepthFunc() const { if (!getRenderStateSet()) return NULL; else return static_cast<const DepthFunc*>( getRenderStateSet()->renderState( RS_DepthFunc ) ); }
02000 DepthFunc* getDepthFunc() { if (!getRenderStateSet()) return NULL; else return static_cast<DepthFunc*>( getRenderStateSet()->renderState( RS_DepthFunc ) ); }
02001
02002 DepthMask* gocDepthMask();
02003 const DepthMask* getDepthMask() const { if (!getRenderStateSet()) return NULL; else return static_cast<const DepthMask*>( getRenderStateSet()->renderState( RS_DepthMask ) ); }
02004 DepthMask* getDepthMask() { if (!getRenderStateSet()) return NULL; else return static_cast<DepthMask*>( getRenderStateSet()->renderState( RS_DepthMask ) ); }
02005
02006 Color* gocColor();
02007 const Color* getColor() const { if (!getRenderStateSet()) return NULL; else return static_cast<const Color*>( getRenderStateSet()->renderState( RS_Color ) ); }
02008 Color* getColor() { if (!getRenderStateSet()) return NULL; else return static_cast<Color*>( getRenderStateSet()->renderState( RS_Color ) ); }
02009
02010 SecondaryColor* gocSecondaryColor();
02011 const SecondaryColor* getSecondaryColor() const { if (!getRenderStateSet()) return NULL; else return static_cast<const SecondaryColor*>( getRenderStateSet()->renderState( RS_SecondaryColor ) ); }
02012 SecondaryColor* getSecondaryColor() { if (!getRenderStateSet()) return NULL; else return static_cast<SecondaryColor*>( getRenderStateSet()->renderState( RS_SecondaryColor ) ); }
02013
02014 Normal* gocNormal();
02015 const Normal* getNormal() const { if (!getRenderStateSet()) return NULL; else return static_cast<const Normal*>( getRenderStateSet()->renderState( RS_Normal ) ); }
02016 Normal* getNormal() { if (!getRenderStateSet()) return NULL; else return static_cast<Normal*>( getRenderStateSet()->renderState( RS_Normal ) ); }
02017
02018 ColorMask* gocColorMask();
02019 const ColorMask* getColorMask() const { if (!getRenderStateSet()) return NULL; else return static_cast<const ColorMask*>( getRenderStateSet()->renderState( RS_ColorMask ) ); }
02020 ColorMask* getColorMask() { if (!getRenderStateSet()) return NULL; else return static_cast<ColorMask*>( getRenderStateSet()->renderState( RS_ColorMask ) ); }
02021
02022 PolygonMode* gocPolygonMode();
02023 const PolygonMode* getPolygonMode() const { if (!getRenderStateSet()) return NULL; else return static_cast<const PolygonMode*>( getRenderStateSet()->renderState( RS_PolygonMode ) ); }
02024 PolygonMode* getPolygonMode() { if (!getRenderStateSet()) return NULL; else return static_cast<PolygonMode*>( getRenderStateSet()->renderState( RS_PolygonMode ) ); }
02025
02026 ShadeModel* gocShadeModel();
02027 const ShadeModel* getShadeModel() const { if (!getRenderStateSet()) return NULL; else return static_cast<const ShadeModel*>( getRenderStateSet()->renderState( RS_ShadeModel ) ); }
02028 ShadeModel* getShadeModel() { if (!getRenderStateSet()) return NULL; else return static_cast<ShadeModel*>( getRenderStateSet()->renderState( RS_ShadeModel ) ); }
02029
02030 BlendEquation* gocBlendEquation();
02031 const BlendEquation* getBlendEquation() const { if (!getRenderStateSet()) return NULL; else return static_cast<const BlendEquation*>( getRenderStateSet()->renderState( RS_BlendEquation ) ); }
02032 BlendEquation* getBlendEquation() { if (!getRenderStateSet()) return NULL; else return static_cast<BlendEquation*>( getRenderStateSet()->renderState( RS_BlendEquation ) ); }
02033
02034 AlphaFunc* gocAlphaFunc();
02035 const AlphaFunc* getAlphaFunc() const { if (!getRenderStateSet()) return NULL; else return static_cast<const AlphaFunc*>( getRenderStateSet()->renderState( RS_AlphaFunc ) ); }
02036 AlphaFunc* getAlphaFunc() { if (!getRenderStateSet()) return NULL; else return static_cast<AlphaFunc*>( getRenderStateSet()->renderState( RS_AlphaFunc ) ); }
02037
02038 Material* gocMaterial();
02039 const Material* getMaterial() const { if (!getRenderStateSet()) return NULL; else return static_cast<const Material*>( getRenderStateSet()->renderState( RS_Material ) ); }
02040 Material* getMaterial() { if (!getRenderStateSet()) return NULL; else return static_cast<Material*>( getRenderStateSet()->renderState( RS_Material ) ); }
02041
02042 LightModel* gocLightModel();
02043 const LightModel* getLightModel() const { if (!getRenderStateSet()) return NULL; else return static_cast<const LightModel*>( getRenderStateSet()->renderState( RS_LightModel ) ); }
02044 LightModel* getLightModel() { if (!getRenderStateSet()) return NULL; else return static_cast<LightModel*>( getRenderStateSet()->renderState( RS_LightModel ) ); }
02045
02046 Fog* gocFog();
02047 const Fog* getFog() const { if (!getRenderStateSet()) return NULL; else return static_cast<const Fog*>( getRenderStateSet()->renderState( RS_Fog ) ); }
02048 Fog* getFog() { if (!getRenderStateSet()) return NULL; else return static_cast<Fog*>( getRenderStateSet()->renderState( RS_Fog ) ); }
02049
02050 PolygonOffset* gocPolygonOffset();
02051 const PolygonOffset* getPolygonOffset() const { if (!getRenderStateSet()) return NULL; else return static_cast<const PolygonOffset*>( getRenderStateSet()->renderState( RS_PolygonOffset ) ); }
02052 PolygonOffset* getPolygonOffset() { if (!getRenderStateSet()) return NULL; else return static_cast<PolygonOffset*>( getRenderStateSet()->renderState( RS_PolygonOffset ) ); }
02053
02054 LogicOp* gocLogicOp();
02055 const LogicOp* getLogicOp() const { if (!getRenderStateSet()) return NULL; else return static_cast<const LogicOp*>( getRenderStateSet()->renderState( RS_LogicOp ) ); }
02056 LogicOp* getLogicOp() { if (!getRenderStateSet()) return NULL; else return static_cast<LogicOp*>( getRenderStateSet()->renderState( RS_LogicOp ) ); }
02057
02058 DepthRange* gocDepthRange();
02059 const DepthRange* getDepthRange() const { if (!getRenderStateSet()) return NULL; else return static_cast<const DepthRange*>( getRenderStateSet()->renderState( RS_DepthRange ) ); }
02060 DepthRange* getDepthRange() { if (!getRenderStateSet()) return NULL; else return static_cast<DepthRange*>( getRenderStateSet()->renderState( RS_DepthRange ) ); }
02061
02062 LineWidth* gocLineWidth();
02063 const LineWidth* getLineWidth() const { if (!getRenderStateSet()) return NULL; else return static_cast<const LineWidth*>( getRenderStateSet()->renderState( RS_LineWidth ) ); }
02064 LineWidth* getLineWidth() { if (!getRenderStateSet()) return NULL; else return static_cast<LineWidth*>( getRenderStateSet()->renderState( RS_LineWidth ) ); }
02065
02066 PointSize* gocPointSize();
02067 const PointSize* getPointSize() const { if (!getRenderStateSet()) return NULL; else return static_cast<const PointSize*>( getRenderStateSet()->renderState( RS_PointSize ) ); }
02068 PointSize* getPointSize() { if (!getRenderStateSet()) return NULL; else return static_cast<PointSize*>( getRenderStateSet()->renderState( RS_PointSize ) ); }
02069
02070 LineStipple* gocLineStipple();
02071 const LineStipple* getLineStipple() const { if (!getRenderStateSet()) return NULL; else return static_cast<const LineStipple*>( getRenderStateSet()->renderState( RS_LineStipple ) ); }
02072 LineStipple* getLineStipple() { if (!getRenderStateSet()) return NULL; else return static_cast<LineStipple*>( getRenderStateSet()->renderState( RS_LineStipple ) ); }
02073
02074 PolygonStipple* gocPolygonStipple();
02075 const PolygonStipple* getPolygonStipple() const { if (!getRenderStateSet()) return NULL; else return static_cast<const PolygonStipple*>( getRenderStateSet()->renderState( RS_PolygonStipple ) ); }
02076 PolygonStipple* getPolygonStipple() { if (!getRenderStateSet()) return NULL; else return static_cast<PolygonStipple*>( getRenderStateSet()->renderState( RS_PolygonStipple ) ); }
02077
02078 PointParameter* gocPointParameter();
02079 const PointParameter* getPointParameter() const { if (!getRenderStateSet()) return NULL; else return static_cast<const PointParameter*>( getRenderStateSet()->renderState( RS_PointParameter ) ); }
02080 PointParameter* getPointParameter() { if (!getRenderStateSet()) return NULL; else return static_cast<PointParameter*>( getRenderStateSet()->renderState( RS_PointParameter ) ); }
02081
02082 StencilFunc* gocStencilFunc();
02083 const StencilFunc* getStencilFunc() const { if (!getRenderStateSet()) return NULL; else return static_cast<const StencilFunc*>( getRenderStateSet()->renderState( RS_StencilFunc ) ); }
02084 StencilFunc* getStencilFunc() { if (!getRenderStateSet()) return NULL; else return static_cast<StencilFunc*>( getRenderStateSet()->renderState( RS_StencilFunc ) ); }
02085
02086 StencilOp* gocStencilOp();
02087 const StencilOp* getStencilOp() const { if (!getRenderStateSet()) return NULL; else return static_cast<const StencilOp*>( getRenderStateSet()->renderState( RS_StencilOp ) ); }
02088 StencilOp* getStencilOp() { if (!getRenderStateSet()) return NULL; else return static_cast<StencilOp*>( getRenderStateSet()->renderState( RS_StencilOp ) ); }
02089
02090 StencilMask* gocStencilMask();
02091 const StencilMask* getStencilMask() const { if (!getRenderStateSet()) return NULL; else return static_cast<const StencilMask*>( getRenderStateSet()->renderState( RS_StencilMask ) ); }
02092 StencilMask* getStencilMask() { if (!getRenderStateSet()) return NULL; else return static_cast<StencilMask*>( getRenderStateSet()->renderState( RS_StencilMask ) ); }
02093
02094 BlendColor* gocBlendColor();
02095 const BlendColor* getBlendColor() const { if (!getRenderStateSet()) return NULL; else return static_cast<const BlendColor*>( getRenderStateSet()->renderState( RS_BlendColor ) ); }
02096 BlendColor* getBlendColor() { if (!getRenderStateSet()) return NULL; else return static_cast<BlendColor*>( getRenderStateSet()->renderState( RS_BlendColor ) ); }
02097
02098 BlendFunc* gocBlendFunc();
02099 const BlendFunc* getBlendFunc() const { if (!getRenderStateSet()) return NULL; else return static_cast<const BlendFunc*>( getRenderStateSet()->renderState( RS_BlendFunc ) ); }
02100 BlendFunc* getBlendFunc() { if (!getRenderStateSet()) return NULL; else return static_cast<BlendFunc*>( getRenderStateSet()->renderState( RS_BlendFunc ) ); }
02101
02102 SampleCoverage* gocSampleCoverage();
02103 const SampleCoverage* getSampleCoverage() const { if (!getRenderStateSet()) return NULL; else return static_cast<const SampleCoverage*>( getRenderStateSet()->renderState( RS_SampleCoverage ) ); }
02104 SampleCoverage* getSampleCoverage() { if (!getRenderStateSet()) return NULL; else return static_cast<SampleCoverage*>( getRenderStateSet()->renderState( RS_SampleCoverage ) ); }
02105
02106
02107
02108
02109
02110 VertexAttrib* gocVertexAttrib(int attr_index);
02111
02112 const VertexAttrib* getVertexAttrib(int attr_index) const;
02113
02114 VertexAttrib* getVertexAttrib(int attr_index);
02115
02116
02117
02118 Light* gocLight(int light_index);
02119
02120 const Light* getLight(int light_index) const;
02121
02122 Light* getLight(int light_index);
02123
02124
02125
02126 ClipPlane* gocClipPlane(int plane_index);
02127
02128 const ClipPlane* getClipPlane(int plane_index) const;
02129
02130 ClipPlane* getClipPlane(int plane_index);
02131
02132
02133
02134 TextureSampler* gocTextureSampler(int unit_index);
02135
02136 const TextureSampler* getTextureSampler(int unit_index) const { return static_cast<const TextureSampler*>( getRenderStateSet()->renderState( RS_TextureSampler, unit_index ) ); }
02137
02138 TextureSampler* getTextureSampler(int unit_index) { return static_cast<TextureSampler*>( getRenderStateSet()->renderState( RS_TextureSampler, unit_index ) ); }
02139
02140
02141
02142 TexEnv* gocTexEnv(int unit_index);
02143
02144 const TexEnv* getTexEnv(int unit_index) const { return static_cast<const TexEnv*>( getRenderStateSet()->renderState( RS_TexEnv, unit_index ) ); }
02145
02146 TexEnv* getTexEnv(int unit_index) { return static_cast<TexEnv*>( getRenderStateSet()->renderState( RS_TexEnv, unit_index ) ); }
02147
02148
02149
02150 TexGen* gocTexGen(int unit_index);
02151
02152 const TexGen* getTexGen(int unit_index) const { return static_cast<const TexGen*>( getRenderStateSet()->renderState( RS_TexGen, unit_index ) ); }
02153
02154 TexGen* getTexGen(int unit_index) { return static_cast<TexGen*>( getRenderStateSet()->renderState( RS_TexGen, unit_index ) ); }
02155
02156
02157
02158 TextureMatrix* gocTextureMatrix(int unit_index);
02159
02160 const TextureMatrix* getTextureMatrix(int unit_index) const { return static_cast<const TextureMatrix*>( getRenderStateSet()->renderState( RS_TextureMatrix, unit_index ) ); }
02161
02162 TextureMatrix* getTextureMatrix(int unit_index) { return static_cast<TextureMatrix*>( getRenderStateSet()->renderState( RS_TextureMatrix, unit_index ) ); }
02163
02164
02165
02166 void enable(EEnable capability) { gocEnableSet()->enable(capability); }
02167
02168 void disable(EEnable capability) { gocEnableSet()->disable(capability); }
02169
02170 const std::vector<EEnable>& enables() const { return getEnableSet()->enables(); }
02171
02172 int isEnabled(EEnable capability) const { if (!getEnableSet()) return false; return getEnableSet()->isEnabled(capability); }
02173
02174 void disableAll() { if (getEnableSet()) getEnableSet()->disableAll(); }
02175
02176 bool isBlendingEnabled() const { if (!getEnableSet()) return false; return getEnableSet()->isBlendingEnabled(); }
02177
02178
02179
02180 void setRenderState(RenderStateNonIndexed* renderstate) { gocRenderStateSet()->setRenderState(renderstate, -1); }
02181
02182 void setRenderState(RenderState* renderstate, int index) { gocRenderStateSet()->setRenderState(renderstate, index); }
02183
02184 const RenderState* renderState( ERenderState type, int index=0 ) const { if (!getRenderStateSet()) return NULL; return getRenderStateSet()->renderState(type, index); }
02185
02186 RenderState* renderState( ERenderState type, int index=0 ) { return gocRenderStateSet()->renderState(type, index); }
02187
02188 size_t renderStatesCount() const { return getRenderStateSet()->renderStatesCount(); }
02189
02190 const RenderStateSlot* renderStates() const { return getRenderStateSet()->renderStates(); }
02191
02192 RenderStateSlot* renderStates() { return getRenderStateSet()->renderStates(); }
02193
02195 void eraseRenderState(ERenderState type, int index=-1) { gocRenderStateSet()->eraseRenderState(type, index); }
02196
02197 void eraseRenderState(RenderState* rs, int index) { if (rs) gocRenderStateSet()->eraseRenderState(rs->type(), index); }
02198
02199 void eraseAllRenderStates() { if(getRenderStateSet()) getRenderStateSet()->eraseAllRenderStates(); }
02200
02202 const GLSLProgram* glslProgram() const { if (!getRenderStateSet()) return NULL; return getRenderStateSet()->glslProgram(); }
02203
02205 GLSLProgram* glslProgram() { return gocRenderStateSet()->glslProgram(); }
02206
02207
02208
02210 void setUniform(Uniform* uniform) { VL_CHECK(uniform); gocUniformSet()->setUniform(uniform); }
02211
02213 const std::vector< ref<Uniform> >& uniforms() const { return getUniformSet()->uniforms(); }
02214
02216 void eraseUniform(const char* name) { gocUniformSet()->eraseUniform(name); }
02217
02219 void eraseUniform(const Uniform* uniform) { gocUniformSet()->eraseUniform(uniform); }
02220
02222 void eraseAllUniforms() { if (getUniformSet()) getUniformSet()->eraseAllUniforms(); }
02223
02225 Uniform* gocUniform(const char* name) { return gocUniformSet()->gocUniform(name); }
02226
02228 Uniform* getUniform(const char* name) { return getUniformSet()->getUniform(name); }
02229
02231 const Uniform* getUniform(const char* name) const { return getUniformSet()->getUniform(name); }
02232
02233
02234
02235 EnableSet* gocEnableSet() { if (!mEnableSet) mEnableSet = new EnableSet; return mEnableSet.get(); }
02236
02237 EnableSet* getEnableSet() { return mEnableSet.get(); }
02238
02239 const EnableSet* getEnableSet() const { return mEnableSet.get(); }
02240
02241 RenderStateSet* gocRenderStateSet() { if (!mRenderStateSet) mRenderStateSet = new RenderStateSet; return mRenderStateSet.get(); }
02242
02243 RenderStateSet* getRenderStateSet() { return mRenderStateSet.get(); }
02244
02245 const RenderStateSet* getRenderStateSet() const { return mRenderStateSet.get(); }
02246
02257 UniformSet* gocUniformSet() { if (!mUniformSet) mUniformSet = new UniformSet; return mUniformSet.get(); }
02258
02269 UniformSet* getUniformSet() { return mUniformSet.get(); }
02270
02281 const UniformSet* getUniformSet() const { return mUniformSet.get(); }
02282
02283 void setEnableSet(EnableSet* es) { mEnableSet = es; }
02284
02285 void setRenderStateSet(RenderStateSet* rss) { mRenderStateSet = rss; }
02286
02297 void setUniformSet(UniformSet* us) { mUniformSet = us; }
02298
02308 void setScissor(Scissor* scissor) { mScissor = scissor; }
02309
02317 const Scissor* scissor() const { return mScissor.get(); }
02318
02326 Scissor* scissor() { return mScissor.get(); }
02327
02329 void setShaderAnimator(ShaderAnimator* animator) { mShaderAnimator = animator; }
02330
02332 ShaderAnimator* shaderAnimator() { return mShaderAnimator.get(); }
02333
02335 const ShaderAnimator* shaderAnimator() const { return mShaderAnimator.get(); }
02336
02338 real lastUpdateTime() const { return mLastUpdateTime; }
02339
02341 void setLastUpdateTime(real time) { mLastUpdateTime = time; }
02342
02343 #if VL_SHADER_USER_DATA
02344 public:
02345 void* shaderUserData() { return mShaderUserData; }
02346 const void* shaderUserData() const { return mShaderUserData; }
02347 void setShaderUserData(void* user_data) { mShaderUserData = user_data; }
02348
02349 private:
02350 void* mShaderUserData;
02351 #endif
02352
02353 protected:
02354 ref<RenderStateSet> mRenderStateSet;
02355 ref<EnableSet> mEnableSet;
02356 ref<UniformSet> mUniformSet;
02357 ref<Scissor> mScissor;
02358 ref<ShaderAnimator> mShaderAnimator;
02359 real mLastUpdateTime;
02360 };
02361 }
02362
02363 #endif