OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreHlmsCommon.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-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _OgreHlmsCommon_H_
29 #define _OgreHlmsCommon_H_
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreIdString.h"
33 #include "OgreBlendMode.h"
34 #include "OgreVector3.h"
35 #include "OgreHeaderPrefix.h"
36 
37 namespace Ogre
38 {
47  {
48  String const *mOriginal;
49  size_t mStart;
50  size_t mEnd;
51 
52  public:
53  SubStringRef( const String *original, size_t start ) :
54  mOriginal( original ),
55  mStart( start ),
56  mEnd( original->size() )
57  {
58  assert( start <= original->size() );
59  }
60 
61  SubStringRef( const String *original, size_t start, size_t end_ ) :
62  mOriginal( original ),
63  mStart( start ),
64  mEnd( end_ )
65  {
66  assert( start <= end_ );
67  assert( end_ <= original->size() );
68  }
69 
70  SubStringRef( const String *original, String::const_iterator start ) :
71  mOriginal( original ),
72  mStart( start - original->begin() ),
73  mEnd( original->size() )
74  {
75  }
76 
77  size_t find( const char *value ) const
78  {
79  size_t retVal = mOriginal->find( value, mStart );
80  if( retVal >= mEnd )
81  retVal = String::npos;
82  else if( retVal != String::npos )
83  retVal -= mStart;
84 
85  return retVal;
86  }
87 
88  size_t find( const String &value ) const
89  {
90  size_t retVal = mOriginal->find( value, mStart );
91  if( retVal >= mEnd )
92  retVal = String::npos;
93  else if( retVal != String::npos )
94  retVal -= mStart;
95 
96  return retVal;
97  }
98 
99  void setStart( size_t newStart ) { mStart = std::min( newStart, mOriginal->size() ); }
100  void setEnd( size_t newEnd ) { mEnd = std::min( newEnd, mOriginal->size() ); }
101  size_t getStart(void) const { return mStart; }
102  size_t getEnd(void) const { return mEnd; }
103  size_t getSize(void) const { return mEnd - mStart; }
104  String::const_iterator begin() const { return mOriginal->begin() + mStart; }
105  String::const_iterator end() const { return mOriginal->begin() + mEnd; }
106  const String& getOriginalBuffer() const { return *mOriginal; }
107  };
108 
110  {
113 
114  HlmsProperty( IdString _keyName, int32 _value ) :
115  keyName( _keyName ), value( _value ) {}
116  };
117 
119 
120  inline bool OrderPropertyByIdString( const HlmsProperty &_left, const HlmsProperty &_right )
121  {
122  return _left.keyName < _right.keyName;
123  }
124 
126 
127  inline bool OrderParamVecByKey( const std::pair<IdString, String> &_left,
128  const std::pair<IdString, String> &_right )
129  {
130  return _left.first < _right.second;
131  }
132 
133  struct HlmsParam
134  {
135  virtual ~HlmsParam() {}
136 
145 
146  // Blending factors
151 
152  // Used to determine if separate alpha blending should be used for color and alpha channels
154 
155  //-------------------------------------------------------------------------
156  // Blending operations
159 
162  };
163 
165  {
169 
170  //TODO: Most likely these strings should be replaced by an index to the texture arrays.
176  };
177 
178  struct HlmsCache
179  {
182 
188 
189  /* This is state, independent of the shader being used
190  CullingMode cullMode;
191  PolygonMode polygonMode;
192  bool alphaToCoverageEnabled;
193  bool colourWrite;
194  bool depthCheck;
195  bool depthWrite;
196  CompareFunction depthFunc;
197  float depthBiasSlopeScale;
198 
199  // Blending factors
200  SceneBlendFactor sourceBlendFactor;
201  SceneBlendFactor destBlendFactor;
202  SceneBlendFactor sourceBlendFactorAlpha;
203  SceneBlendFactor destBlendFactorAlpha;
204 
205  // Used to determine if separate alpha blending should be used for color and alpha channels
206  bool separateBlend;
207 
208  //-------------------------------------------------------------------------
209  // Blending operations
210  SceneBlendOperation blendOperation;
211  SceneBlendOperation alphaBlendOperation;
212 
214  bool separateBlendOperation;
215 */
216 
217  HlmsCache( uint32 _hash ) : hash( _hash ) {}
218  };
219 
221 
222  inline bool OrderCacheByHash( const HlmsCache &_left, const HlmsCache &_right )
223  {
224  return _left.hash < _right.hash;
225  }
226 
230 }
231 
232 #include "OgreHeaderSuffix.h"
233 
234 #endif
GpuProgramPtr vertexShader
String const * mOriginal
unsigned int uint32
Definition: OgrePlatform.h:420
String::const_iterator end() const
vector< HlmsCache >::type HlmsCacheVec
size_t getSize(void) const
vector< std::pair< IdString, String > >::type HlmsParamVec
Class representing colour.
size_t find(const String &value) const
void setEnd(size_t newEnd)
SceneBlendFactor
Blending factors for manually blending objects with the scene.
SceneBlendFactor destBlendFactorAlpha
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:166
bool OrderPropertyByIdString(const HlmsProperty &_left, const HlmsProperty &_right)
GpuProgramPtr pixelShader
GpuProgramPtr tesselationHullShader
SceneBlendOperation alphaBlendOperation
ColourValue diffuseColour
size_t getEnd(void) const
SubStringRef(const String *original, size_t start, size_t end_)
String::const_iterator begin() const
const float & min(const float &a, const float &b)
Definition: OgreCommon.h:846
Hashed string.
Definition: OgreIdString.h:94
CullingMode cullMode
const String & getOriginalBuffer() const
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
SubStringRef(const String *original, String::const_iterator start)
SceneBlendFactor destBlendFactor
virtual ~HlmsParam()
vector< HlmsProperty >::type HlmsPropertyVec
HlmsCache(uint32 _hash)
GpuProgramPtr tesselationDomainShader
bool OrderCacheByHash(const HlmsCache &_left, const HlmsCache &_right)
HlmsPropertyVec setProperties
PolygonMode
The polygon mode to use when rasterising.
Definition: OgreCommon.h:210
SubStringRef(const String *original, size_t start)
HlmsProperty(IdString _keyName, int32 _value)
GpuProgramPtr geometryShader
SceneBlendOperation
Blending operations controls how objects are blended into the scene.
int int32
Definition: OgrePlatform.h:423
_StringBase String
Definition: OgreCommon.h:53
bool OrderParamVecByKey(const std::pair< IdString, String > &_left, const std::pair< IdString, String > &_right)
size_t getStart(void) const
SceneBlendFactor sourceBlendFactorAlpha
unsigned short uint16
Definition: OgrePlatform.h:421
CompareFunction depthFunc
SceneBlendOperation blendOperation
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:74
PolygonMode polygonMode
size_t find(const char *value) const
void setStart(size_t newStart)
bool separateBlendOperation
Determines if we should use separate blending operations for color and alpha channels.
SceneBlendFactor sourceBlendFactor