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