PixelLightAPI  .
ProgramUniform.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ProgramUniform.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_PROGRAMUNIFORM_H__
00024 #define __PLRENDERER_PROGRAMUNIFORM_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLRenderer/PLRenderer.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Forward declarations                                  ]
00036 //[-------------------------------------------------------]
00037 namespace PLMath {
00038     class Vector2;
00039     class Vector2i;
00040     class Vector3;
00041     class Vector3i;
00042     class Vector4;
00043     class Matrix3x3;
00044     class Matrix3x4;
00045     class Matrix4x4;
00046     class Quaternion;
00047 }
00048 namespace PLGraphics {
00049     class Color3;
00050     class Color4;
00051 }
00052 namespace PLRenderer {
00053     class TextureBuffer;
00054 }
00055 
00056 
00057 //[-------------------------------------------------------]
00058 //[ Namespace                                             ]
00059 //[-------------------------------------------------------]
00060 namespace PLRenderer {
00061 
00062 
00063 //[-------------------------------------------------------]
00064 //[ Classes                                               ]
00065 //[-------------------------------------------------------]
00066 /**
00067 *  @brief
00068 *    Abstract renderer program uniform
00069 *
00070 *  @remarks
00071 *    An uniform is a program parameter which stays the same for all elements processed within the shader pipeline.
00072 *    Whether or not parameter shadowing is used, depends on the internal shader API. GLSL and Cg perform parameter
00073 *    shadowing. Shadowing means that the uniform will keep it's value when another program is set and still has
00074 *    the same value when the program of the uniform is set again as the currently one used for rendering.
00075 *
00076 *    Please note that the internal shader API like GLSL or Cg may handle uniforms differently. When using Cg it's
00077 *    possible to set the uniform value at each time, even when the program the uniform is part of is currently
00078 *    not the used renderer program. When using GLSL, it's only possible to access the value of an uniform when
00079 *    the program, the uniform is part of, is the currently used for rendering. For performance reasons, this
00080 *    abstract program uniform interface can't compensate those differences. It has to be as lightweight as possible
00081 *    in order to keep the interface performance impact as low as possible.
00082 *
00083 *    In order to be as internal shader API independent as possible, it's highly recommended to access program
00084 *    uniforms only when the program, the uniform is part of, is currently used for rendering.
00085 *
00086 *  @note
00087 *    - The value of an uniform is directly coupled to a certain program
00088 *    - Do only access uniform values when the program, the uniform is part of, is currently used for rendering
00089 */
00090 class ProgramUniform {
00091 
00092 
00093     //[-------------------------------------------------------]
00094     //[ Public virtual ProgramUniform functions               ]
00095     //[-------------------------------------------------------]
00096     public:
00097         //[-------------------------------------------------------]
00098         //[ 1 component                                           ]
00099         //[-------------------------------------------------------]
00100         virtual void Get(int &nX) = 0;
00101         virtual void Get(float &fX) = 0;
00102         virtual void Get(double &fX) = 0;
00103         virtual void Set(int nX) = 0;
00104         virtual void Set(float fX) = 0;
00105         virtual void Set(double fX) = 0;
00106 
00107 
00108         //[-------------------------------------------------------]
00109         //[ 2 components                                          ]
00110         //[-------------------------------------------------------]
00111         virtual void Get(int &nX, int &nY) = 0;
00112         virtual void Get(float &fX, float &fY) = 0;
00113         virtual void Get(double &fX, double &fY) = 0;
00114         virtual void Get(PLMath::Vector2i &vVector) = 0;
00115         virtual void Get(PLMath::Vector2 &vVector) = 0;
00116         virtual void Get2(int *pnComponents) = 0;
00117         virtual void Get2(float *pfComponents) = 0;
00118         virtual void Get2(double *pfComponents) = 0;
00119         virtual void Set(int nX, int nY) = 0;
00120         virtual void Set(float fX, float fY) = 0;
00121         virtual void Set(double fX, double fY) = 0;
00122         virtual void Set(const PLMath::Vector2i &vVector) = 0;
00123         virtual void Set(const PLMath::Vector2 &vVector) = 0;
00124         virtual void Set2(const int *pnComponents) = 0;
00125         virtual void Set2(const float *pfComponents) = 0;
00126         virtual void Set2(const double *pfComponents) = 0;
00127 
00128 
00129         //[-------------------------------------------------------]
00130         //[ 3 components                                          ]
00131         //[-------------------------------------------------------]
00132         virtual void Get(int &nX, int &nY, int &nZ) = 0;
00133         virtual void Get(float &fX, float &fY, float &fZ) = 0;
00134         virtual void Get(double &fX, double &fY, double &fZ) = 0;
00135         virtual void Get(PLMath::Vector3i &vVector) = 0;
00136         virtual void Get(PLMath::Vector3 &vVector) = 0;
00137         virtual void Get(PLGraphics::Color3 &cColor) = 0;   // Floating point
00138         virtual void Get3(int *pnComponents) = 0;
00139         virtual void Get3(float *pfComponents) = 0;
00140         virtual void Get3(double *pfComponents) = 0;
00141         virtual void Set(int nX, int nY, int nZ) = 0;
00142         virtual void Set(float fX, float fY, float fZ) = 0;
00143         virtual void Set(double fX, double fY, double fZ) = 0;
00144         virtual void Set(const PLMath::Vector3i &vVector) = 0;
00145         virtual void Set(const PLMath::Vector3 &vVector) = 0;
00146         virtual void Set(const PLGraphics::Color3 &cColor) = 0; // Floating point
00147         virtual void Set3(const int *pnComponents) = 0;
00148         virtual void Set3(const float *pfComponents) = 0;
00149         virtual void Set3(const double *pfComponents) = 0;
00150 
00151 
00152         //[-------------------------------------------------------]
00153         //[ 4 components                                          ]
00154         //[-------------------------------------------------------]
00155         virtual void Get(int &nX, int &nY, int &nZ, int &nW) = 0;
00156         virtual void Get(float &fX, float &fY, float &fZ, float &fW) = 0;
00157         virtual void Get(double &fX, double &fY, double &fZ, double &fW) = 0;
00158         virtual void Get(PLMath::Vector4 &vVector) = 0;
00159         virtual void Get(PLGraphics::Color4 &cColor) = 0;   // Floating point
00160         virtual void Get(PLMath::Quaternion &qQuaternion) = 0;
00161         virtual void Get4(int *pnComponents) = 0;
00162         virtual void Get4(float *pfComponents) = 0;
00163         virtual void Get4(double *pfComponents) = 0;
00164         virtual void Set(int nX, int nY, int nZ, int nW) = 0;
00165         virtual void Set(float fX, float fY, float fZ, float fW) = 0;
00166         virtual void Set(double fX, double fY, double fZ, double fW) = 0;
00167         virtual void Set(const PLMath::Vector4 &vVector) = 0;
00168         virtual void Set(const PLGraphics::Color4 &cColor) = 0; // Floating point
00169         virtual void Set(const PLMath::Quaternion &qQuaternion) = 0;
00170         virtual void Set4(const int *pnComponents) = 0;
00171         virtual void Set4(const float *pfComponents) = 0;
00172         virtual void Set4(const double *pfComponents) = 0;
00173 
00174 
00175         //[-------------------------------------------------------]
00176         //[ Matrix                                                ]
00177         //[-------------------------------------------------------]
00178         virtual void Get(PLMath::Matrix3x3 &mMatrix) = 0;
00179         virtual void Get(PLMath::Matrix4x4 &mMatrix) = 0;
00180         virtual void Set(const PLMath::Matrix3x3 &mMatrix, bool bTranspose = false) = 0;
00181         virtual void Set(const PLMath::Matrix4x4 &mMatrix, bool bTranspose = false) = 0;
00182 
00183 
00184         //[-------------------------------------------------------]
00185         //[ Texture                                               ]
00186         //[-------------------------------------------------------]
00187         /**
00188         *  @brief
00189         *    If this uniform is a texture, this method will return the texture unit assigned to this uniform
00190         *
00191         *  @return
00192         *    The texture unit assigned to this uniform, negative on error
00193         */
00194         virtual int GetTextureUnit() const = 0;
00195 
00196         /**
00197         *  @brief
00198         *    If this uniform is a texture, this method sets the texture buffer assigned to the uniform
00199         *
00200         *  @return
00201         *    The texture unit assigned to this uniform (same as GetTextureUnit()), negative on error
00202         */
00203         virtual int Set(TextureBuffer *pTextureBuffer) = 0;
00204 
00205 
00206     //[-------------------------------------------------------]
00207     //[ Protected functions                                   ]
00208     //[-------------------------------------------------------]
00209     protected:
00210         /**
00211         *  @brief
00212         *    Constructor
00213         */
00214         PLRENDERER_API ProgramUniform();
00215 
00216         /**
00217         *  @brief
00218         *    Destructor
00219         */
00220         PLRENDERER_API virtual ~ProgramUniform();
00221 
00222 
00223     //[-------------------------------------------------------]
00224     //[ Private functions                                     ]
00225     //[-------------------------------------------------------]
00226     private:
00227         /**
00228         *  @brief
00229         *    Copy constructor
00230         *
00231         *  @param[in] cSource
00232         *    Source to copy from
00233         */
00234         ProgramUniform(const ProgramUniform &cSource);
00235 
00236         /**
00237         *  @brief
00238         *    Copy operator
00239         *
00240         *  @param[in] cSource
00241         *    Source to copy from
00242         *
00243         *  @return
00244         *    Reference to this instance
00245         */
00246         ProgramUniform &operator =(const ProgramUniform &cSource);
00247 
00248 
00249 };
00250 
00251 
00252 //[-------------------------------------------------------]
00253 //[ Namespace                                             ]
00254 //[-------------------------------------------------------]
00255 } // PLRenderer
00256 
00257 
00258 #endif // __PLRENDERER_PROGRAMUNIFORM_H__


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