PixelLightAPI  .
RenderStates.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: RenderStates.h                                 *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLRENDERER_RENDERSTATES_H__
00024 #define __PLRENDERER_RENDERSTATES_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Object.h>
00032 #include "PLRenderer/PLRenderer.h"
00033 #include "PLRenderer/Renderer/Types.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Namespace                                             ]
00038 //[-------------------------------------------------------]
00039 namespace PLRenderer {
00040 
00041 
00042 //[-------------------------------------------------------]
00043 //[ Classes                                               ]
00044 //[-------------------------------------------------------]
00045 /**
00046 *  @brief
00047 *    Render states RTTI wrapper class
00048 */
00049 class RenderStates : public PLCore::Object {
00050 
00051 
00052     //[-------------------------------------------------------]
00053     //[ RTTI interface                                        ]
00054     //[-------------------------------------------------------]
00055     pl_class(PLRENDERER_RTTI_EXPORT, RenderStates, "PLRenderer", PLCore::Object, "Render states RTTI wrapper class")
00056         // Attributes
00057             // Modes
00058         pl_attribute(FillMode,              pl_enum_type(Fill::Enum),               Fill::Solid,                ReadWrite,  GetSet, "Fill mode",                                                                            "")
00059         pl_attribute(CullMode,              pl_enum_type(Cull::Enum),               Cull::CCW,                  ReadWrite,  GetSet, "Cull mode",                                                                            "")
00060             // Z buffer
00061         pl_attribute(ZEnable,               bool,                                   true,                       ReadWrite,  GetSet, "Enable/disable z buffer test",                                                         "")
00062         pl_attribute(ZWriteEnable,          bool,                                   true,                       ReadWrite,  GetSet, "Enable/disable z buffer writing",                                                      "")
00063         pl_attribute(ZFunc,                 pl_enum_type(Compare::Enum),            Compare::LessEqual,         ReadWrite,  GetSet, "Z buffer function",                                                                    "")
00064         pl_attribute(ZBias,                 float,                                  0.0f,                       ReadWrite,  GetSet, "Z bias/polygon offset factor",                                                         "")
00065         pl_attribute(SlopeScaleDepthBias,   float,                                  0.0f,                       ReadWrite,  GetSet, "Slope scale bias/polygon offset factor",                                               "")
00066         pl_attribute(DepthBias,             float,                                  0.0f,                       ReadWrite,  GetSet, "Depth bias/polygon offset units",                                                      "")
00067             // Blend
00068         pl_attribute(BlendEnable,           bool,                                   false,                      ReadWrite,  GetSet, "Enable/disable blending",                                                              "")
00069         pl_attribute(SrcBlendFunc,          pl_enum_type(BlendFunc::Enum),          BlendFunc::SrcAlpha,        ReadWrite,  GetSet, "Source blend function",                                                                "")
00070         pl_attribute(DstBlendFunc,          pl_enum_type(BlendFunc::Enum),          BlendFunc::InvSrcAlpha,     ReadWrite,  GetSet, "Destination blend function",                                                           "")
00071             // Stencil
00072         pl_attribute(StencilEnable,         bool,                                   false,                      ReadWrite,  GetSet, "Enable/disable stencil test",                                                          "")
00073         pl_attribute(StencilFunc,           pl_enum_type(Compare::Enum),            Compare::Always,            ReadWrite,  GetSet, "Stencil test passes if ((ref & mask) stencilfn (stencil & mask)) is true",             "")
00074         pl_attribute(StencilRef,            PLCore::uint32,                         0,                          ReadWrite,  GetSet, "Reference value used in stencil test",                                                 "")
00075         pl_attribute(StencilMask,           PLCore::uint32,                         0xFFFFFFFF,                 ReadWrite,  GetSet, "Mask value used in stencil test",                                                      "")
00076         pl_attribute(StencilFail,           pl_enum_type(StencilOp::Enum),          StencilOp::Keep,            ReadWrite,  GetSet, "Operation to perform if stencil test fails",                                           "")
00077         pl_attribute(StencilZFail,          pl_enum_type(StencilOp::Enum),          StencilOp::Keep,            ReadWrite,  GetSet, "Operation to perform if stencil test passes and Z test fails",                         "")
00078         pl_attribute(StencilPass,           pl_enum_type(StencilOp::Enum),          StencilOp::Keep,            ReadWrite,  GetSet, "Operation to perform if both stencil and Z tests pass",                                "")
00079         pl_attribute(TwoSidedStencilMode,   bool,                                   false,                      ReadWrite,  GetSet, "Enable/disable 2 sided stenciling",                                                    "")
00080         pl_attribute(CCWStencilFunc,        pl_enum_type(Compare::Enum),            Compare::Always,            ReadWrite,  GetSet, "Stencil test passes if ((ref & mask) stencilfn (stencil & mask)) is true",             "")
00081         pl_attribute(CCWStencilFail,        pl_enum_type(StencilOp::Enum),          StencilOp::Keep,            ReadWrite,  GetSet, "Operation to perform if ccw stencil test fails",                                       "")
00082         pl_attribute(CCWStencilZFail,       pl_enum_type(StencilOp::Enum),          StencilOp::Keep,            ReadWrite,  GetSet, "Operation to perform if ccw stencil test passes and Z test fails",                     "")
00083         pl_attribute(CCWStencilPass,        pl_enum_type(StencilOp::Enum),          StencilOp::Keep,            ReadWrite,  GetSet, "Operation to perform if both ccw stencil and Z tests pass",                            "")
00084             // Point and line
00085         pl_attribute(PointSize,             float,                                  1.0f,                       ReadWrite,  GetSet, "Point size when it is not specified for each vertex",                                  "")
00086         pl_attribute(PointScaleEnable,      bool,                                   false,                      ReadWrite,  GetSet, "Controls computation of size for point primitives",                                    "")
00087         pl_attribute(PointSizeMin,          float,                                  1.0f,                       ReadWrite,  GetSet, "Minimum size of point primitives",                                                     "")
00088         pl_attribute(PointSizeMax,          float,                                  64.0f,                      ReadWrite,  GetSet, "Maximum size of point primitives, must be greater than or equal to m_fPointSizeMin",   "")
00089         pl_attribute(PointScaleA,           float,                                  1.0f,                       ReadWrite,  GetSet, "Controls for distance-based size attenuation for point primitives",                    "")
00090         pl_attribute(PointScaleB,           float,                                  0.0f,                       ReadWrite,  GetSet, "Controls for distance-based size attenuation for point primitives",                    "")
00091         pl_attribute(PointScaleC,           float,                                  0.0f,                       ReadWrite,  GetSet, "Controls for distance-based size attenuation for point primitives",                    "")
00092         pl_attribute(LineWidth,             float,                                  1.0f,                       ReadWrite,  GetSet, "Line width",                                                                           "")
00093             // Tessellation
00094         pl_attribute(TessellationFactor,    PLCore::uint32,                         1,                          ReadWrite,  GetSet, "Tessellation factor",                                                                  "Min=1")
00095 // [TODO] Linux GCC: "error: changes meaning of ‘TessellationMode’ from ‘class PLRenderer::TessellationMode"
00096 //      pl_attribute(TessellationMode,      pl_enum_type(TessellationMode::Enum),   TessellationMode::Discrete, ReadWrite,  GetSet, "Tessellation mode",                                                                    "")
00097             // Misc
00098         pl_attribute(PointSpriteEnable,     bool,                                   false,                      ReadWrite,  GetSet, "When true, use point texture mapping",                                                 "")
00099         pl_attribute(DitherEnable,          bool,                                   false,                      ReadWrite,  GetSet, "Enable/disable dithering",                                                             "")
00100         pl_attribute(ScissorTestEnable,     bool,                                   false,                      ReadWrite,  GetSet, "Enable/disable the scissor test",                                                      "")
00101         pl_attribute(MultisampleEnable,     bool,                                   true,                       ReadWrite,  GetSet, "When true, use multisample",                                                           "")
00102         pl_attribute(InvCullMode,           bool,                                   false,                      ReadWrite,  GetSet, "Controls computation of size for point primitives",                                    "")
00103         pl_attribute(FixedFillMode,         pl_enum_type(Fill::Enum),               Fill::Unknown,              ReadWrite,  GetSet, "General fill mode which is normally set once",                                         "")
00104     pl_class_end
00105 
00106 
00107     //[-------------------------------------------------------]
00108     //[ Public RTTI get/set functions                         ]
00109     //[-------------------------------------------------------]
00110     public:
00111         // Modes
00112         inline Fill::Enum GetFillMode() const;
00113         inline void SetFillMode(Fill::Enum nValue);
00114         inline Cull::Enum GetCullMode() const;
00115         inline void SetCullMode(Cull::Enum nValue);
00116         // Z buffer
00117         inline bool GetZEnable() const;
00118         inline void SetZEnable(bool bValue);
00119         inline bool GetZWriteEnable() const;
00120         inline void SetZWriteEnable(bool bValue);
00121         inline Compare::Enum GetZFunc() const;
00122         inline void SetZFunc(Compare::Enum nValue);
00123         inline float GetZBias() const;
00124         inline void SetZBias(float fValue);
00125         inline float GetSlopeScaleDepthBias() const;
00126         inline void SetSlopeScaleDepthBias(float fValue);
00127         inline float GetDepthBias() const;
00128         inline void SetDepthBias(float fValue);
00129         // Blend
00130         inline bool GetBlendEnable() const;
00131         inline void SetBlendEnable(bool bValue);
00132         inline BlendFunc::Enum GetSrcBlendFunc() const;
00133         inline void SetSrcBlendFunc(BlendFunc::Enum nValue);
00134         inline BlendFunc::Enum GetDstBlendFunc() const;
00135         inline void SetDstBlendFunc(BlendFunc::Enum nValue);
00136         // Stencil
00137         inline bool GetStencilEnable() const;
00138         inline void SetStencilEnable(bool bValue);
00139         inline Compare::Enum GetStencilFunc() const;
00140         inline void SetStencilFunc(Compare::Enum nValue);
00141         inline PLCore::uint32 GetStencilRef() const;
00142         inline void SetStencilRef(PLCore::uint32 nValue);
00143         inline PLCore::uint32 GetStencilMask() const;
00144         inline void SetStencilMask(PLCore::uint32 nValue);
00145         inline StencilOp::Enum GetStencilFail() const;
00146         inline void SetStencilFail(StencilOp::Enum nValue);
00147         inline StencilOp::Enum GetStencilZFail() const;
00148         inline void SetStencilZFail(StencilOp::Enum nValue);
00149         inline StencilOp::Enum GetStencilPass() const;
00150         inline void SetStencilPass(StencilOp::Enum nValue);
00151         inline bool GetTwoSidedStencilMode() const;
00152         inline void SetTwoSidedStencilMode(bool bValue);
00153         inline Compare::Enum GetCCWStencilFunc() const;
00154         inline void SetCCWStencilFunc(Compare::Enum nValue);
00155         inline StencilOp::Enum GetCCWStencilFail() const;
00156         inline void SetCCWStencilFail(StencilOp::Enum nValue);
00157         inline StencilOp::Enum GetCCWStencilZFail() const;
00158         inline void SetCCWStencilZFail(StencilOp::Enum nValue);
00159         inline StencilOp::Enum GetCCWStencilPass() const;
00160         inline void SetCCWStencilPass(StencilOp::Enum nValue);
00161         // Point and line
00162         inline float GetPointSize() const;
00163         inline void SetPointSize(float fValue);
00164         inline bool GetPointScaleEnable() const;
00165         inline void SetPointScaleEnable(bool bValue);
00166         inline float GetPointSizeMin() const;
00167         inline void SetPointSizeMin(float fValue);
00168         inline float GetPointSizeMax() const;
00169         inline void SetPointSizeMax(float fValue);
00170         inline float GetPointScaleA() const;
00171         inline void SetPointScaleA(float fValue);
00172         inline float GetPointScaleB() const;
00173         inline void SetPointScaleB(float fValue);
00174         inline float GetPointScaleC() const;
00175         inline void SetPointScaleC(float fValue);
00176         inline float GetLineWidth() const;
00177         inline void SetLineWidth(float fValue);
00178         // Tessellation
00179         inline PLCore::uint32 GetTessellationFactor() const;
00180         inline void SetTessellationFactor(PLCore::uint32 nValue);
00181         /*
00182         // [TODO] Linux GCC: "error: changes meaning of ‘TessellationMode’ from ‘class PLRenderer::TessellationMode"
00183         inline TessellationMode::Enum GetTessellationMode() const;
00184         inline void SetTessellationMode(TessellationMode::Enum nValue);
00185         */
00186         // Misc
00187         inline bool GetPointSpriteEnable() const;
00188         inline void SetPointSpriteEnable(bool bValue);
00189         inline bool GetDitherEnable() const;
00190         inline void SetDitherEnable(bool bValue);
00191         inline bool GetScissorTestEnable() const;
00192         inline void SetScissorTestEnable(bool bValue);
00193         inline bool GetMultisampleEnable() const;
00194         inline void SetMultisampleEnable(bool bValue);
00195         inline bool GetInvCullMode() const;
00196         inline void SetInvCullMode(bool bValue);
00197         inline Fill::Enum GetFixedFillMode() const;
00198         inline void SetFixedFillMode(Fill::Enum nValue);
00199 
00200 
00201     //[-------------------------------------------------------]
00202     //[ Public functions                                      ]
00203     //[-------------------------------------------------------]
00204     public:
00205         /**
00206         *  @brief
00207         *    Constructor
00208         */
00209         PLRENDERER_API RenderStates();
00210 
00211         /**
00212         *  @brief
00213         *    Copy constructor
00214         *
00215         *  @param[in] cSource
00216         *    Source to copy from
00217         */
00218         PLRENDERER_API RenderStates(const RenderStates &cSource);
00219 
00220         /**
00221         *  @brief
00222         *    Destructor
00223         */
00224         PLRENDERER_API virtual ~RenderStates();
00225 
00226         /**
00227         *  @brief
00228         *    Retrieves a render-state value
00229         *
00230         *  @param[in] nState
00231         *    State variable that is being queried. This parameter can
00232         *    be any member of the render state enumerated type.
00233         *
00234         *  @return
00235         *    The value of the queried render state variable
00236         *
00237         *  @note
00238         *    - Some settings like stencil, fog and scissor test aren't set
00239         *      by the material through the default setting
00240         */
00241         inline PLCore::uint32 Get(RenderState::Enum nState) const;
00242 
00243         /**
00244         *  @brief
00245         *    Sets a single render-state parameter
00246         *
00247         *  @param[in] nState
00248         *    State variable that is being modified. This parameter can
00249         *    be any member of the render state enumerated type.
00250         *  @param[in] nValue
00251         *    New value for the render state to be set. The meaning of
00252         *    this parameter is dependent on the value specified for nState.
00253         *    For example, if nState is Shade, the second parameter
00254         *    must be one member of the Shade enumerated type. (e.g. Shade::Flat)
00255         *    You can also set the value to unknown - then this state is ignored.
00256         *
00257         *  @return
00258         *    'true' if all went fine, else 'false'
00259         */
00260         inline bool Set(RenderState::Enum nState, PLCore::uint32 nValue);
00261 
00262         /**
00263         *  @brief
00264         *    Copy operator
00265         *
00266         *  @param[in] cSource
00267         *    Source to copy from
00268         *
00269         *  @return
00270         *    This class
00271         */
00272         inline RenderStates &operator =(const RenderStates &cSource);
00273 
00274 
00275     //[-------------------------------------------------------]
00276     //[ Private data                                          ]
00277     //[-------------------------------------------------------]
00278     private:
00279         // Exported variables
00280         PLCore::uint32 m_nRS[RenderState::Number];  /**< List of render states (see RenderState) */
00281 
00282 
00283 };
00284 
00285 
00286 //[-------------------------------------------------------]
00287 //[ Namespace                                             ]
00288 //[-------------------------------------------------------]
00289 } // PLRenderer
00290 
00291 
00292 //[-------------------------------------------------------]
00293 //[ Implementation                                        ]
00294 //[-------------------------------------------------------]
00295 #include "PLRenderer/Renderer/RenderStates.inl"
00296 
00297 
00298 #endif // __PLRENDERER_RENDERSTATES_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:59
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported