GL Studio C++ Runtime API
effect_directx_shader.h
1 #ifndef _EFFECT_DIRECTX_SHADER_H_INCLUDED
2 #define _EFFECT_DIRECTX_SHADER_H_INCLUDED
3 
5 #include "file_path_class.h"
6 #include "gls_render_effect.h"
7 #include "material.h"
8 #include <map>
9 
10 #ifdef _MSC_VER
11  // Disable warning in gls_matrix_affine.h (DR 2156)
12 # pragma warning( push )
13 # pragma warning( disable : 4244 )
14 #endif
15 #include "gls_matrix_affine.h"
16 #ifdef _MSC_VER
17 # pragma warning( pop )
18 #endif
19 
20 #ifdef GLES
21 # include "gls_state_manager.h"
22 #endif
23 
24 //////////////////// Provides support for creating DLLs ////////////////////////
25 #if( defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLSGEN_IMPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
26  && defined( _MSC_VER )
27 # if defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED )
28 # define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllexport )
29 # else
30 # define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllimport )
31 # endif
32 #else
33 # define GLSGEN_GlsAdvancedMesh_EXPORT
34 #endif
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 namespace disti
38 {
39 /** Render effect that supports DirectX effect scripts. This will not render anything special in the Editor or in the GLStudio 4 rungime;
40  * it only holds the effect configuration for processing by the Lumen converter/generator. */
42 {
43 public:
44  static const std::string EFFECT_TYPE_NAME;
45 
46  FilePathClass* _effectScriptPath;
47 
48  typedef std::map<std::string /* parameter name */, float> FloatParamsT;
49  typedef std::map<std::string /* parameter name */, int> IntParamsT;
50  typedef std::map<std::string /* parameter name */, GlsColor> ColorParamsT;
51  typedef std::map<std::string /* parameter name */, Vector> VectorParamsT;
52  typedef std::map<std::string /* parameter name */, bool> BoolParamsT;
53  FloatParamsT _floatParams;
54  IntParamsT _intParams;
55  ColorParamsT _colorParams;
56  VectorParamsT _vectorParams;
57  BoolParamsT _boolParams;
58  IntParamsT _texture2DIndexParams;
59  IntParamsT _textureCUBEIndexParams;
60 
61 protected:
62  unsigned int _ref_count; ///< Reference count
63 
64  unsigned int _materialIndex; ///< The material index to use
65 
66  /** Used for rendering the object in the editor; we'll just set up a basic grey */
68 
69  void SetupHelperEffect();
70 
71  DistiAttribDict* _attribDict;
72 
73  void SetupAttribDict();
74 
75 public:
76  static const int INVALID_INDEX = -1;
77 
78  GLSGEN_GlsAdvancedMesh_EXPORT Effect_DirectXShader();
79  GLSGEN_GlsAdvancedMesh_EXPORT ~Effect_DirectXShader();
80 
81  /** Assignment operator */
82  GLSGEN_GlsAdvancedMesh_EXPORT Effect_DirectXShader( const Effect_DirectXShader& );
83  GLSGEN_GlsAdvancedMesh_EXPORT const Effect_DirectXShader& operator=( const Effect_DirectXShader& );
84 
85  GLSGEN_GlsAdvancedMesh_EXPORT bool operator==( const Effect_DirectXShader& ) const;
86  inline bool operator!=( const Effect_DirectXShader& o ) const { return !( *this == o ); }
87 
88  inline void SetMaterialIndex( unsigned int materialIndex ) { _materialIndex = materialIndex; }
89  inline unsigned int GetMaterialIndex() const { return _materialIndex; }
90 
91  // Selects the shader to use based on the current effect parameters
92  // Not normally called by users
93  GLSGEN_GlsAdvancedMesh_EXPORT void SelectShader();
94 
95  // Returns reference to the effect attribute dictionary
96  inline DistiAttribDict& Attributes()
97  {
98  if( !_attribDict )
99  {
100  SetupAttribDict();
101  }
102  return *_attribDict;
103  }
104 
105  // Return this effect's type as a readable string
106  inline const std::string& EffectTypeName()
107  {
108  return EFFECT_TYPE_NAME;
109  }
110 
111  /////////////////////////////////////////////
112  // VertexAttribIndexLookup Interface
113  /////////////////////////////////////////////
114 
115  virtual GLint GetVertexAttribIndexForSemantic( int semanticEnum );
116 
117  ///////////////////////////////////////////////////////////////////////////
118  // GlsRenderEffect overrides
119  ///////////////////////////////////////////////////////////////////////////
120  virtual void AddRef();
121  virtual void Release();
122  virtual unsigned int GlsRenderEffect_ClassID() const;
123  virtual void SetupEffect(
124  DynamicArray<Material, false>& materialPalette,
125  TexturePalette* texturePalette,
126  const TextureSettings& textureSettings,
127  float* viewToWorld3x3 // 3x3 matrix (float[9])
128 #if !( ( GLS_VERSION_MAJOR == 4 && ( GLS_VERSION_MINOR == 1 || GLS_VERSION_MINOR == 0 ) ) || GLS_VERSION_MAJOR <= 3 )
129  ,
130  unsigned int maxLightNum,
131  unsigned int activeLightMask
132 #endif
133  );
134 
135  virtual void CleanupEffect();
136  virtual int Compare( const GlsRenderEffect* ) const;
137  virtual GlsRenderEffect* Clone() const;
138 };
139 
140 } // namespace disti
141 
142 #endif
Render effect that supports diffuse, normal, specular, and reflection maps.
A class to handle file paths.
The disti::Material class.
Definition: effect_diff_norm_spec_refl.h:82
unsigned int _ref_count
Reference count.
Definition: effect_directx_shader.h:62
The GlsMatrixAffine class.
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
virtual int Compare(const GlsRenderEffect *) const
virtual GLint GetVertexAttribIndexForSemantic(int semanticEnum)
Effect_DiffNormSpecRefl * _helperEffect
Definition: effect_directx_shader.h:67
virtual void CleanupEffect()
Remove the effect trom the OpenGL state.
Definition: gls_color.h:53
Definition: file_path_class.h:60
Definition: disti_metadata.h:673
virtual GlsRenderEffect * Clone() const
Definition: vertex.h:83
Definition: effect_directx_shader.h:41
virtual void SetupEffect(DynamicArray< Material, false > &materialPalette, TexturePalette *texturePalette, const TextureSettings &textureSettings, float *viewToWorld3x3)
Definition: gls_render_effect.h:115
unsigned int _materialIndex
The material index to use.
Definition: effect_directx_shader.h:64
Definition: bmpimage.h:46
The disti::GlsRenderEffect class.