PixelLightAPI  .
Parameter.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Parameter.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_MATERIAL_PARAMETER_H__
00024 #define __PLRENDERER_MATERIAL_PARAMETER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLRenderer/Renderer/Parameters.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLRenderer {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Forward declarations                                  ]
00042 //[-------------------------------------------------------]
00043 class Texture;
00044 class Program;
00045 class TextureHandler;
00046 class ParameterManager;
00047 
00048 
00049 //[-------------------------------------------------------]
00050 //[ Classes                                               ]
00051 //[-------------------------------------------------------]
00052 /**
00053 *  @brief
00054 *    Parameters are used for material/effect parameters
00055 *
00056 *  @note
00057 *    - You can only use the functions of the given parameter type!
00058 */
00059 class Parameter {
00060 
00061 
00062     //[-------------------------------------------------------]
00063     //[ Friends                                               ]
00064     //[-------------------------------------------------------]
00065     friend class ParameterManager;
00066 
00067 
00068     //[-------------------------------------------------------]
00069     //[ Public functions                                      ]
00070     //[-------------------------------------------------------]
00071     public:
00072         /**
00073         *  @brief
00074         *    Returns the parameter manager this parameter is in
00075         *
00076         *  @return
00077         *    The parameter manager this parameter is in
00078         */
00079         inline ParameterManager &GetManager() const;
00080 
00081         /**
00082         *  @brief
00083         *    Sets the value of this parameter to a parameter within the given manager
00084         *
00085         *  @param[in] cManager
00086         *    Parameter manager to use
00087         *  @param[in] sName
00088         *    Name of the parameter within the given manager
00089         * 
00090         *  @return
00091         *    'true' if all went fine, else 'false' (maybe incompatible parameter types?)
00092         */
00093         PLRENDERER_API bool SetManagerParameterValue(Parameters &cManager, const PLCore::String &sName) const;
00094 
00095         /**
00096         *  @brief
00097         *    Sets the value of this parameter to a parameter within the given GPU program
00098         *
00099         *  @param[in] cProgram
00100         *    GPU program to use
00101         *  @param[in] sName
00102         *    Name of the parameter within the given manager
00103         * 
00104         *  @return
00105         *    'true' if all went fine, else 'false' (maybe incompatible parameter types?)
00106         */
00107         PLRENDERER_API bool SetManagerParameterValue(Program &cProgram, const PLCore::String &sName) const;
00108 
00109         /**
00110         *  @brief
00111         *    Get the parameter type
00112         *
00113         *  @return
00114         *    Parameter type, NEVER Parameters::UnknownDataType!
00115         */
00116         inline Parameters::EDataType GetType() const;
00117 
00118         /**
00119         *  @brief
00120         *    Get the parameter name
00121         *
00122         *  @return
00123         *    Parameter name
00124         */
00125         inline PLCore::String GetName() const;
00126 
00127         /**
00128         *  @brief
00129         *    Set the parameter name
00130         *
00131         *  @param[in] sName
00132         *    New parameter name
00133         *
00134         *  @return
00135         *    'true' if all went fine and the parameter name was changed, else 'false'
00136         *    (maybe the given name is empty or there's already a parameter with this name
00137         *    within the parameter manager this parameter is in)
00138         */
00139         PLRENDERER_API bool SetName(const PLCore::String &sName);
00140 
00141         //[-------------------------------------------------------]
00142         //[ Get/set value                                         ]
00143         //[-------------------------------------------------------]
00144         /**
00145         *  @brief
00146         *    Returns a parameter value as string (e.g. "1.0 5.4 0.21")
00147         *
00148         *  @return
00149         *    The value of the parameter as string, empty string on error
00150         *
00151         *  @note
00152         *    - Not that performant, try to avoid using this multiple times within each frame
00153         */
00154         PLRENDERER_API PLCore::String GetParameterString() const;
00155 
00156         /**
00157         *  @brief
00158         *    Sets a parameter value from a string (e.g. "1.0 5.4 0.21")
00159         *
00160         *  param[in] sValue
00161         *    New parameter value
00162         *
00163         *  @return
00164         *    'true' if all went fine, else 'false' (maybe unknown parameter)
00165         *
00166         *  @see
00167         *    - GetParameterString()
00168         */
00169         PLRENDERER_API bool SetParameterString(const PLCore::String &sValue);
00170 
00171         // Integer
00172         inline bool GetValue1i(int &nX) const;
00173         inline int GetValue1i() const;
00174         PLRENDERER_API bool SetValue1i(int nX);
00175 
00176         // Integer2
00177         inline bool GetValue2i(int &nX, int &nY) const;
00178         inline const int *GetValue2iv() const;
00179         PLRENDERER_API bool SetValue2i(int nX, int nY);
00180         PLRENDERER_API bool SetValue2iv(const int nValue[]);
00181 
00182         // Integer3
00183         inline bool GetValue3i(int &nX, int &nY, int &nZ) const;
00184         inline const int *GetValue3iv() const;
00185         PLRENDERER_API bool SetValue3i(int nX, int nY, int nZ);
00186         PLRENDERER_API bool SetValue3iv(const int nValue[]);
00187 
00188         // Integer4
00189         inline bool GetValue4i(int &nX, int &nY, int &nZ, int &nW) const;
00190         inline const int *GetValue4iv() const;
00191         PLRENDERER_API bool SetValue4i(int nX, int nY, int nZ, int nW);
00192         PLRENDERER_API bool SetValue4iv(const int nValue[]);
00193 
00194         // Float
00195         inline bool GetValue1f(float &fX) const;
00196         inline float GetValue1f() const;
00197         PLRENDERER_API bool SetValue1f(float fX);
00198 
00199         // Float2
00200         inline bool GetValue2f(float &fX, float &fY) const;
00201         inline const float *GetValue2fv() const;
00202         PLRENDERER_API bool SetValue2f(float fX, float fY);
00203         PLRENDERER_API bool SetValue2fv(const float fValue[]);
00204 
00205         // Float3
00206         inline bool GetValue3f(float &fX, float &fY, float &fZ) const;
00207         inline const float *GetValue3fv() const;
00208         PLRENDERER_API bool SetValue3f(float fX, float fY, float fZ);
00209         PLRENDERER_API bool SetValue3fv(const float fValue[]);
00210 
00211         // Float4
00212         inline bool GetValue4f(float &fX, float &fY, float &fZ, float &fW) const;
00213         inline const float *GetValue4fv() const;
00214         PLRENDERER_API bool SetValue4f(float fX, float fY, float fZ, float fW);
00215         PLRENDERER_API bool SetValue4fv(const float fValue[]);
00216 
00217         // Double
00218         inline bool GetValue1d(double &fW) const;
00219         PLRENDERER_API bool SetValue1d(double fW);
00220 
00221         // Double2
00222         inline bool GetValue2d(double &fX, double &fY) const;
00223         inline const double *GetValue2dv() const;
00224         PLRENDERER_API bool SetValue2d(double fX, double fY);
00225         PLRENDERER_API bool SetValue2dv(const double fValue[]);
00226 
00227         // Double3
00228         inline bool GetValue3d(double &fX, double &fY, double &fZ) const;
00229         inline const double *GetValue3dv() const;
00230         PLRENDERER_API bool SetValue3d(double fX, double fY, double fZ);
00231         PLRENDERER_API bool SetValue3dv(const double fValue[]);
00232 
00233         // Double4
00234         inline bool GetValue4d(double &fX, double &fY, double &fZ, double &fW) const;
00235         inline const double *GetValue4dv() const;
00236         PLRENDERER_API bool SetValue4d(double fX, double fY, double fZ, double fW);
00237         PLRENDERER_API bool SetValue4dv(const double fValue[]);
00238 
00239         // Float3x3
00240         inline const float *GetValueFloat3x3() const;
00241         PLRENDERER_API bool SetValueFloat3x3(const float fValue[]);
00242 
00243         // Float3x4
00244         inline const float *GetValueFloat3x4() const;
00245         PLRENDERER_API bool SetValueFloat3x4(const float fValue[]);
00246 
00247         // Float4x4
00248         inline const float *GetValueMatrixfv() const;
00249         PLRENDERER_API bool SetValueMatrixfv(const float fValue[]);
00250 
00251         // Double4x4
00252         inline const double *GetValueMatrixdv() const;
00253         PLRENDERER_API bool SetValueMatrixdv(const double fValue[]);
00254 
00255         // Texture
00256         PLRENDERER_API Texture *GetValueTexture() const;
00257         PLRENDERER_API TextureBuffer *GetValueTextureBuffer() const;
00258         inline TextureHandler *GetValueTextureHandler() const;
00259         PLRENDERER_API bool SetValueTexture(Texture *pTexture);
00260         PLRENDERER_API bool SetValueTexture(const PLCore::String &sFilename);
00261 
00262 
00263     //[-------------------------------------------------------]
00264     //[ Private functions                                     ]
00265     //[-------------------------------------------------------]
00266     private:
00267         /**
00268         *  @brief
00269         *    Constructor
00270         *
00271         *  @param[in] cManager
00272         *    The parameter manager this parameter is in
00273         *  @param[in] nType
00274         *    Type of the parameter, NEVER Parameters::UnknownDataType!
00275         *  @param[in] sName
00276         *    Name of the parameter
00277         */
00278         Parameter(ParameterManager &cManager, Parameters::EDataType nType, const PLCore::String &sName);
00279 
00280         /**
00281         *  @brief
00282         *    Destructor
00283         */
00284         ~Parameter();
00285 
00286 
00287     //[-------------------------------------------------------]
00288     //[ Private data                                          ]
00289     //[-------------------------------------------------------]
00290     private:
00291         ParameterManager      *m_pManager;  /**< The parameter manager this parameter is in (NEVER a null pointer!) */
00292         Parameters::EDataType  m_nType;     /**< Parameter type */
00293         PLCore::String         m_sName;     /**< Parameter name */
00294         void                  *m_pValue;    /**< Parameter value, can be a null pointer */
00295 
00296 
00297 };
00298 
00299 
00300 //[-------------------------------------------------------]
00301 //[ Namespace                                             ]
00302 //[-------------------------------------------------------]
00303 } // PLRenderer
00304 
00305 
00306 //[-------------------------------------------------------]
00307 //[ Implementation                                        ]
00308 //[-------------------------------------------------------]
00309 #include "PLRenderer/Material/Parameter.inl"
00310 
00311 
00312 #endif // __PLRENDERER_MATERIAL_PARAMETER_H__


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