6#ifndef MATERIALX_GLSLPROGRAM_H
7#define MATERIALX_GLSLPROGRAM_H
14#include <MaterialXRender/Camera.h>
21MATERIALX_NAMESPACE_BEGIN
24using GlslProgramPtr = std::shared_ptr<class GlslProgram>;
54 void addStage(
const string& stage,
const string& sourceCode);
81 void clearBuiltData();
93 static int INVALID_OPENGL_TYPE;
116 Input(
int inputLocation,
int inputType,
int inputSize,
const string& inputPath) :
117 location(inputLocation),
127 using InputMap = std::unordered_map<string, InputPtr>;
212 static unsigned int UNDEFINED_OPENGL_RESOURCE_ID;
213 static int UNDEFINED_OPENGL_PROGRAM_LOCATION;
219 const InputMap& updateUniformsList();
222 const InputMap& updateAttributesList();
226 ValuePtr findUniformValue(
const string& uniformName,
const InputMap& uniformList);
229 ImagePtr bindTexture(
unsigned int uniformType,
int uniformLocation,
const FilePath& filePath,
233 static int mapTypeToOpenGLType(
TypeDesc type);
244 unsigned int _programId;
256 std::unordered_map<string, unsigned int> _attributeBufferIds;
259 std::map<MeshPartitionPtr, unsigned int> _indexBufferIds;
262 unsigned int _vertexArray;
268 std::unordered_map<string, unsigned int> _programTextures;
271 std::set<int> _enabledStreamLocations;
274MATERIALX_NAMESPACE_END
Geometry loader interfaces.
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:23
Image handler interfaces.
std::shared_ptr< ImageHandler > ImageHandlerPtr
Shared pointer to an ImageHandler.
Definition: ImageHandler.h:32
Handler for hardware lights.
std::shared_ptr< class LightHandler > LightHandlerPtr
Shared pointer to a LightHandler.
Definition: LightHandler.h:25
std::unordered_map< string, string > StringMap
An unordered map with strings as both keys and values.
Definition: Library.h:57
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
Macros for declaring imported and exported symbols.
shared_ptr< class MeshPartition > MeshPartitionPtr
Shared pointer to a mesh partition.
Definition: Mesh.h:146
shared_ptr< class Mesh > MeshPtr
Shared pointer to a mesh.
Definition: Mesh.h:230
Shader instance class created during shader generation.
shared_ptr< const Value > ConstValuePtr
A shared pointer to a const Value.
Definition: Value.h:31
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:27
A class representing an executable GLSL program.
Definition: GlslProgram.h:32
const InputMap & getAttributesList()
Get list of program input attributes.
std::shared_ptr< Input > InputPtr
Program input structure shared pointer type.
Definition: GlslProgram.h:125
void printAttributes(std::ostream &outputStream)
Print all attributes to the given stream.
bool hasActiveAttributes() const
Return true if the program has active attributes.
void bindMesh(MeshPtr mesh)
Bind input geometry streams.
bool bind()
Bind the program.
bool hasBuiltData()
Return true if built shader program data is present.
void bindTextures(ImageHandlerPtr imageHandler)
Bind any input textures.
void printUniforms(std::ostream &outputStream)
Print all uniforms to the given stream.
void bindAttribute(const GlslProgram::InputMap &inputs, MeshPtr mesh)
Bind attribute buffers to attribute inputs.
std::unordered_map< string, InputPtr > InputMap
Program input shaded pointer map type.
Definition: GlslProgram.h:127
void bindUniform(const string &name, ConstValuePtr value, bool errorIfMissing=true)
Bind a value to the uniform with the given name.
static GlslProgramPtr create()
Create a GLSL program instance.
Definition: GlslProgram.h:35
void setStages(ShaderPtr shader)
Set up code stages to validate based on an input hardware shader.
void build()
Build shader program data from the source code set for each shader stage.
void bindPartition(MeshPartitionPtr partition)
Bind input geometry partition (indexing)
void unbindGeometry()
Unbind any bound geometry.
const string & getStageSourceCode(const string &stage) const
Get source code string for a given stage.
void bindLighting(LightHandlerPtr lightHandler, ImageHandlerPtr imageHandler)
Bind lighting.
void unbind() const
Unbind the program. Equivalent to binding no program.
void findInputs(const string &variable, const InputMap &variableList, InputMap &foundList, bool exactMatch)
Find the locations in the program which starts with a given variable name.
ShaderPtr getShader() const
Return the shader, if any, used to generate this program.
Definition: GlslProgram.h:61
const InputMap & getUniformsList()
Get list of program input uniforms.
virtual ~GlslProgram()
Destructor.
void bindViewInformation(CameraPtr camera)
Bind view information.
void addStage(const string &stage, const string &sourceCode)
Set the code stages based on a list of stage strings.
void bindTimeAndFrame(float time=1.0f, float frame=1.0f)
Bind time and frame.
bool hasUniform(const string &name)
Return true if a uniform with the given name is present.
Interface to describe sampling properties for images.
Definition: ImageHandler.h:43
A type descriptor for MaterialX data types.
Definition: TypeDesc.h:35