PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: EffectPass.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_EFFECT_PASS_H__ 00024 #define __PLRENDERER_EFFECT_PASS_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLRenderer/Renderer/FixedFunctions.h" 00032 #include "PLRenderer/Renderer/RenderStates.h" 00033 #include "PLRenderer/Renderer/FixedFunctionsRenderStates.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Namespace ] 00038 //[-------------------------------------------------------] 00039 namespace PLRenderer { 00040 00041 00042 //[-------------------------------------------------------] 00043 //[ Forward declarations ] 00044 //[-------------------------------------------------------] 00045 class Program; 00046 class VertexShader; 00047 class FragmentShader; 00048 class EffectPassLayer; 00049 class EffectTechnique; 00050 class ParameterManager; 00051 00052 00053 //[-------------------------------------------------------] 00054 //[ Classes ] 00055 //[-------------------------------------------------------] 00056 /** 00057 * @brief 00058 * A effect pass will set the render states, textures etc. 00059 * required for proper rendering of the given pass. 00060 */ 00061 class EffectPass { 00062 00063 00064 //[-------------------------------------------------------] 00065 //[ Friends ] 00066 //[-------------------------------------------------------] 00067 friend class EffectTechnique; 00068 00069 00070 //[-------------------------------------------------------] 00071 //[ Public functions ] 00072 //[-------------------------------------------------------] 00073 public: 00074 /** 00075 * @brief 00076 * Returns the owner effect technique 00077 * 00078 * @return 00079 * Owner effect technique 00080 */ 00081 inline EffectTechnique &GetTechnique() const; 00082 00083 /** 00084 * @brief 00085 * Returns the pass name 00086 * 00087 * @return 00088 * Pass name 00089 */ 00090 inline PLCore::String GetName() const; 00091 00092 /** 00093 * @brief 00094 * Sets the pass name 00095 * 00096 * @param[in] sName 00097 * New pass name 00098 */ 00099 inline void SetName(const PLCore::String &sName = "Pass"); 00100 00101 /** 00102 * @brief 00103 * Binds the pass 00104 * 00105 * @param[in] pParameterManager 00106 * Parameters set instead of existing effect parameters, can be a null pointer 00107 * 00108 * @return 00109 * 'true' if all went fine, else 'false' 00110 */ 00111 PLRENDERER_API bool Bind(ParameterManager *pParameterManager = nullptr); 00112 00113 /** 00114 * @brief 00115 * Copy operator 00116 * 00117 * @param[in] cSource 00118 * Source to copy from 00119 * 00120 * @return 00121 * This instance 00122 */ 00123 PLRENDERER_API EffectPass &operator =(const EffectPass &cSource); 00124 00125 //[-------------------------------------------------------] 00126 //[ States ] 00127 //[-------------------------------------------------------] 00128 /** 00129 * @brief 00130 * Returns the general color 00131 * 00132 * @return 00133 * General color 00134 */ 00135 inline const PLGraphics::Color4 &GetColor() const; 00136 00137 /** 00138 * @brief 00139 * Sets the general color 00140 * 00141 * @param[in] cColor 00142 * New general color 00143 */ 00144 inline void SetColor(const PLGraphics::Color4 &cColor = PLGraphics::Color4::White); 00145 00146 /** 00147 * @brief 00148 * Returns the render states 00149 * 00150 * @return 00151 * The render states 00152 */ 00153 inline RenderStates &GetRenderStates(); 00154 inline const RenderStates &GetRenderStates() const; 00155 00156 /** 00157 * @brief 00158 * Returns the fixed functions render states 00159 * 00160 * @return 00161 * The fixed functions render states 00162 */ 00163 inline FixedFunctionsRenderStates &GetFixedFunctionsRenderStates(); 00164 inline const FixedFunctionsRenderStates &GetFixedFunctionsRenderStates() const; 00165 00166 /** 00167 * @brief 00168 * Resets all material states to default 00169 */ 00170 PLRENDERER_API void ResetMaterialStates(); 00171 00172 /** 00173 * @brief 00174 * Retrieves a material-state value 00175 * 00176 * @param[in] nState 00177 * State variable that is being queried. This parameter can 00178 * be any member of the renderer material enumerated type. 00179 * 00180 * @return 00181 * The value of the queried material state variable 00182 */ 00183 inline PLCore::uint32 GetMaterialState(FixedFunctions::MaterialState::Enum nState) const; 00184 00185 /** 00186 * @brief 00187 * Sets a single material-state parameter 00188 * 00189 * @param[in] nState 00190 * State variable that is being modified. This parameter 00191 * can be any member of the renderer material enumerated type. 00192 * @param[in] nValue 00193 * New value for the material state to be set. 00194 * You can also set the value to unknown - then this state is ignored. 00195 * 00196 * @return 00197 * 'true' if all went fine, else 'false' 00198 */ 00199 inline bool SetMaterialState(FixedFunctions::MaterialState::Enum nState, PLCore::uint32 nValue); 00200 00201 //[-------------------------------------------------------] 00202 //[ Layers ] 00203 //[-------------------------------------------------------] 00204 /** 00205 * @brief 00206 * Returns the number of texture layers 00207 * 00208 * @return 00209 * Number of texture layers 00210 */ 00211 inline PLCore::uint32 GetNumOfLayers() const; 00212 00213 /** 00214 * @brief 00215 * Adds a new layer 00216 * 00217 * @return 00218 * The new effect pass layer, a null pointer on error 00219 */ 00220 PLRENDERER_API EffectPassLayer *AddLayer(); 00221 00222 /** 00223 * @brief 00224 * Returns a layer 00225 * 00226 * @param[in] nIndex 00227 * Layer index 00228 * 00229 * @return 00230 * Effect pass layer, a null pointer if there was an error 00231 */ 00232 inline EffectPassLayer *GetLayer(PLCore::uint32 nIndex = 0) const; 00233 00234 /** 00235 * @brief 00236 * Removes a layer 00237 * 00238 * @param[in] nIndex 00239 * Index of the layer to remove 00240 * 00241 * @return 00242 * 'true' if all went fine, else 'false' 00243 */ 00244 PLRENDERER_API bool RemoveLayer(PLCore::uint32 nIndex = 0); 00245 00246 /** 00247 * @brief 00248 * Removes all layers 00249 */ 00250 PLRENDERER_API void RemoveAllLayers(); 00251 00252 //[-------------------------------------------------------] 00253 //[ Shaders ] 00254 //[-------------------------------------------------------] 00255 /** 00256 * @brief 00257 * Loads a vertex shader 00258 * 00259 * @param[in] sFilename 00260 * Shader filename 00261 * @param[in] sShaderLanguage 00262 * Shader language to use (for example "GLSL" or "Cg") 00263 * @param[in] sProfile 00264 * Profile that should be used (e.g. "arbvp1") 00265 * 00266 * @return 00267 * 'true' if all went fine, else 'false' 00268 */ 00269 PLRENDERER_API bool LoadVertexShader(const PLCore::String &sFilename, const PLCore::String &sShaderLanguage, const PLCore::String &sProfile = ""); 00270 00271 /** 00272 * @brief 00273 * Loads a fragment shader 00274 * 00275 * @param[in] sFilename 00276 * Shader filename 00277 * @param[in] sShaderLanguage 00278 * Shader language to use (for example "GLSL" or "Cg") 00279 * @param[in] sProfile 00280 * Profile that should be used (e.g. "arbfp1") 00281 * 00282 * @return 00283 * 'true' if all went fine, else 'false' 00284 */ 00285 PLRENDERER_API bool LoadFragmentShader(const PLCore::String &sFilename, const PLCore::String &sShaderLanguage, const PLCore::String &sProfile = ""); 00286 00287 /** 00288 * @brief 00289 * Returns the used GPU program 00290 * 00291 * @return 00292 * The used GPU program, a null pointer if there's no such GPU program 00293 */ 00294 PLRENDERER_API Program *GetProgram(); 00295 00296 00297 //[-------------------------------------------------------] 00298 //[ Private functions ] 00299 //[-------------------------------------------------------] 00300 private: 00301 /** 00302 * @brief 00303 * Constructor 00304 * 00305 * @param[in] cTechnique 00306 * Owner effect technique 00307 */ 00308 EffectPass(EffectTechnique &cTechnique); 00309 00310 /** 00311 * @brief 00312 * Destructor 00313 */ 00314 ~EffectPass(); 00315 00316 00317 //[-------------------------------------------------------] 00318 //[ Private data ] 00319 //[-------------------------------------------------------] 00320 private: 00321 EffectTechnique *m_pTechnique; /**< Owner effect technique (always valid!) */ 00322 PLCore::String m_sName; /**< Pass name */ 00323 // States 00324 PLGraphics::Color4 m_cColor; /**< General color */ 00325 RenderStates m_cRenderStates; /**< Render states */ 00326 FixedFunctionsRenderStates m_cFixedFunctionsRenderStates; /**< Fixed functions render states */ 00327 PLCore::uint32 m_nMaterialState[FixedFunctions::MaterialState::Number]; /**< List of material states (see 'Material') */ 00328 // Layers 00329 PLCore::Array<EffectPassLayer*> m_lstLayers; /**< Texture layers */ 00330 // Shaders 00331 VertexShader *m_pVertexShader; /**< Used vertex shader, can be a null pointer */ 00332 FragmentShader *m_pFragmentShader; /**< Used fragment shader, can be a null pointer */ 00333 Program *m_pProgram; /**< GPU program, can be a null pointer */ 00334 00335 00336 }; 00337 00338 00339 //[-------------------------------------------------------] 00340 //[ Namespace ] 00341 //[-------------------------------------------------------] 00342 } // PLRenderer 00343 00344 00345 //[-------------------------------------------------------] 00346 //[ Implementation ] 00347 //[-------------------------------------------------------] 00348 #include "PLRenderer/Effect/EffectPass.inl" 00349 00350 00351 #endif // __PLRENDERER_EFFECT_PASS_H__
|