OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderRenderState.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 #ifndef _ShaderRenderState_
28 #define _ShaderRenderState_
29 
32 #include "OgreSharedPtr.h"
33 
34 namespace Ogre {
35 namespace RTShader {
36 
51 {
52 
53  // Interface.
54 public:
55 
57  RenderState();
58 
60  virtual ~RenderState();
61 
63  void reset();
64 
68  void addTemplateSubRenderState(SubRenderState* subRenderState);
69 
73  void removeTemplateSubRenderState(SubRenderState* subRenderState);
74 
76  const SubRenderStateList& getTemplateSubRenderStateList() const { return mSubRenderStateList; }
77 
86  void setLightCount(const int lightCount[3]);
87 
96  void getLightCount(int lightCount[3]) const;
97 
104  void setLightCountAutoUpdate(bool autoUpdate) { mLightCountAutoUpdate = autoUpdate; }
105 
110  bool getLightCountAutoUpdate() const { return mLightCountAutoUpdate; }
111 
112 
113 
114 
115  // Attributes.
116 protected:
117  // The sub render states list.
119  // The light count per light type definition.
120  int mLightCount[3];
121  // True if light count was explicitly set.
123 
124 private:
125  friend class ProgramManager;
126  friend class FFPRenderStateBuilder;
127 };
128 
129 
131 typedef RenderStateList::iterator RenderStateIterator;
132 typedef RenderStateList::const_iterator RenderStateConstIterator;
133 
134 
140 {
141 
142 // Interface.
143 public:
144 
147 
149  virtual ~TargetRenderState();
150 
157  void link(const RenderState& other, Pass* srcPass, Pass* dstPass);
158 
165  void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList);
166 
167 // Protected methods
168 protected:
169 
171  void sortSubRenderStates();
172 
174  static int sSubRenderStateCompare(const void * p0, const void *p1);
175 
176 
179  bool createCpuPrograms();
180 
184 
185  /* Destroy the program set of this render state. */
186  void destroyProgramSet();
187 
191 
195  void addSubRenderStateInstance(SubRenderState* subRenderState);
196 
200  void removeSubRenderStateInstance(SubRenderState* subRenderState);
201 
202 
203 // Attributes.
204 protected:
205  // Tells if the list of the sub render states is sorted.
207  // The program set of this RenderState.
209 
210 
211 private:
212  friend class ProgramManager;
213  friend class FFPRenderStateBuilder;
214 };
215 
216 
220 }
221 }
222 
223 #endif
224 
TargetRenderState()
Class default constructor.
vector< RenderState * >::type RenderStateList
ProgramSet * createProgramSet()
Create the program set of this render state.
virtual ~TargetRenderState()
Class destructor.
SubRenderStateList mSubRenderStateList
bool createCpuPrograms()
Create CPU programs that represent this render state.
static int sSubRenderStateCompare(const void *p0, const void *p1)
Comparison function of the sub render states.
void link(const RenderState &other, Pass *srcPass, Pass *dstPass)
Link this target render state with the given render state.
RenderStateList::const_iterator RenderStateConstIterator
#define _OgreRTSSExport
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
const SubRenderStateList & getTemplateSubRenderStateList() const
Get the list of the template sub render states composing this render state.
Abstract class defining the interface all renderable objects must implement.
This is the target render state.
This is a container class for sub render state class.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
void sortSubRenderStates()
Sort the sub render states composing this render state.
ProgramSet * getProgramSet()
Return the program set of this render state.
void setLightCountAutoUpdate(bool autoUpdate)
Set the light count auto update state.
RenderStateList::iterator RenderStateIterator
void removeSubRenderStateInstance(SubRenderState *subRenderState)
Remove sub render state from this render state.
void addSubRenderStateInstance(SubRenderState *subRenderState)
Add sub render state to this render state.
vector< SubRenderState * >::type SubRenderStateList
This class is the base interface of sub part from a shader based rendering pipeline.
Container class for shader based programs.
bool getLightCountAutoUpdate() const
Return true if this render state override the light count.
A singleton manager class that manages shader based programs.
void updateGpuProgramsParams(Renderable *rend, Pass *pass, const AutoParamDataSource *source, const LightList *pLightList)
Update the GPU programs constant parameters before a renderable is rendered.
This utility class is used to hold the information used to generate the matrices and other informatio...