PixelLightAPI  .
FixedFunctions.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: FixedFunctions.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_FIXEDFUNCTIONS_H__
00024 #define __PLRENDERER_FIXEDFUNCTIONS_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Rtti.h>
00032 #include <PLMath/Vector3.h>
00033 #include <PLGraphics/Color/Color4.h>
00034 #include "PLRenderer/PLRenderer.h"
00035 
00036 
00037 //[-------------------------------------------------------]
00038 //[ Forward declarations                                  ]
00039 //[-------------------------------------------------------]
00040 namespace PLMath {
00041     class Matrix3x4;
00042     class Matrix4x4;
00043 }
00044 namespace PLRenderer {
00045     class VertexBuffer;
00046 }
00047 
00048 
00049 //[-------------------------------------------------------]
00050 //[ Namespace                                             ]
00051 //[-------------------------------------------------------]
00052 namespace PLRenderer {
00053 
00054 
00055 //[-------------------------------------------------------]
00056 //[ Classes                                               ]
00057 //[-------------------------------------------------------]
00058 /**
00059 *  @brief
00060 *    Abstract fixed functions renderer interface
00061 *
00062 *  @note
00063 *    - A legacy renderer interface for previously build in features in old graphics APIs and GPUs
00064 */
00065 class FixedFunctions {
00066 
00067 
00068     //[-------------------------------------------------------]
00069     //[ Public definitions                                    ]
00070     //[-------------------------------------------------------]
00071     public:
00072         /**
00073         *  @brief
00074         *    Holds all hardware capabilities
00075         */
00076         struct Capabilities {
00077             PLCore::uint8 nMaxActiveLights;         /**< Maximum number of active lights */
00078             PLCore::uint8 nMaxClipPlanes;           /**< Maximum number of clip planes */
00079             bool          bVertexBufferFogCoord;    /**< Vertex buffer fog coordinates supported? (for VertexBuffer::FogCoord) */
00080             PLCore::uint8 nMaxVertexBufferStreams;  /**< Maximum number of vertex buffer streams */
00081         };
00082 
00083         /**
00084         *  @brief
00085         *    Fixed functions render states
00086         */
00087         class RenderState {
00088             public:
00089             enum Enum {
00090                 // Fog
00091                 FogEnable           = 0,    /**< Enable/disable fog (false/true, default: false) */
00092                 FogColor            = 1,    /**< RGBA fog color (PLCore::uint32, default: 0/0/0/0) */
00093                 FogDensity          = 2,    /**< Fog density (float, default: 1.0) */
00094                 FogStart            = 3,    /**< Fog start (float, default: 0.0) */
00095                 FogEnd              = 4,    /**< Fog start (float, default: 1.0) */
00096                 FogMode             = 5,    /**< Fog mode (Fog, default: Fog::Exp) */
00097                 // Alpha test
00098                 AlphaTestEnable     = 6,    /**< Enable/disable alpha test (false/true, default: false) */
00099                 AlphaTestFunction   = 7,    /**< Alpha test comparison function (see 'Compare', default: Compare::GreaterEqual) */
00100                 AlphaTestReference  = 8,    /**< Alpha test reference value (0-1, default: 0.5) */
00101                 // Misc
00102                 Lighting            = 9,    /**< Enable/disable lighting (false/true, default: false) */
00103                 Ambient             = 10,   /**< General RGBA ambient color (PLCore::uint32, default: 0.0/0.0/0.0/0.0) */
00104                 NormalizeNormals    = 11,   /**< Enable/disable normalize normals (false/true, default: true) */
00105                 ShadeMode           = 12,   /**< Shade mode (see Shade, default: Shade::Smooth) */
00106                 // End
00107                 Number              = 13,   /**< Number of render states */
00108                 Unknown             = 14    /**< Unknown render state */
00109             };
00110         };
00111 
00112         /**
00113         *  @brief
00114         *    Transform states
00115         *
00116         *  @note
00117         *    - The default value for each matrix is the identity matrix
00118         */
00119         class Transform {
00120             public:
00121             enum Enum {
00122                 // View and projection
00123                 Projection =  0,    /**< Projection transformation matrix */
00124                 View       =  1,    /**< View transformation matrix */
00125                 World      =  2,    /**< World transformation matrix */
00126                 // Texture
00127                 Texture0   =  3,    /**< Texture matrix for stage 0 */
00128                 Texture1   =  4,    /**< Texture matrix for stage 1 */
00129                 Texture2   =  5,    /**< Texture matrix for stage 2 */
00130                 Texture3   =  6,    /**< Texture matrix for stage 3 */
00131                 Texture4   =  7,    /**< Texture matrix for stage 4 */
00132                 Texture5   =  8,    /**< Texture matrix for stage 5 */
00133                 Texture6   =  9,    /**< Texture matrix for stage 6 */
00134                 Texture7   = 10,    /**< Texture matrix for stage 7 */
00135                 // End
00136                 Number     = 11,    /**< Number of transform states */
00137                 Unknown    = 12     /**< Unknown transform state */
00138             };
00139         };
00140 
00141         /**
00142         *  @brief
00143         *    Texture environment modes
00144         */
00145         class TextureEnvironment {
00146             public:
00147             enum Enum {
00148                 Add                 = 0,    /**< Add */
00149                 Replace             = 1,    /**< Replace */
00150                 Modulate            = 2,    /**< Modulate */
00151                 PassThru            = 3,    /**< Pass thru */
00152                 Dot3                = 4,    /**< Dot 3*/
00153                 Interpolate         = 5,    /**< Interpolate */
00154                 InterpolatePrimary  = 6,    /**< Interpolate primary */
00155                 InterpolateTexAlpha = 7,    /**< Interpolate texture alpha */
00156                 // End
00157                 Number              = 8,    /**< Number of texture environment modes */
00158                 Unknown             = 9     /**< Unknown texture environment mode */
00159             };
00160             pl_enum(Enum)
00161                 pl_enum_value(Add,                  "Add")
00162                 pl_enum_value(Replace,              "Replace")
00163                 pl_enum_value(Modulate,             "Modulate")
00164                 pl_enum_value(PassThru,             "Pass thru")
00165                 pl_enum_value(Dot3,                 "Dot 3")
00166                 pl_enum_value(Interpolate,          "Interpolate")
00167                 pl_enum_value(InterpolatePrimary,   "Interpolate primary")
00168                 pl_enum_value(InterpolateTexAlpha,  "Interpolate texture alpha")
00169             pl_enum_end
00170         };
00171 
00172         /**
00173         *  @brief
00174         *    Texture coordinate generation modes
00175         */
00176         class TexCoordGen {
00177             public:
00178             enum Enum {
00179                 None          = 0,  /**< No texture coordinate generation (passthru) */
00180                 ObjectLinear  = 1,  /**< Object linear */
00181                 EyeLinear     = 2,  /**< Eye linear */
00182                 ReflectionMap = 3,  /**< Reflection map. Internally the texture matrix is multiplied with the inversed view matrix
00183                                          automatically for correct reflections before the matrix is send to the API. If you request
00184                                          the current texture matrix, the original matrix set by SetTransformState() is returned. */
00185                 NormalMap     = 4,  /**< Normal map */
00186                 SphereMap     = 5,  /**< Sphere map */
00187                 // End
00188                 Number        = 6,  /**< Number of texture coordinate generation modes */
00189                 Unknown       = 7   /**< Unknown texture coordinate generation mode */
00190             };
00191             pl_enum(Enum)
00192                 pl_enum_value(None,             "No texture coordinate generation (passthru)")
00193                 pl_enum_value(ObjectLinear,     "Object linear")
00194                 pl_enum_value(EyeLinear,        "Eye linear")
00195                 pl_enum_value(ReflectionMap,    "Reflection map")
00196                 pl_enum_value(NormalMap,        "Normal map")
00197                 pl_enum_value(SphereMap,        "Sphere map")
00198             pl_enum_end
00199         };
00200 
00201         /**
00202         *  @brief
00203         *    Texture stage states
00204         */
00205         class TextureStage {
00206             public:
00207             enum Enum {
00208                 ColorTexEnv = 0,    /**< Color texture environment mode (TextureEnvironment, default: TextureEnvironment::Modulate) */
00209                 AlphaTexEnv = 1,    /**< Alpha texture environment mode (TextureEnvironment, default: TextureEnvironment::Modulate) */
00210                 TexGen      = 2,    /**< Texture coordinate generation mode (TexCoordGen, default: TexCoordGen::None) */
00211                 // End
00212                 Number      = 3,    /**< Number of texture stage states */
00213                 Unknown     = 4     /**< Unknown texture stage state */
00214             };
00215         };
00216 
00217         /**
00218         *  @brief
00219         *    Fog modes
00220         */
00221         class Fog {
00222             public:
00223             enum Enum {
00224                 Exp     = 0,    /**< Fog effect intensifies exponentially (f=1/((e^(d*density)))) */
00225                 Exp2    = 1,    /**< Fog effect intensifies exponentially with the square of the distance (f=1/((e^((d*density)^2)))) */
00226                 Linear  = 2,    /**< Fog effect intensifies linearly between the start and end points (f=(end-d)/(end-start)) */
00227                 // End
00228                 Number  = 3,    /**< Number of fog modes */
00229                 Unknown = 4     /**< Unknown fog mode */
00230             };
00231             pl_enum(Enum)
00232                 pl_enum_value(Exp,      "Fog effect intensifies exponentially (f=1/((e^(d*density))))")
00233                 pl_enum_value(Exp2,     "Fog effect intensifies exponentially with the square of the distance (f=1/((e^((d*density)^2))))")
00234                 pl_enum_value(Linear,   "Fog effect intensifies linearly between the start and end points (f=(end-d)/(end-start))")
00235             pl_enum_end
00236         };
00237 
00238         /**
00239         *  @brief
00240         *    Material states
00241         */
00242         class MaterialState {
00243             public:
00244             enum Enum {
00245                 Ambient   = 0,  /**< RGBA ambient color (PLCore::uint32, default: 0.2, 0.2, 0.2, 1.0) */
00246                 Diffuse   = 1,  /**< RGBA diffuse color (PLCore::uint32, default: 0.8, 0.8, 0.8, 1.0) */
00247                 Specular  = 2,  /**< RGBA specular color (PLCore::uint32, default: 0.0, 0.0, 0.0, 1.0) */
00248                 Emission  = 3,  /**< RGBA emission color (PLCore::uint32, default: 0.0, 0.0, 0.0, 1.0) */
00249                 Shininess = 4,  /**< Shininess (float, default: 0.0) */
00250                 // End
00251                 Number    = 5,  /**< Number of material states */
00252                 Unknown   = 6   /**< Unknown material state */
00253             };
00254         };
00255 
00256         /**
00257         *  @brief
00258         *    Light types
00259         */
00260         class LightType {
00261             public:
00262             enum Enum {
00263                 Point       = 0,    /**< Point light */
00264                 Spot        = 1,    /**< Spot light */
00265                 Directional = 2,    /**< Directional light */
00266                 // End
00267                 Number      = 3,    /**< Number of light types */
00268                 Unknown     = 4     /**< Unknown light type */
00269             };
00270         };
00271 
00272         /**
00273         *  @brief
00274         *    Light data
00275         *
00276         *  @remarks
00277         *    attenuation = 1/(fConstantAttenuation      +
00278         *                     fLinearAttenuation    * d +
00279         *                     fQuadraticAttenuation * d2)
00280         *    Where: d  = Distance from vertex position to light position \n
00281         *           d2 = d squared
00282         */
00283         struct Light {
00284             LightType::Enum    nType;                   /**< Light source type (LightType, default: LightType::Point) */
00285             PLGraphics::Color4 cAmbient;                /**< RGBA ambient color of light (default: 0.0/0.0/0.0/0.0) */
00286             PLGraphics::Color4 cDiffuse;                /**< RGBA diffuse color of light (default: 0.0/0.0/0.0/0.0) */
00287             PLGraphics::Color4 cSpecular;               /**< RGBA specular color of light (default: 0.0/0.0/0.0/0.0) */
00288             PLMath::Vector3    vPosition;               /**< x/y/z position of light in world space (default: 0.0/0.0/0.0) */
00289             PLMath::Vector3    vDirection;              /**< x/y/z direction of light in world space (default: 0.0/0.0/0.0) */
00290             float              fCutOff;                 /**< Cutoff range (default: 0.0) */
00291             float              fConstantAttenuation;    /**< Constant attenuation (default: 1.0) */
00292             float              fLinearAttenuation;      /**< Linear attenuation (default: 0.0) */
00293             float              fQuadraticAttenuation;   /**< Quadratic attenuation (default: 0.0) */
00294         };
00295 
00296         /**
00297         *  @brief
00298         *    Shade modes
00299         */
00300         class Shade {
00301             public:
00302             enum Enum {
00303                 Flat    = 0,    /**< No interpolated during rasterizing */
00304                 Smooth  = 1,    /**< Interpolated during rasterizing */
00305                 // End
00306                 Number  = 2,    /**< Number of shade modes */
00307                 Unknown = 3     /**< Unknown shade mode */
00308             };
00309             pl_enum(Enum)
00310                 pl_enum_value(Flat,     "No interpolated during rasterizing")
00311                 pl_enum_value(Smooth,   "Interpolated during rasterizing")
00312             pl_enum_end
00313         };
00314 
00315 
00316     //[-------------------------------------------------------]
00317     //[ Public virtual FixedFunctions functions               ]
00318     //[-------------------------------------------------------]
00319     public:
00320         /**
00321         *  @brief
00322         *    Returns the renderer fixed functions capabilities
00323         *
00324         *  @return
00325         *    The renderer fixed functions capabilities
00326         */
00327         virtual const Capabilities &GetCapabilities() const = 0;
00328 
00329         /**
00330         *  @brief
00331         *    Resets all fixed functions render states, texture units etc. to default
00332         *
00333         *  @note
00334         *    - Avoid calling this function frequently because this can be a performance hit
00335         *    - Internally this functions are called:
00336         *      ResetRenderStates(), SetColor(), ResetTransformStates(), ResetTextureStageStates(),
00337         *      ResetMaterialStates(), ResetLights(), SetClipPlaneEnabled(), SetClipPlane(), SetVertexBuffer()
00338         */
00339         virtual void Reset() = 0;
00340 
00341         //[-------------------------------------------------------]
00342         //[ Render states                                         ]
00343         //[-------------------------------------------------------]
00344         /**
00345         *  @brief
00346         *    Returns a default render state
00347         *
00348         *  @param[in] nState
00349         *    Render state to return the default value from
00350         *
00351         *  @return
00352         *    The default state
00353         */
00354         virtual PLCore::uint32 GetDefaultRenderState(RenderState::Enum nState) const = 0;
00355 
00356         /**
00357         *  @brief
00358         *    Resets all render states to default
00359         *
00360         *  @see
00361         *    - GetDefaultRenderState()
00362         */
00363         virtual void ResetRenderStates() = 0;
00364 
00365         /**
00366         *  @brief
00367         *    Retrieves a render-state value
00368         *
00369         *  @param[in] nState
00370         *    State variable that is being queried. This parameter can
00371         *    be any member of the render state enumerated type.
00372         *
00373         *  @return
00374         *    The value of the queried render state variable, < 0 on error
00375         *
00376         *  @see
00377         *    - GetDefaultRenderState()
00378         */
00379         virtual int GetRenderState(RenderState::Enum nState) const = 0;
00380 
00381         /**
00382         *  @brief
00383         *    Sets a single render-state parameter
00384         *
00385         *  @param[in] nState
00386         *    State variable that is being modified. This parameter
00387         *    can be any member of the render state enumerated type.
00388         *  @param[in] nValue
00389         *    New value for the render state to be set. The meaning of
00390         *    this parameter is dependent on the value specified for nState.
00391         *    For example, if nState is FogMode, the second parameter
00392         *    must be one member of the Shade enumerated type. (e.g. Fog::Exp)
00393         *
00394         *  @return
00395         *    'true' if all went fine, else 'false'
00396         *
00397         *  @see
00398         *    - GetDefaultRenderState()
00399         */
00400         virtual bool SetRenderState(RenderState::Enum nState, PLCore::uint32 nValue) = 0;
00401 
00402         /**
00403         *  @brief
00404         *    Gets the current color
00405         *
00406         *  @return
00407         *    Current RGBA color
00408         */
00409         virtual PLGraphics::Color4 GetColor() const = 0;
00410 
00411         /**
00412         *  @brief
00413         *    Sets the current color
00414         *
00415         *  @param[in] cColor
00416         *    RGBA color
00417         */
00418         virtual void SetColor(const PLGraphics::Color4 &cColor = PLGraphics::Color4::White) = 0;
00419 
00420         //[-------------------------------------------------------]
00421         //[ Transform states                                      ]
00422         //[-------------------------------------------------------]
00423         /**
00424         *  @brief
00425         *    Resets all transform states to default (identity matrix)
00426         */
00427         virtual void ResetTransformStates() = 0;
00428 
00429         /**
00430         *  @brief
00431         *    Retrieves a transform-state value
00432         *
00433         *  @param[in] nState
00434         *    State variable that is being queried. This parameter can
00435         *    be any member of the transform enumerated type.
00436         *  @param[in] bOriginal
00437         *    Return the original set state? The returned transform state may differ from the given
00438         *    original state. OpenGL backend example: If a rectangle texture buffer is used the used
00439         *    transform matrix is scaled because in this case OpenGL requires not normalized texture
00440         *    coordinates. If you give this matrix to a shader program, don't use the original matrix! This has
00441         *    only an influence on the texture matrices, view etc. matrices are always original.
00442         *
00443         *  @return
00444         *    The requested matrix, on error the projection matrix is returned
00445         *
00446         *  @note
00447         *    - A transform state is a 4x4 matrix. Matrices are assumed to be stored in
00448         *      column major order like OpenGL does.
00449         */
00450         virtual const PLMath::Matrix4x4 &GetTransformState(Transform::Enum nState, bool bOriginal = true) const = 0;
00451 
00452         /**
00453         *  @brief
00454         *    Sets a single transform-state parameter
00455         *
00456         *  @param[in] nState
00457         *    State variable that is being modified. This parameter
00458         *    can be any member of the transform enumerated type.
00459         *  @param[in] mTrans
00460         *    New value for the transform state to be set
00461         *
00462         *  @return
00463         *    'true' if all went fine, else 'false'
00464         *
00465         *  @see
00466         *    - See GetTransformState()
00467         */
00468         virtual bool SetTransformState(Transform::Enum nState, const PLMath::Matrix3x4 &mTrans) = 0;
00469         virtual bool SetTransformState(Transform::Enum nState, const PLMath::Matrix4x4 &mTrans) = 0;
00470 
00471         //[-------------------------------------------------------]
00472         //[ Texture stage states                                  ]
00473         //[-------------------------------------------------------]
00474         /**
00475         *  @brief
00476         *    Returns a default texture stage state
00477         *
00478         *  @param[in] nState
00479         *    Texture stage state to return the default value from
00480         *
00481         *  @return
00482         *    The default state
00483         */
00484         virtual PLCore::uint32 GetDefaultTextureStageState(TextureStage::Enum nState) const = 0;
00485 
00486         /**
00487         *  @brief
00488         *    Resets all texture stage states to default
00489         *
00490         *  @see
00491         *    - GetDefaultTextureStageState()
00492         */
00493         virtual void ResetTextureStageStates() = 0;
00494 
00495         /**
00496         *  @brief
00497         *    Retrieves a texture stage state value
00498         *
00499         *  @param[in] nStage
00500         *    Texture stage to get the value from
00501         *  @param[in] nState
00502         *    State variable that is being queried. This parameter can
00503         *    be any member of the texture stage enumerated type.
00504         *
00505         *  @return
00506         *    The value of the queried texture stage state variable, < 0 on error
00507         *
00508         *  @see
00509         *    - GetDefaultTextureStageState()
00510         */
00511         virtual int GetTextureStageState(PLCore::uint32 nStage, TextureStage::Enum nState) const = 0;
00512 
00513         /**
00514         *  @brief
00515         *    Sets a single texture stage state parameter
00516         *
00517         *  @param[in] nStage
00518         *    Texture stage to set the value
00519         *  @param[in] nState
00520         *    State variable that is being modified. This parameter
00521         *    can be any member of the texture stage enumerated type.
00522         *  @param[in] nValue
00523         *    New value for the texture stage state to be set. The meaning of
00524         *    this parameter is dependent on the value specified for nState.
00525         *    For example, if nState is TextureStage::ColorTexEnv, the second parameter
00526         *    must be one member of the texture environment enumerated type. (e.g. TextureEnvironment::Modulate)
00527         *
00528         *  @return
00529         *    'true' if all went fine, else 'false'
00530         *
00531         *  @see
00532         *    - GetDefaultTextureStageState()
00533         */
00534         virtual bool SetTextureStageState(PLCore::uint32 nStage, TextureStage::Enum nState, PLCore::uint32 nValue) = 0;
00535 
00536         //[-------------------------------------------------------]
00537         //[ Material states                                       ]
00538         //[-------------------------------------------------------]
00539         /**
00540         *  @brief
00541         *    Returns a default material state
00542         *
00543         *  @param[in] nState
00544         *    Material state to return the default value from
00545         *
00546         *  @return
00547         *    The default state
00548         *
00549         *  @return
00550         *    The default state
00551         */
00552         virtual PLCore::uint32 GetDefaultMaterialState(MaterialState::Enum nState) const = 0;
00553 
00554         /**
00555         *  @brief
00556         *    Resets all material states to default
00557         *
00558         *  @see
00559         *    - GetDefaultMaterialState()
00560         */
00561         virtual void ResetMaterialStates() = 0;
00562 
00563         /**
00564         *  @brief
00565         *    Retrieves a material-state value
00566         *
00567         *  @param[in] nState
00568         *    State variable that is being queried. This parameter can
00569         *    be any member of the material enumerated type.
00570         *
00571         *  @return
00572         *    The value of the queried material state variable, < 0 on error
00573         *
00574         *  @see
00575         *    - GetDefaultMaterialState()
00576         */
00577         virtual int GetMaterialState(MaterialState::Enum nState) const = 0;
00578 
00579         /**
00580         *  @brief
00581         *    Sets a single material-state parameter
00582         *
00583         *  @param[in] nState
00584         *    State variable that is being modified. This parameter
00585         *    can be any member of the material enumerated type.
00586         *  @param[in] nValue
00587         *    New value for the material state to be set
00588         *
00589         *  @return
00590         *    'true' if all went fine, else 'false'
00591         *
00592         *  @see
00593         *    - GetDefaultMaterialState()
00594         */
00595         virtual bool SetMaterialState(MaterialState::Enum nState, PLCore::uint32 nValue) = 0;
00596 
00597         //[-------------------------------------------------------]
00598         //[ Light states                                          ]
00599         //[-------------------------------------------------------]
00600         /**
00601         *  @brief
00602         *    Gets the default light settings
00603         *
00604         *  @param[out] sLight
00605         *    Light structure which will receive the default settings
00606         */
00607         virtual void GetDefaultLightSettings(Light &sLight) const = 0;
00608 
00609         /**
00610         *  @brief
00611         *    Resets the lights
00612         *
00613         *  @see
00614         *    - GetDefaultLightSettings()
00615         */
00616         virtual void ResetLights() = 0;
00617 
00618         /**
00619         *  @brief
00620         *    Returns whether a light is enabled or not
00621         *
00622         *  @param[in] nLightID
00623         *    ID of the light
00624         *
00625         *  @return
00626         *    'true' if the light is enabled, else 'false'
00627         *
00628         *  @see
00629         *    - GetDefaultLightSettings()
00630         */
00631         virtual bool IsLightEnabled(PLCore::uint32 nLightID) const = 0;
00632 
00633         /**
00634         *  @brief
00635         *    Sets whether a light is enabled or not
00636         *
00637         *  @param[in] nLightID
00638         *    ID of the light
00639         *  @param[in] bEnabled
00640         *    Is this light enabled?
00641         *
00642         *  @return
00643         *    'true' if all went fine, else 'false'
00644         *
00645         *  @see
00646         *    - GetDefaultLightSettings()
00647         */
00648         virtual bool SetLightEnabled(PLCore::uint32 nLightID, bool bEnabled) = 0;
00649 
00650         /**
00651         *  @brief
00652         *    Returns light settings
00653         *
00654         *  @param[in]  nLightID
00655         *    ID of the light
00656         *  @param[out] sLight
00657         *    Will receive the light settings
00658         *
00659         *  @return
00660         *    'true' if all went fine, else 'false'
00661         *
00662         *  @see
00663         *    - GetDefaultLightSettings()
00664         */
00665         virtual bool GetLight(PLCore::uint32 nLightID, Light &sLight) const = 0;
00666 
00667         /**
00668         *  @brief
00669         *    Sets light settings
00670         *
00671         *  @param[in] nLightID
00672         *    ID of the light
00673         *  @param[in] sLight
00674         *    The light settings
00675         *
00676         *  @return
00677         *    'true' if all went fine, else 'false'
00678         *
00679         *  @see
00680         *    - GetDefaultLightSettings()
00681         */
00682         virtual bool SetLight(PLCore::uint32 nLightID, const Light &sLight) = 0;
00683 
00684         //[-------------------------------------------------------]
00685         //[ Clip plane states                                     ]
00686         //[-------------------------------------------------------]
00687         /**
00688         *  @brief
00689         *    Returns whether a clip plane is enabled/disabled
00690         *
00691         *  @param[in] nIndex
00692         *    Index (0 - Capabilities::nMaxClipPlanes-1) of the clip plane which should be checked
00693         *
00694         *  @return
00695         *    'true' if the requested clip plane is enabled, else 'false'
00696         *
00697         *  @note
00698         *    - A clip plane specifies a plane against which all geometry is clipped
00699         *    - By default, all clipping planes are defined as (0,0,0,0) in eye coordinates and are disabled
00700         *    - The coefficients which the clip plane methods take have the form of the general plane equation
00701         *    - Clip planes will only work in fix pass and often they are not well supported by hardware. So
00702         *      try to avoid using clip planes whenever you can!
00703         */
00704         virtual bool IsClipPlaneEnabled(PLCore::uint8 nIndex) const = 0;
00705 
00706         /**
00707         *  @brief
00708         *    Enables/disables a clip plane
00709         *
00710         *  @param[in] nIndex
00711         *    Index (0 - Capabilities::nMaxClipPlanes-1) of the clip plane which should be enabled/disabled,
00712         *    < 0 = Set all clip planes to this value
00713         *  @param[in] bEnable
00714         *    Should the defined clip clip plane be enabled?
00715         *
00716         *  @return
00717         *    'true' if all went fine, else 'false' (maybe invalid plane index)
00718         *
00719         *  @see
00720         *    - IsClipPlaneEnabled()
00721         */
00722         virtual bool SetClipPlaneEnabled(char nIndex = -1, bool bEnable = false) = 0;
00723 
00724         /**
00725         *  @brief
00726         *    Returns a clip plane
00727         *
00728         *  @param[in]  nIndex
00729         *    Index (0 - Capabilities::nMaxClipPlanes-1) of the clip plane which should be returned
00730         *  @param[out] fA
00731         *    Will receive the A coefficient of the requested clip plane
00732         *  @param[out] fB
00733         *    Will receive the B coefficient of the requested clip plane
00734         *  @param[out] fC
00735         *    Will receive the C coefficient of the requested clip plane
00736         *  @param[out] fD
00737         *    Will receive the D coefficient of the requested clip plane
00738         *
00739         *  @return
00740         *    'true' if all went fine, else 'false' (maybe invalid plane index)
00741         *
00742         *  @see
00743         *    - IsClipPlaneEnabled()
00744         */
00745         virtual bool GetClipPlane(PLCore::uint8 nIndex, float &fA, float &fB, float &fC, float &fD) const = 0;
00746 
00747         /**
00748         *  @brief
00749         *    Sets a clip plane
00750         *
00751         *  @param[in] nIndex
00752         *    Index (0 - Capabilities::nMaxClipPlanes-1) of the clip plane which should be returned
00753         *    < 0 = Set all clip planes to this value
00754         *  @param[in] fA
00755         *    The new A coefficient of the given clip plane
00756         *  @param[in] fB
00757         *    The new B coefficient of the given clip plane
00758         *  @param[in] fC
00759         *    The new C coefficient of the given clip plane
00760         *  @param[in] fD
00761         *    The new D coefficient of the given clip plane
00762         *
00763         *  @return
00764         *    'true' if all went fine, else 'false' (maybe invalid plane index)
00765         *
00766         *  @see
00767         *    - IsClipPlaneEnabled()
00768         */
00769         virtual bool SetClipPlane(char nIndex = -1, float fA = 0.0f, float fB = 0.0f, float fC = 0.0f, float fD = 0.0f) = 0;
00770 
00771         //[-------------------------------------------------------]
00772         //[ Vertex buffer states                                  ]
00773         //[-------------------------------------------------------]
00774         /**
00775         *  @brief
00776         *    Gets the current vertex buffer
00777         *
00778         *  @param[in]  nStreamNumber
00779         *    Specifies the data stream number (0 - Capabilities::nMaxVertexBufferStreams()-1)
00780         *  @param[out] pnOffset
00781         *    If not a null pointer, this variable will receive the vertex offset in bytes
00782         *
00783         *  @return
00784         *    The current vertex buffer, a null pointer if there's no one
00785         *
00786         *  @note
00787         *    - By assigning different vertex buffers to different stream numbers its for instance possible
00788         *      to get the vertex positions from vertex buffer 0, the vertex normals from vertex buffer 1
00789         *      and so on.
00790         *    - Try to avoid conflicts in which different vertex buffers want to provide for instance the
00791         *      vertex positions!
00792         *    - For better performance, try to avoid using more than one vertex buffer at the same time
00793         *      whenever possible.
00794         */
00795         virtual VertexBuffer *GetVertexBuffer(PLCore::uint32 nStreamNumber = 0, PLCore::uint32 *pnOffset = nullptr) const = 0;
00796 
00797         /**
00798         *  @brief
00799         *   Sets the current vertex buffer
00800         *
00801         *  @param[in] pVertexBuffer
00802         *    The vertex buffer which should be set, a null pointer if no vertex buffer should be set
00803         *  @param[in] nOffset
00804         *    Vertex offset (vertex index, NOT in bytes!)
00805         *  @param[in] nStreamNumber
00806         *    Specifies the data stream number (0 - Capabilities::nMaxVertexBufferStreams()-1)
00807         *
00808         *  @return
00809         *    'true' if all went fine, else 'false' (maybe this is already the current vertex buffer)
00810         *
00811         *  @note
00812         *    - If nStreamNumber is 0 and pVertexBuffer is a null pointer no vertex buffer at any stream number is set
00813         *    - If the first stream (the base stream) is set all other stream settings are cleared
00814         *    - See GetVertexBuffer()
00815         */
00816         virtual bool SetVertexBuffer(VertexBuffer *pVertexBuffer = nullptr, PLCore::uint32 nOffset = 0, PLCore::uint32 nStreamNumber = 0) = 0;
00817 
00818 
00819     //[-------------------------------------------------------]
00820     //[ Protected functions                                   ]
00821     //[-------------------------------------------------------]
00822     protected:
00823         /**
00824         *  @brief
00825         *    Constructor
00826         */
00827         PLRENDERER_API FixedFunctions();
00828 
00829         /**
00830         *  @brief
00831         *    Destructor
00832         */
00833         PLRENDERER_API virtual ~FixedFunctions();
00834 
00835 
00836     //[-------------------------------------------------------]
00837     //[ Private functions                                     ]
00838     //[-------------------------------------------------------]
00839     private:
00840         /**
00841         *  @brief
00842         *    Copy constructor
00843         *
00844         *  @param[in] cSource
00845         *    Source to copy from
00846         */
00847         FixedFunctions(const FixedFunctions &cSource);
00848 
00849         /**
00850         *  @brief
00851         *    Copy operator
00852         *
00853         *  @param[in] cSource
00854         *    Source to copy from
00855         *
00856         *  @return
00857         *    Reference to this instance
00858         */
00859         FixedFunctions &operator =(const FixedFunctions &cSource);
00860 
00861 
00862 };
00863 
00864 
00865 //[-------------------------------------------------------]
00866 //[ Namespace                                             ]
00867 //[-------------------------------------------------------]
00868 } // PLRenderer
00869 
00870 
00871 #endif // __PLRENDERER_FIXEDFUNCTIONS_H__


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