Reads and writes a graphics shader file collection.
This class parses the commented JSON header at the top of ISF files (since that metadata is needed to build a node around the shader).
This class leaves #include
directives unresolved (to comply with the LGPL); VuoShader is responsible for resolving those.
Definition at line 29 of file VuoShaderFile.hh.
Classes | |
struct | Port |
A published input/output port in a shader. More... | |
Public Types | |
enum | Type { GLSLImageFilter , GLSLImageGenerator , GLSLImageTransition , GLSLObjectRenderer , GLSLObjectFilter } |
How the shader is intended to be used. More... | |
enum | Stage { Vertex , Geometry , Fragment , Program } |
The individual phases of a shader collection. More... | |
Public Member Functions | |
VuoShaderFile (Type type) | |
Creates a new shader collection from a template. More... | |
VuoShaderFile (VuoFileUtilities::File file, const string &overriddenFragmentSource="") | |
Reads a shader collection from a set of files. More... | |
void | dump () |
Logs info about the shader file to the console. More... | |
string | name () |
Returns the shader's display name. More... | |
Type | type () |
Returns this shader's type. More... | |
string | typeName () |
Returns a text description of this shader's type. More... | |
string | typeNameISF () |
Returns this shader's ISF type key. More... | |
bool | typeAllowsGeometryShader () |
Returns true if this shader type can have a geometry shader phase. More... | |
bool | typeAllowsFragmentShader () |
Returns true if this shader type can have a fragment shader phase. More... | |
VuoCompositionMetadata * | metadata () |
Returns the metadata for this shader. More... | |
void | setMetadata (VuoCompositionMetadata *metadata) |
Sets the metadata values for this shader. More... | |
json_object * | vuoModuleMetadata () |
Returns a JSON object in Module Metadata format. More... | |
void | setVuoModuleMetadata (json_object *metadata) |
Sets the shader's metadata, in Module Metadata format. More... | |
vector< Port > | inputPorts () |
Returns this shader's published input ports. More... | |
void | setInputPorts (vector< Port > ports) |
Sets this shader's published input ports. More... | |
bool | showsTime () |
Returns true if the node should show a Time port and use its value to populate the TIME uniform. More... | |
Port | outputPort () |
Returns this shader's published output port. More... | |
string & | vertexSource () |
Returns the user-editable source code for this shader's vertex shader phase (or empty string if the default passthru shader should be used). More... | |
void | setVertexSource (const string &source) |
Sets the user-edited source code for this shader's vertex shader phase. More... | |
string | expandedVertexSource () |
Returns the source code for this shader's vertex shader phase, with the ISF includes and uniforms inserted. More... | |
string & | geometrySource () |
Returns the user-editable source code for this shader's geometry shader phase (or empty string if the geometry shader phase should be disabled). More... | |
void | setGeometrySource (const string &source) |
Sets the user-edited source code for this shader's geometry shader phase. More... | |
string | expandedGeometrySource () |
Returns the source code for this shader's geometry shader phase, with the ISF includes and uniforms inserted (or empty string if the geometry shader phase should be disabled). More... | |
string & | fragmentSource () |
Returns the user-editable source code for this shader's fragment shader phase (or empty string if the fragment shader phase should be disabled). More... | |
void | setFragmentSource (const string &source) |
Returns the user-edited source code for this shader's fragment shader phase. More... | |
string | expandedFragmentSource () |
Returns the source code for this shader's fragment shader phase, with the ISF includes and uniforms inserted (or empty string if the fragment shader phase should be disabled). More... | |
void | save (string filePath) |
Writes the shader to filePath . More... | |
string | fragmentFileContents () |
Returns the string that would be written to the fragment shader file by save. More... | |
Static Public Member Functions | |
static VuoFileUtilities::File | getTemplate (Type type) |
Returns the specified template's primary file (the one with the ISF JSON header). More... | |
static string | stageName (Stage stage) |
Returns a display name for the specified shader stage. More... | |
static set< string > | supportedVuoTypes () |
Returns the allowed data types for input and output ports. More... | |
struct VuoShaderFile::Port |
Class Members | ||
---|---|---|
string | key | |
json_object * | vuoPortDetails | |
string | vuoTypeName |
enum VuoShaderFile::Stage |
The individual phases of a shader collection.
Definition at line 48 of file VuoShaderFile.hh.
enum VuoShaderFile::Type |
How the shader is intended to be used.
Definition at line 36 of file VuoShaderFile.hh.
VuoShaderFile::VuoShaderFile | ( | Type | type | ) |
Creates a new shader collection from a template.
Definition at line 23 of file VuoShaderFile.cc.
VuoShaderFile::VuoShaderFile | ( | VuoFileUtilities::File | file, |
const string & | overriddenFragmentSource = "" |
||
) |
Reads a shader collection from a set of files.
The specified file can be any one in the shader collection (i.e., you can pass the .vs
, .gs
, or .fs
file).
VuoException | The shader couldn't be parsed. |
Definition at line 73 of file VuoShaderFile.cc.
void VuoShaderFile::dump | ( | ) |
Logs info about the shader file to the console.
Definition at line 96 of file VuoShaderFile.cc.
string VuoShaderFile::expandedFragmentSource | ( | ) |
Returns the source code for this shader's fragment shader phase, with the ISF includes and uniforms inserted (or empty string if the fragment shader phase should be disabled).
Definition at line 428 of file VuoShaderFile.cc.
string VuoShaderFile::expandedGeometrySource | ( | ) |
Returns the source code for this shader's geometry shader phase, with the ISF includes and uniforms inserted (or empty string if the geometry shader phase should be disabled).
Definition at line 391 of file VuoShaderFile.cc.
string VuoShaderFile::expandedVertexSource | ( | ) |
Returns the source code for this shader's vertex shader phase, with the ISF includes and uniforms inserted.
Definition at line 347 of file VuoShaderFile.cc.
string VuoShaderFile::fragmentFileContents | ( | ) |
Returns the string that would be written to the fragment shader file by save.
Definition at line 479 of file VuoShaderFile.cc.
string & VuoShaderFile::fragmentSource | ( | ) |
Returns the user-editable source code for this shader's fragment shader phase (or empty string if the fragment shader phase should be disabled).
Definition at line 410 of file VuoShaderFile.cc.
string & VuoShaderFile::geometrySource | ( | ) |
Returns the user-editable source code for this shader's geometry shader phase (or empty string if the geometry shader phase should be disabled).
Definition at line 373 of file VuoShaderFile.cc.
|
static |
Returns the specified template's primary file (the one with the ISF JSON header).
Definition at line 31 of file VuoShaderFile.cc.
vector< VuoShaderFile::Port > VuoShaderFile::inputPorts | ( | ) |
Returns this shader's published input ports.
Definition at line 250 of file VuoShaderFile.cc.
VuoCompositionMetadata * VuoShaderFile::metadata | ( | ) |
Returns the metadata for this shader.
The caller takes ownership of the returned object.
Definition at line 196 of file VuoShaderFile.cc.
string VuoShaderFile::name | ( | ) |
Returns the shader's display name.
Definition at line 128 of file VuoShaderFile.cc.
VuoShaderFile::Port VuoShaderFile::outputPort | ( | ) |
Returns this shader's published output port.
Definition at line 275 of file VuoShaderFile.cc.
void VuoShaderFile::save | ( | string | filePath | ) |
Writes the shader to filePath
.
filePath
's extension is ignored. A file is created for each non-disabled, non-default shader phase. Stage files that are disabled or default are deleted.
Definition at line 450 of file VuoShaderFile.cc.
void VuoShaderFile::setFragmentSource | ( | const string & | source | ) |
Returns the user-edited source code for this shader's fragment shader phase.
Definition at line 418 of file VuoShaderFile.cc.
void VuoShaderFile::setGeometrySource | ( | const string & | source | ) |
Sets the user-edited source code for this shader's geometry shader phase.
Definition at line 381 of file VuoShaderFile.cc.
void VuoShaderFile::setInputPorts | ( | vector< Port > | ports | ) |
Sets this shader's published input ports.
Definition at line 258 of file VuoShaderFile.cc.
void VuoShaderFile::setMetadata | ( | VuoCompositionMetadata * | metadata | ) |
Sets the metadata values for this shader.
The caller keeps ownership of metadata.
Definition at line 215 of file VuoShaderFile.cc.
void VuoShaderFile::setVertexSource | ( | const string & | source | ) |
Sets the user-edited source code for this shader's vertex shader phase.
Definition at line 294 of file VuoShaderFile.cc.
void VuoShaderFile::setVuoModuleMetadata | ( | json_object * | metadata | ) |
Sets the shader's metadata, in Module Metadata format.
Definition at line 242 of file VuoShaderFile.cc.
bool VuoShaderFile::showsTime | ( | ) |
Returns true if the node should show a Time port and use its value to populate the TIME
uniform.
Definition at line 267 of file VuoShaderFile.cc.
|
static |
Returns a display name for the specified shader stage.
Definition at line 53 of file VuoShaderFile.cc.
|
static |
Returns the allowed data types for input and output ports.
Definition at line 849 of file VuoShaderFile.cc.
VuoShaderFile::Type VuoShaderFile::type | ( | ) |
Returns this shader's type.
Definition at line 136 of file VuoShaderFile.cc.
bool VuoShaderFile::typeAllowsFragmentShader | ( | ) |
Returns true if this shader type can have a fragment shader phase.
Definition at line 185 of file VuoShaderFile.cc.
bool VuoShaderFile::typeAllowsGeometryShader | ( | ) |
Returns true if this shader type can have a geometry shader phase.
Definition at line 176 of file VuoShaderFile.cc.
string VuoShaderFile::typeName | ( | ) |
Returns a text description of this shader's type.
Definition at line 144 of file VuoShaderFile.cc.
string VuoShaderFile::typeNameISF | ( | ) |
Returns this shader's ISF type key.
Definition at line 161 of file VuoShaderFile.cc.
string & VuoShaderFile::vertexSource | ( | ) |
Returns the user-editable source code for this shader's vertex shader phase (or empty string if the default passthru shader should be used).
Definition at line 286 of file VuoShaderFile.cc.
json_object * VuoShaderFile::vuoModuleMetadata | ( | ) |
Returns a JSON object in Module Metadata format.
Definition at line 234 of file VuoShaderFile.cc.