| GL Studio C++ Runtime API

effect_directx_shader.h
1#ifndef INCLUDED_EFFECT_DIRECTX_SHADER_H
2#define INCLUDED_EFFECT_DIRECTX_SHADER_H
3
4#include "effect_diff_norm_spec_refl.h"
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 runtime;
32/// it only holds the effect configuration for processing by the Lumen converter/generator.
33/// \deprecated The Lumen code generator is deprecated.
34 class Effect_DirectXShader : public GlsRenderEffect
35{
36 public:
37 static const std::string EFFECT_TYPE_NAME; ///< Backing storage for the human readable string for this effect type.
38
39 FilePathClass* _effectScriptPath; ///< File path to the script for this effect.
40
41 typedef std::map<std::string /* parameter name */, float> FloatParamsT; ///< Typedef for a map between strings and floats.
42 typedef std::map<std::string /* parameter name */, int> IntParamsT; ///< Typedef for a map between strings and ints.
43 typedef std::map<std::string /* parameter name */, GlsColor> ColorParamsT; ///< Typedef for a map between strings and Colors.
44 typedef std::map<std::string /* parameter name */, Vector> VectorParamsT; ///< Typedef for a map between strings and Vectors.
45 typedef std::map<std::string /* parameter name */, bool> BoolParamsT; ///< Typedef for a map between strings and bools.
46
47 FloatParamsT _floatParams; ///< Float parameter storage.
48 IntParamsT _intParams; ///< Int parameter storage.
49 ColorParamsT _colorParams; ///< Color parameter storage.
50 VectorParamsT _vectorParams; ///< Vector parameter storage.
51 BoolParamsT _boolParams; ///< Bool parameter storage.
52 IntParamsT _texture2DIndexParams; ///< 2D texture parameter storage.
53 IntParamsT _textureCUBEIndexParams; ///< Cube map parameter storage.
54
55 protected:
56 unsigned int _ref_count; ///< Reference count
57
58 unsigned int _materialIndex; ///< The material index to use
59
60 /** Used for rendering the object in the editor; we'll just set up a basic grey */
61 Effect_DiffNormSpecRefl* _helperEffect;
62
63 /// Sets up _helperEffect.
64 /// \note Not normally called by users
65 void SetupHelperEffect();
66
67 DistiAttribDict* _attribDict; ///< The attribute dictionary for this object.
68
69 /// Called to add this object's attributes to the dictionary.
70 /// \note Not normally called by users.
71 void SetupAttribDict();
72
73 public:
74 static const int INVALID_INDEX = -1; ///< Value to represent an invalid texture index.
75
76 GLSGEN_GlsAdvancedMesh_EXPORT Effect_DirectXShader();
77 GLSGEN_GlsAdvancedMesh_EXPORT ~Effect_DirectXShader();
78
79 /// Copy constructor
80 GLSGEN_GlsAdvancedMesh_EXPORT Effect_DirectXShader( const Effect_DirectXShader& );
81
82 /// Assignment operator
83 /// \return The resulting object (this).
84 GLSGEN_GlsAdvancedMesh_EXPORT const Effect_DirectXShader& operator=( const Effect_DirectXShader& );
85
86 /// Equality operator
87 /// \return Whether or not the objects are the same.
88 GLSGEN_GlsAdvancedMesh_EXPORT bool operator==( const Effect_DirectXShader& ) const;
89
90 /// Inequality operator
91 /// \param o The object to compare to.
92 /// \return Whether or not the objects are not the same.
93 inline bool operator!=( const Effect_DirectXShader& o ) const { return !( *this == o ); }
94
95 /// Set the material index for this effect.
96 /// \param materialIndex The new material index for this effect.
97 inline void SetMaterialIndex( unsigned int materialIndex ) { _materialIndex = materialIndex; }
98
99 /// \return The current material index for this effect.
100 inline unsigned int GetMaterialIndex() const { return _materialIndex; }
101
102 /// Selects the shader to use based on the current effect parameters.
103 /// \note Not normally called by users.
104 GLSGEN_GlsAdvancedMesh_EXPORT void SelectShader();
105
106 /// \return A reference to the effect attribute dictionary.
107 inline DistiAttribDict& Attributes() DISTI_METHOD_OVERRIDE
108 {
109 if( !_attribDict )
110 {
111 SetupAttribDict();
112 }
113 return *_attribDict;
114 }
115
116 /// \return This effect's type as a readable string.
117 inline const std::string& EffectTypeName() DISTI_METHOD_OVERRIDE
118 {
119 return EFFECT_TYPE_NAME;
120 }
121
122 /////////////////////////////////////////////
123 // VertexAttribIndexLookup Interface
124 /////////////////////////////////////////////
125
126 /// \copydoc VertexAttribIndexLookup::GetVertexAttribIndexForSemantic
127 virtual GLint GetVertexAttribIndexForSemantic( int semanticEnum ) DISTI_METHOD_OVERRIDE;
128
129 ///////////////////////////////////////////////////////////////////////////
130 // GlsRenderEffect overrides
131 ///////////////////////////////////////////////////////////////////////////
132
133 /// \copydoc GlsRenderEffect::AddRef
134 virtual void AddRef() DISTI_METHOD_OVERRIDE;
135
136 /// \copydoc GlsRenderEffect::Release
137 virtual void Release() DISTI_METHOD_OVERRIDE;
138
139 /// \copydoc GlsRenderEffect::GlsRenderEffect_ClassID
140 virtual unsigned int GlsRenderEffect_ClassID() const DISTI_METHOD_OVERRIDE;
141
142 /// \copydoc GlsRenderEffect::SetupEffect
143 virtual void SetupEffect(
144 DynamicArray<Material>& materialPalette,
145 TexturePalette* texturePalette,
146 const TextureSettings& textureSettings,
147 float* viewToWorld3x3, // 3x3 matrix (float[9])
148 unsigned int maxLightNum,
149 unsigned int activeLightMask ) DISTI_METHOD_OVERRIDE;
150
151 /// Remove the effect from the OpenGL state.
152 virtual void CleanupEffect();
153
154 /// \copydoc GlsRenderEffect::Compare
155 virtual int Compare( const GlsRenderEffect* other ) const DISTI_METHOD_OVERRIDE;
156
157 /// \copydoc GlsRenderEffect::Clone
158 virtual GlsRenderEffect* Clone() const DISTI_METHOD_OVERRIDE;
159};
160
161} // namespace disti
162
163#endif
disti::DistiAttribDict
Definition: disti_metadata.h:750
disti::DynamicArray
Definition: dynamic_array.h:79
disti::Effect_DiffNormSpecRefl
Definition: effect_diff_norm_spec_refl.h:74
disti::Effect_DirectXShader
Definition: effect_directx_shader.h:35
disti::Effect_DirectXShader::IntParamsT
std::map< std::string, int > IntParamsT
Typedef for a map between strings and ints.
Definition: effect_directx_shader.h:42
disti::Effect_DirectXShader::CleanupEffect
virtual void CleanupEffect()
Remove the effect from the OpenGL state.
disti::Effect_DirectXShader::_materialIndex
unsigned int _materialIndex
The material index to use.
Definition: effect_directx_shader.h:58
disti::Effect_DirectXShader::SetupHelperEffect
void SetupHelperEffect()
disti::Effect_DirectXShader::Attributes
DistiAttribDict & Attributes() DISTI_METHOD_OVERRIDE
Definition: effect_directx_shader.h:107
disti::Effect_DirectXShader::_vectorParams
VectorParamsT _vectorParams
Vector parameter storage.
Definition: effect_directx_shader.h:50
disti::Effect_DirectXShader::_texture2DIndexParams
IntParamsT _texture2DIndexParams
2D texture parameter storage.
Definition: effect_directx_shader.h:52
disti::Effect_DirectXShader::SetMaterialIndex
void SetMaterialIndex(unsigned int materialIndex)
Definition: effect_directx_shader.h:97
disti::Effect_DirectXShader::BoolParamsT
std::map< std::string, bool > BoolParamsT
Typedef for a map between strings and bools.
Definition: effect_directx_shader.h:45
disti::Effect_DirectXShader::_ref_count
unsigned int _ref_count
Reference count.
Definition: effect_directx_shader.h:56
disti::Effect_DirectXShader::GetMaterialIndex
unsigned int GetMaterialIndex() const
Definition: effect_directx_shader.h:100
disti::Effect_DirectXShader::VectorParamsT
std::map< std::string, Vector > VectorParamsT
Typedef for a map between strings and Vectors.
Definition: effect_directx_shader.h:44
disti::Effect_DirectXShader::operator=
const Effect_DirectXShader & operator=(const Effect_DirectXShader &)
disti::Effect_DirectXShader::SetupAttribDict
void SetupAttribDict()
disti::Effect_DirectXShader::SelectShader
void SelectShader()
disti::Effect_DirectXShader::_boolParams
BoolParamsT _boolParams
Bool parameter storage.
Definition: effect_directx_shader.h:51
disti::Effect_DirectXShader::EFFECT_TYPE_NAME
static const std::string EFFECT_TYPE_NAME
Backing storage for the human readable string for this effect type.
Definition: effect_directx_shader.h:37
disti::Effect_DirectXShader::_effectScriptPath
FilePathClass * _effectScriptPath
File path to the script for this effect.
Definition: effect_directx_shader.h:39
disti::Effect_DirectXShader::operator!=
bool operator!=(const Effect_DirectXShader &o) const
Definition: effect_directx_shader.h:93
disti::Effect_DirectXShader::Compare
virtual int Compare(const GlsRenderEffect *other) const DISTI_METHOD_OVERRIDE
disti::Effect_DirectXShader::_helperEffect
Effect_DiffNormSpecRefl * _helperEffect
Definition: effect_directx_shader.h:61
disti::Effect_DirectXShader::ColorParamsT
std::map< std::string, GlsColor > ColorParamsT
Typedef for a map between strings and Colors.
Definition: effect_directx_shader.h:43
disti::Effect_DirectXShader::Release
virtual void Release() DISTI_METHOD_OVERRIDE
Release a reference to this object.
disti::Effect_DirectXShader::GlsRenderEffect_ClassID
virtual unsigned int GlsRenderEffect_ClassID() const DISTI_METHOD_OVERRIDE
disti::Effect_DirectXShader::INVALID_INDEX
static const int INVALID_INDEX
Value to represent an invalid texture index.
Definition: effect_directx_shader.h:74
disti::Effect_DirectXShader::operator==
bool operator==(const Effect_DirectXShader &) const
disti::Effect_DirectXShader::GetVertexAttribIndexForSemantic
virtual GLint GetVertexAttribIndexForSemantic(int semanticEnum) DISTI_METHOD_OVERRIDE
disti::Effect_DirectXShader::_attribDict
DistiAttribDict * _attribDict
The attribute dictionary for this object.
Definition: effect_directx_shader.h:67
disti::Effect_DirectXShader::AddRef
virtual void AddRef() DISTI_METHOD_OVERRIDE
Add to this object's reference count.
disti::Effect_DirectXShader::SetupEffect
virtual void SetupEffect(DynamicArray< Material > &materialPalette, TexturePalette *texturePalette, const TextureSettings &textureSettings, float *viewToWorld3x3, unsigned int maxLightNum, unsigned int activeLightMask) DISTI_METHOD_OVERRIDE
disti::Effect_DirectXShader::Clone
virtual GlsRenderEffect * Clone() const DISTI_METHOD_OVERRIDE
disti::Effect_DirectXShader::_textureCUBEIndexParams
IntParamsT _textureCUBEIndexParams
Cube map parameter storage.
Definition: effect_directx_shader.h:53
disti::Effect_DirectXShader::FloatParamsT
std::map< std::string, float > FloatParamsT
Typedef for a map between strings and floats.
Definition: effect_directx_shader.h:41
disti::Effect_DirectXShader::_colorParams
ColorParamsT _colorParams
Color parameter storage.
Definition: effect_directx_shader.h:49
disti::Effect_DirectXShader::_floatParams
FloatParamsT _floatParams
Float parameter storage.
Definition: effect_directx_shader.h:47
disti::Effect_DirectXShader::EffectTypeName
const std::string & EffectTypeName() DISTI_METHOD_OVERRIDE
Definition: effect_directx_shader.h:117
disti::Effect_DirectXShader::_intParams
IntParamsT _intParams
Int parameter storage.
Definition: effect_directx_shader.h:48
disti::FilePathClass
Definition: file_path_class.h:63
disti::GlsColor
Definition: gls_color.h:54
disti::GlsRenderEffect::TextureSettings
Definition: gls_render_effect.h:136
disti::GlsRenderEffect
Definition: gls_render_effect.h:116
disti::Material
Definition: material.h:56
disti::TexturePalette
Definition: texture_palette.h:186
disti::VertexNoColor
Definition: vertex.h:85
effect_diff_norm_spec_refl.h
Render effect that supports diffuse, normal, specular, and reflection maps.
file_path_class.h
A class to handle file paths.
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
gls_matrix_affine.h
The GlsMatrixAffine class.
gls_render_effect.h
The disti::GlsRenderEffect class.
gls_state_manager.h
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
material.h
The disti::Material class.
disti
Definition: bmpimage.h:47