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