VVISF & VVGL
VVISF::ISFDoc Class Reference

Describes an "ISF file"- requires an actual file on disk which is parsed. Capable of generating GLSL source code for the various shader types. More...

#include <ISFDoc.hpp>

Public Member Functions

bool generateShaderSource (string *outFragSrc, string *outVertSrc, VVGL::GLVersion &inGLVers, const bool &inVarsAsUBO=false)
 Returns a true if successful. Generates GLSL source code, populating the provided vars with strings that are usable for frag/vert shaders. More...
 
Constructors
 ISFDoc (const string &inPath, ISFScene *inParentScene=nullptr, const bool &inThrowExcept=true) noexcept(false)
 Constructs an ISFDoc instance from a passed file on disk. Consider using CreateISFDocRef() instead. More...
 
 ISFDoc (const string &inFSContents, const string &inVSContents, const string &importsDir, ISFScene *inParentScene=nullptr, const bool &inThrowExcept=true)
 Constructs an ISFDoc instance from shader strings. Consider using CreateISFDocRef() instead.
 
ISF file properties
string path () const
 Returns the path of the ISF file for the receiver. This is probably the path to the frag shader.
 
string name () const
 Returns the name of the receiver's ISF file (the file name, minus the extension).
 
string description () const
 Returns the receiver's "description" string, as defined in its JSON blob ("DESCRIPTION").
 
string credit () const
 Returns the receiver's "credit" string, as defined in its JSON blob ("CREDIT").
 
string vsn () const
 Returns the receiver's "vsn" string, as defined in its JSON blob ("VSN")
 
ISFFileType type () const
 Returns the receiver's file type.
 
vector< string > & categories ()
 Returns a vector containing strings listing the receiver's categories.
 
ISF attribute/INPUT getters
vector< ISFAttrRef > & inputs ()
 Returns a vector of ISFAttrRef instances describing all of the receiver's inputs.
 
vector< ISFAttrRef > & imageInputs ()
 Returns a vector of ISFAttrRef instances describing only the receiver's image inputs.
 
vector< ISFAttrRef > & audioInputs ()
 Returns a vector of ISFAttrRef instances describing only the receiver's audio inputs.
 
vector< ISFAttrRef > & imageImports ()
 Returns a vector of ISFAttrRef instances describing only the receiver's audioFFT inputs.
 
vector< ISFAttrRef > inputsOfType (const ISFValType &inInputType)
 Returns a vector of ISFAttrRef instances describing only the receiver's inputs that match the passed type.
 
ISFAttrRef input (const string &inAttrName)
 Returns the ISFAttrRef for the input with the passed name.
 
ISF render pass getters
vector< ISFPassTargetRef > persistentPassTargets () const
 Returns a vector of ISFPassTargetRef instances describing every pass that has a persistent buffer.
 
vector< ISFPassTargetRef > tempPassTargets () const
 Returns a vector of ISFPassTargetRef instances describing every pass that doesn't have a persistent buffer.
 
vector< string > & renderPasses ()
 Returns a vector of std::string instances describing the names of the render passes, in order. If the names were not specified properly in the JSON blob, this array will be incomplete or inaccurate and rendering won't work!
 
const VVGL::GLBufferRef getBufferForKey (const string &n)
 Returns the GLBufferRef for the passed key. Checks all attributes/inputs as well as persistent and temp buffers.
 
const VVGL::GLBufferRef getPersistentBufferForKey (const string &n)
 Returns the persistent buffer for the render pass with the passed key.
 
const VVGL::GLBufferRef getTempBufferForKey (const string &n)
 Returns the temp buffer for the render pass with the passed key.
 
const ISFPassTargetRef passTargetForKey (const string &n)
 Returns the ISFPassTarget that matches the passed key. Returns null if no pass could be found.
 
const ISFPassTargetRef persistentPassTargetForKey (const string &n)
 Returns the ISFPassTarget that matches the passed key. Returns null if no pass could be found or if the pass found wasn't flagged as requiring a persistent buffer.
 
const ISFPassTargetRef tempPassTargetForKey (const string &n)
 Returns the ISFPassTarget that matches the passed key. Returns null if no pass could be found or if the pass found was flagged as requiring a persistent buffer.
 
ISF file source code getters
string * jsonSourceString () const
 Returns the JSON string from the source including the comments and any linebreaks before/after it
 
string * jsonString () const
 Returns the JSON string copied from the source- doesn't include any comments before/after it.
 
string * vertShaderSource () const
 Returns the raw vert shader source before being find-and-replaced.
 
string * fragShaderSource () const
 Returns the raw frag shader source before being find-and-replaced.
 
void jsonSourceString (string &outStr)
 Populates the passed var with the JSON string from the source including the comments and any linebreaks before/after it
 

Related Functions

(Note that these are not member functions.)

using ISFDocRef = shared_ptr< ISFDoc >
 ISFDocRef is a shared pointer around an ISFDoc instance. More...
 
ISFDocRef CreateISFDocRef (const string &inPath, ISFScene *inParentScene=nullptr, const bool &inThrowExcept=true) noexcept(false)
 Constructs an ISFDoc instance from a passed file on disk. More...
 
