GL Studio C++ Runtime API
effect_directx_shader.h
Go to the documentation of this file.
1/// \file effect_directx_shader.h
2/// \brief DirectX shader effect interface.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2026 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef INCLUDED_EFFECT_DIRECTX_SHADER_H
40#define INCLUDED_EFFECT_DIRECTX_SHADER_H
41
43#include "file_path_class.h"
44#include "gls_matrix_affine.h"
45#include "gls_render_effect.h"
46#include "material.h"
47
48#include <map>
49
50#ifdef GLES
51# include "gls_state_manager.h"
52#endif
53
54//////////////////// Provides support for creating DLLs ////////////////////////
55#if( defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLSGEN_IMPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
56 && defined( _MSC_VER )
57# if defined( GLSGEN_EXPORT_GLSADVANCEDMESH ) || defined( GLS_EXPORT_GENERATED )
58# define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllexport )
59# else
60# define GLSGEN_GlsAdvancedMesh_EXPORT __declspec( dllimport )
61# endif
62#else
63# define GLSGEN_GlsAdvancedMesh_EXPORT
64#endif
65///////////////////////////////////////////////////////////////////////////////
66
67namespace disti
68{
69/// Render effect that supports DirectX effect scripts. This will not render anything special in the Editor or in the GLStudio runtime;
70/// it only holds the effect configuration for processing by the Lumen converter/generator.
71/// \deprecated The Lumen code generator is deprecated.
73{
74public:
75 static const std::string EFFECT_TYPE_NAME; ///< Backing storage for the human readable string for this effect type.
76
77 FilePathClass* _effectScriptPath; ///< File path to the script for this effect.
78
79 typedef std::map<std::string /* parameter name */, float> FloatParamsT; ///< Typedef for a map between strings and floats.
80 typedef std::map<std::string /* parameter name */, int> IntParamsT; ///< Typedef for a map between strings and ints.
81 typedef std::map<std::string /* parameter name */, GlsColor> ColorParamsT; ///< Typedef for a map between strings and Colors.
82 typedef std::map<std::string /* parameter name */, Vector> VectorParamsT; ///< Typedef for a map between strings and Vectors.
83 typedef std::map<std::string /* parameter name */, bool> BoolParamsT; ///< Typedef for a map between strings and bools.
84
85 FloatParamsT _floatParams; ///< Float parameter storage.
86 IntParamsT _intParams; ///< Int parameter storage.
87 ColorParamsT _colorParams; ///< Color parameter storage.
88 VectorParamsT _vectorParams; ///< Vector parameter storage.
89 BoolParamsT _boolParams; ///< Bool parameter storage.
90 IntParamsT _texture2DIndexParams; ///< 2D texture parameter storage.
91 IntParamsT _textureCUBEIndexParams; ///< Cube map parameter storage.
92
93protected:
94 unsigned int _ref_count; ///< Reference count
95
96 unsigned int _materialIndex; ///< The material index to use
97
98 /** Used for rendering the object in the editor; we'll just set up a basic grey */
100
101 /// Sets up _helperEffect.
102 /// \note Not normally called by users
104
105 DistiAttribDict* _attribDict; ///< The attribute dictionary for this object.
106
107 /// Called to add this object's attributes to the dictionary.
108 /// \note Not normally called by users.
110
111public:
112 static const int INVALID_INDEX = -1; ///< Value to represent an invalid texture index.
113
114 GLSGEN_GlsAdvancedMesh_EXPORT Effect_DirectXShader();
115 GLSGEN_GlsAdvancedMesh_EXPORT ~Effect_DirectXShader();
116
117 /// Copy constructor
118 GLSGEN_GlsAdvancedMesh_EXPORT Effect_DirectXShader( const Effect_DirectXShader& );
119
120 /// Assignment operator
121 /// \return The resulting object (this).
122 GLSGEN_GlsAdvancedMesh_EXPORT const Effect_DirectXShader& operator=( const Effect_DirectXShader& );
123
124 /// Equality operator
125 /// \return Whether or not the objects are the same.
126 GLSGEN_GlsAdvancedMesh_EXPORT bool operator==( const Effect_DirectXShader& ) const;
127
128 /// Inequality operator
129 /// \param o The object to compare to.
130 /// \return Whether or not the objects are not the same.
131 bool operator!=( const Effect_DirectXShader& o ) const { return !( *this == o ); }
132
133 /// Set the material index for this effect.
134 /// \param materialIndex The new material index for this effect.
135 void SetMaterialIndex( unsigned int materialIndex ) { _materialIndex = materialIndex; }
136
137 /// \return The current material index for this effect.
138 unsigned int GetMaterialIndex() const { return _materialIndex; }
139
140 /// Selects the shader to use based on the current effect parameters.
141 /// \note Not normally called by users.
142 GLSGEN_GlsAdvancedMesh_EXPORT void SelectShader();
143
144 /// \return A reference to the effect attribute dictionary.
146 {
147 if( !_attribDict )
148 {
150 }
151 return *_attribDict;
152 }
153
154 /// \return This effect's type as a readable string.
156 {
157 return EFFECT_TYPE_NAME;
158 }
159
160 /////////////////////////////////////////////
161 // VertexAttribIndexLookup Interface
162 /////////////////////////////////////////////
163
164 /// \copydoc VertexAttribIndexLookup::GetVertexAttribIndexForSemantic
166
167 ///////////////////////////////////////////////////////////////////////////
168 // GlsRenderEffect overrides
169 ///////////////////////////////////////////////////////////////////////////
170
171 /// \copydoc GlsRenderEffect::AddRef
173
174 /// \copydoc GlsRenderEffect::Release
176
177 /// \copydoc GlsRenderEffect::GlsRenderEffect_ClassID
179
180 /// \copydoc GlsRenderEffect::SetupEffect
182 DynamicArray<Material>& materialPalette,
183 TexturePalette* texturePalette,
184 const TextureSettings& textureSettings,
185 float* viewToWorld3x3, // 3x3 matrix (float[9])
186 unsigned int maxLightNum,
187 unsigned int activeLightMask ) DISTI_METHOD_OVERRIDE;
188
189 /// Remove the effect from the OpenGL state.
191
192 /// \copydoc GlsRenderEffect::Compare
194
195 /// \copydoc GlsRenderEffect::Clone
197};
198
199} // namespace disti
200
201#endif
Definition: disti_metadata.h:750
Definition: dynamic_array.h:79
Definition: effect_diff_norm_spec_refl.h:70
Definition: effect_directx_shader.h:73
std::map< std::string, int > IntParamsT
Typedef for a map between strings and ints.
Definition: effect_directx_shader.h:80
void AddRef() DISTI_METHOD_OVERRIDE
Add to this object's reference count.
void SetupEffect(DynamicArray< Material > &materialPalette, TexturePalette *texturePalette, const TextureSettings &textureSettings, float *viewToWorld3x3, unsigned int maxLightNum, unsigned int activeLightMask) DISTI_METHOD_OVERRIDE
GLint GetVertexAttribIndexForSemantic(int semanticEnum) DISTI_METHOD_OVERRIDE
void Release() DISTI_METHOD_OVERRIDE
Release a reference to this object.
unsigned int _materialIndex
The material index to use.
Definition: effect_directx_shader.h:96
DistiAttribDict & Attributes() DISTI_METHOD_OVERRIDE
Definition: effect_directx_shader.h:145
int Compare(const GlsRenderEffect *other) const DISTI_METHOD_OVERRIDE
VectorParamsT _vectorParams
Vector parameter storage.
Definition: effect_directx_shader.h:88
IntParamsT _texture2DIndexParams
2D texture parameter storage.
Definition: effect_directx_shader.h:90
void SetMaterialIndex(unsigned int materialIndex)
Definition: effect_directx_shader.h:135
std::map< std::string, bool > BoolParamsT
Typedef for a map between strings and bools.
Definition: effect_directx_shader.h:83
unsigned int _ref_count
Reference count.
Definition: effect_directx_shader.h:94
unsigned int GetMaterialIndex() const
Definition: effect_directx_shader.h:138
std::map< std::string, Vector > VectorParamsT
Typedef for a map between strings and Vectors.
Definition: effect_directx_shader.h:82
const Effect_DirectXShader & operator=(const Effect_DirectXShader &)
BoolParamsT _boolParams
Bool parameter storage.
Definition: effect_directx_shader.h:89
static const std::string EFFECT_TYPE_NAME
Backing storage for the human readable string for this effect type.
Definition: effect_directx_shader.h:75
unsigned int GlsRenderEffect_ClassID() const DISTI_METHOD_OVERRIDE
FilePathClass * _effectScriptPath
File path to the script for this effect.
Definition: effect_directx_shader.h:77
bool operator!=(const Effect_DirectXShader &o) const
Definition: effect_directx_shader.h:131
Effect_DiffNormSpecRefl * _helperEffect
Definition: effect_directx_shader.h:99
std::map< std::string, GlsColor > ColorParamsT
Typedef for a map between strings and Colors.
Definition: effect_directx_shader.h:81
static const int INVALID_INDEX
Value to represent an invalid texture index.
Definition: effect_directx_shader.h:112
bool operator==(const Effect_DirectXShader &) const
DistiAttribDict * _attribDict
The attribute dictionary for this object.
Definition: effect_directx_shader.h:105
GlsRenderEffect * Clone() const DISTI_METHOD_OVERRIDE
void CleanupEffect() DISTI_METHOD_OVERRIDE
Remove the effect from the OpenGL state.
IntParamsT _textureCUBEIndexParams
Cube map parameter storage.
Definition: effect_directx_shader.h:91
std::map< std::string, float > FloatParamsT
Typedef for a map between strings and floats.
Definition: effect_directx_shader.h:79
ColorParamsT _colorParams
Color parameter storage.
Definition: effect_directx_shader.h:87
FloatParamsT _floatParams
Float parameter storage.
Definition: effect_directx_shader.h:85
const std::string & EffectTypeName() DISTI_METHOD_OVERRIDE
Definition: effect_directx_shader.h:155
IntParamsT _intParams
Int parameter storage.
Definition: effect_directx_shader.h:86
Definition: file_path_class.h:62
Definition: gls_color.h:53
Definition: gls_render_effect.h:135
Definition: gls_render_effect.h:115
Definition: material.h:54
Definition: texture_palette.h:185
Definition: vertex.h:84
Render effect that supports diffuse, normal, specular, and reflection maps.
A class to handle file paths.
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
The GlsMatrixAffine class.
The disti::GlsRenderEffect class.
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
The disti::Material class.
Definition: bmpimage.h:46