ISFDocRef CreateISFDocRefWith (const string &inFSContents, const string &inImportsDir=string("/"), const string &inVSContents=string(ISFVertPassthru_GL2), ISFScene *inParentScene=nullptr, const bool &inThrowExcept=true)
 Constructs an ISFDoc instance from shader strings. More...
 

Detailed Description

Describes an "ISF file"- requires an actual file on disk which is parsed. Capable of generating GLSL source code for the various shader types.

Constructing an instance of this class will load the files from disk into local string vars, parse them, and populate the instance with all the attributes(ISFAttr)/passes(ISFPassTarget) necessary to fully describe the ISF file.

Notes on use:

  • ISFDoc's constructor will throw an ISFErr if the file cannot be opened, or if there's a problem parsing the JSON blob in the ISF file.
  • ISFDoc can be used to examine the properties of "ISF files" on disk- create an ISFDoc instance, passing the constructor the path of the file to load, and then then you can examing the properties of the doc to get info about the ISF file.
  • Internally, ISFDoc has all the plumbing necessary to be used to render the ISF file- when you tell an ISFScene to use a file, it's actually creating an ISFDoc which is used to store information necessary for rendering- both ISFAttr and ISFPassTarget cache GL resources and interact directly with GL to do things like set uniform values, calculate rendering resolutions by evaluating strings and substituting variables, and things like that. Even the GLSL source code ISFScene compiles and runs for its GL programs is generated by the ISFDoc.

Constructor & Destructor Documentation

◆ ISFDoc()

VVISF::ISFDoc::ISFDoc ( const string &  inPath,
ISFScene inParentScene = nullptr,
const bool &  inThrowExcept = true 
)
noexcept

Constructs an ISFDoc instance from a passed file on disk. Consider using CreateISFDocRef() instead.

Parameters
inPathThe path to the ISF file you want to load as an ISFDoc.
inParentSceneThe scene that will be used to render this ISFDoc, or null if no scene is to be used.
inThrowExceptWhether or not the ISFDoc should throw any exceptions if it encounters errors parsing anything. Throws an ISFErr if there is a problem of some sort loading the ISF file from disk or parsing the JSON in the ISF file.

Member Function Documentation

◆ generateShaderSource()

bool VVISF::ISFDoc::generateShaderSource ( string *  outFragSrc,
string *  outVertSrc,
VVGL::GLVersion inGLVers,
const bool &  inVarsAsUBO = false 
)

Returns a true if successful. Generates GLSL source code, populating the provided vars with strings that are usable for frag/vert shaders.

Parameters
outFragSrcA non-null pre-allocated std::string variable which will be populated with the fragment shader source code generated for this ISF file.
outVertSrcA non-null pre-allocated std::string variable which will be populated with the vertex shader source code generated for this ISF file.
inGLVersThe version of OpenGL that the generated source code must be compatible with.
inVarsAsUBODefaults to false. If true, variable declarations for non-image INPUTS will be assembled in a uniform block. This option was added because a downstream utility requires it.

Friends And Related Function Documentation

◆ CreateISFDocRef()

ISFDocRef CreateISFDocRef ( const string &  inPath,
ISFScene inParentScene = nullptr,
const bool &  inThrowExcept = true 
)
related

Constructs an ISFDoc instance from a passed file on disk.

Parameters
inPathThe path to the ISF file you want to load as an ISFDoc.
inParentSceneThe scene that will be used to render this ISFDoc, or null if no scene is to be used.
inThrowExceptWhether or not the ISFDoc should throw any exceptions if it encounters errors parsing anything. Throws an ISFErr if there is a problem of some sort loading the ISF file from disk or parsing the JSON in the ISF file.

◆ CreateISFDocRefWith()

ISFDocRef CreateISFDocRefWith ( const string &  inFSContents,
const string &  inImportsDir = string("/"),
const string &  inVSContents = string(ISFVertPassthru_GL2),
ISFScene inParentScene = nullptr,
const bool &  inThrowExcept = true 
)
related

Constructs an ISFDoc instance from shader strings.

Parameters
inFSContentsA string containing the fragment shader portion of the ISF file. The JSON blob that defines the ISF file must be contained in here.
inVSContentsA string containing the vertex shader portion of the ISF file. If you don't have a vertex shader to pass, VVISF defines a static string "ISFVertPassthru_GL2", which should work as a "passthru" vertex shader for most purposes.
inParentSceneThe scene that will be used to render this ISFDoc, or null if no scene is to be used.
inThrowExceptWhether or not the ISFDoc should throw any exceptions if it encounters errors parsing anything. Throws an ISFErr if there is a problem of some sort parsing the JSON blob from the frag shader string.

◆ ISFDocRef

using ISFDocRef = shared_ptr<ISFDoc>
related

ISFDocRef is a shared pointer around an ISFDoc instance.

ISFDocRef is the preferred means of working with ISFDoc instances, which can be extremely simple with no overhead or can potentially contain a variety of data values including GL resources (texture, buffers, etc).


The documentation for this class was generated from the following files: