VVISF & VVGL
VVISF::ISFScene Class Reference

Subclass of GLScene- the primary interface for rendering and interacting with an ISF file. More...

#include <ISFScene.hpp>

Inherits VVGL::GLScene.

Public Member Functions

 ISFScene ()
 Creates a new OpenGL context that shares the global buffer pool's context.
 
 ISFScene (const VVGL::GLContextRef &inCtx)
 Creates a new ISFScene instance, but not a new OpenGL context- instead it uses the passed GLContext.
 
VVGL::Timestamp getTimestamp ()
 Creates a a new Timestamp relative to the scene's built-in _baseTime instance. This is how the render time is calculated.
 
void setThrowExceptions (const bool &n)
 Sets the "throwExceptions" member var, which is false by default. If true, the ISFScene will throw an exception using the ISFErr object to describe the nature and type of the problem. Exceptions may be thrown if the file is missing, if there's a problem reading it or parsing the JSON, if there's a problem compiling the GLSL source code for the shaders, etc.
 
virtual void setVertexShaderString (const string &n)
 You probably shouldn't call this method directly on this subclass.
 
virtual void setFragmentShaderString (const string &n)
 You probably shouldn't call this method directly on this subclass.
 
Loading ISF files
void useFile () noexcept(false)
 Unloads whatever ISF file is currently loaded.
 
void useFile (const string &inPath) noexcept(false)
 Loads the ISF file at the passed path.
 
void useDoc (ISFDocRef &inDoc)
 Starts using the ISF file represented by the passed ISFDoc.
 
ISFDocRef doc ()
 Returns the ISFDoc currently being used by the scene. Interacting with this doc by setting the value of its inputs will directly affect rendering.
 
Uncommon setter/getters
void setAlwaysRenderToFloat (const bool &n)
 Sets the receiver's _alwaysRenderToFloat flag- if true, all frames will be rendered using high-bit-depth textures (usually 32 bits per channel/128 bits per pixel). Default is false.
 
bool alwaysRenderToFloat ()
 Gets the receiver's _alwaysRenderToFloat flag.
 
void setPersistentToIOSurface (const bool &n)
 Sets the receiver's _persistentToIOSurface flag- if true, all passes that are flagged as persistent will render to IOSurface-backed GL textures (a mac-specific optimization that means the textures can be shared with other processes). Defaults to false.
 
bool persistentToIOSurface ()
 Gets the receiver's _persistentToIOSurface flag.
 
Setting/getting images and values from INPUTS and PASSES
void setBufferForInputNamed (const VVGL::GLBufferRef &inBuffer, const string &inName)
 Locates the attribute/INPUT with the passed name, and sets its current value to the passed GLBuffer.
 
void setFilterInputBuffer (const VVGL::GLBufferRef &inBuffer)
 Assumes that the receiver has loaded a filter-type ISF file- locates the attribute/INPUT that corresponds to the image filter input, and sets its current value to the passed GLBuffer.
 
void setBufferForInputImageKey (const VVGL::GLBufferRef &inBuffer, const string &inString)
 Locates the image-type input with the passed name, and sets its current value to the passed GLBuffer.
 
void setBufferForAudioInputKey (const VVGL::GLBufferRef &inBuffer, const string &inString)
 Locates the audio-type or audioFFT-type input with the passed name, and sets its current value to the passed GLBuffer.
 
VVGL::GLBufferRef getBufferForImageInput (const string &inKey)
 Locates the image-type input matching the passed string, and gets its current value (a GLBufferRef, or null).
 
VVGL::GLBufferRef getBufferForAudioInput (const string &inKey)
 Locates the audio-type input matching the passed string, and gets its current value (a GLBufferRef, or null).
 
VVGL::GLBufferRef getPersistentBufferNamed (const string &inKey)
 Locates the render pass flagged to render to a persistent buffer with a name that matches the passed string, and gets its current value (a GLBufferRef, or null).
 
VVGL::GLBufferRef getTempBufferNamed (const string &inKey)
 Locates the render pass not flagged to render to a persistent buffer with a name that matches the passed string, and gets its current value (a GLBufferRef, or null).
 
void setValueForInputNamed (const ISFVal &inVal, const string &inName)
 Locates the attribute/INPUT with the passed name, and sets its current value to the passed ISFVal. Can be used to set the value of inputs that use images to express their values, but there are dedicated functions which are easier to work with because they don't wrap the GLBufferRef up inside an ISFVal.
 
ISFVal valueForInputNamed (const string &inName)
 Locates the attribute/INPUT with the passed name, and gets its current value (an ISFVal). Attributes whose values are expressed as images vend ISFVal instances which in turn vend GLBufferRef instances.
 
Rendering to GLBuffer
virtual VVGL::GLBufferRef createAndRenderABuffer (const VVGL::Size &inSize=VVGL::Size(640., 480.), map< int32_t, VVGL::GLBufferRef > *outPassDict=nullptr, const VVGL::GLBufferPoolRef &inPoolRef=nullptr)
 Creates a buffer of the appropriate type (defaults to 8 bits per channel unless the ISF explicitly requires a floating point texture) and renders into it. More...
 
virtual VVGL::GLBufferRef createAndRenderABuffer (const VVGL::Size &inSize, const double &inRenderTime, map< int32_t, VVGL::GLBufferRef > *outPassDict=nullptr, const VVGL::GLBufferPoolRef &inPoolRef=nullptr)
 Creates a buffer of the appropriate type (defaults to 8 bits per channel unless the ISF explicitly requires a floating point texture) and renders into it. More...
 
Getting attributes/INPUTS
ISFAttrRef inputNamed (const string &inName)
 !{ More...
 
vector< ISFAttrRef > inputs ()
 Returns a vector of ISFAttrRef instances describing all of the attribute/INPUTS.
 
vector< ISFAttrRef > inputsOfType (const ISFValType &inType)
 Returns a vector of ISFAttrRef instances that match the bassed ISFValType.
 
vector< ISFAttrRef > imageInputs ()
 Returns a vector of all the image-type INPUTS, represented as ISFAttr instances.
 
vector< ISFAttrRef > audioInputs ()
 Returns a vector of all the audio- and audioFFT-type INPUTS, represented as ISFAttr instances.
 
vector< ISFAttrRef > imageImports ()
 Returns a vector of all the image-type IMPORTED, represented as ISFAttr instances.
 
- Public Member Functions inherited from VVGL::GLScene
 GLScene ()
 Creates a new OpenGL context that shares the global buffer pool's context.
 
 GLScene (const GLContextRef &inCtx)
 Creates a new GLScene instance, but not a new OpenGL context- instead it uses the passed GLContext.
 
GLContextRef context () const
 Returns the context used by this scene.
 
GLVersion glVersion () const
 Returns the version of OpenGL currently being used by this scene's GL context.
 
void setPrivatePool (const GLBufferPoolRef &n)
 Sets the receiver's private buffer pool (default is null). If non-null, this buffer pool will be used to generate any GL resources required by this scene. Handy if you have a variety of GL contexts that aren't shared and you have to switch between them rapidly on a per-frame basis.
 
GLBufferPoolRef privatePool () const
 Gets the receiver's private buffer pool- null by default, only non-null if something called setPrivatePool().
 
void setPrivateCopier (const GLTexToTexCopierRef &n)
 Sets the receiver's private buffer copier (which should default to null). If non-null, this copier will be used to copy any resources that need to be copied- like setPrivatePool(), handy if you have a variety of GL contexts that aren't shared and you have to switch between them rapidly on a per-frame basis.
 
GLTexToTexCopierRef privateCopier () const
 Gets the receiver's private buffer copier- null by default, only non-null if something called setPrivateCopier().
 
virtual GLBufferRef createAndRenderABuffer (const Size &inSize=Size(640., 480.), const GLBufferPoolRef &inPool=nullptr)
 Creates an 8 bit per channel GL texture, uses it as a color attachment to the GL context and then renders into it. Calls setOrthoSize() with the size of the image in the passed buffer.
 
virtual void renderToBuffer (const GLBufferRef &inBuffer)
 Uses the passed buffer as a color attachment to the GL context and then renders into it. Calls setOrthoSize() with the size of the image in the passed buffer.
 
virtual void render (const RenderTarget &inRenderTarget=RenderTarget())
 Renders the GL scene, uses whatever attachments are present in the passed RenderTarget. Doesn't call setOrthoSize() before rendering!
 
virtual void renderBlackFrame (const RenderTarget &inRenderTarget=RenderTarget())
 Makes the scene render transparent black into whatever attachments are present in the passed RenderTarget.
 
virtual void renderOpaqueBlackFrame (const RenderTarget &inRenderTarget=RenderTarget())
 Makes the scene render opaque black into whatever attachments are present in the passed RenderTarget.
 
virtual void renderRedFrame (const RenderTarget &inRenderTarget=RenderTarget())
 Makes the scene render opaque red into whatever attachments are present in the passed RenderTarget.
 
void setRenderPreLinkCallback (const RenderCallback &n)
 The render pre-link callback is executed if there's a shader after the shader/shaders have been successfully compiled, but before they've been linked. Procedurally, this is the first callback to execute. You probably don't want to perform any draw calls in this callback- this is a good time to configure your geometry shader.
 
void setRenderPrepCallback (const RenderPrepCallback &n)
 The render prep callback is executed after any shaders have been compiled and linked, after the attachments have been made, and after the framebuffer has been cleared (assuming the scene is configured to perform a clear). Procedurally, this is the second callback to execute, and the last to execute before draw calls are expected. You probably don't want to perform any draw calls in this callback- this is a good time to do any ancillary setup outside of this scene that needs to occur before drawing begins.
 
void setRenderCallback (const RenderCallback &n)
 The render callback is expected to contain the drawing code that you want the scene to perform. Procedurally, this is the third callback to execute.
 
void setRenderCleanupCallback (const RenderCallback &n)
 The render cleanup callback is executed immediately after the render callback. Procedurally, this is the fourth and final callback to execute as a result of a render call. You probably don't want to perform any draw calls in this callback- the context has already been flushed and there isn't a framebuffer any more. This is a good time to do any ancillary teardown outside of this scene that needs to occur before you finish and return execution to whatever started rendering.
 
void setAlwaysNeedsReshape (const bool &n)
 Defaults to false. If set to true, the viewport and orthogonal projection setup is applied every single frame (GL2 uses glOrtho, GL3+ uses a 4x4 matrix uniform in the shader to pass a projection transform to the program). You can leave this false unless you plan on modifying the viewport or equivalent of projection matrices in your callbacks.
 
virtual void setOrthoSize (const Size &n)
 Sets the orthogonal render size. If the size is 0x0 then orthogonal rendering is skipped- any other positive values will cause the scene to configure itself for orthographic projection at the passed size during rendering.
 
Size orthoSize () const
 Gets the orthogonal render size. If the size is 0x0 then orthogonal rendering is disabled.
 
void setOrthoFlipped (const bool &n)
 The _orthoFlipped member variable defaults to false- if it's set to true, the orthographic projection or equivalent will be flipped vertically.
 
bool orthoFlipped () const
 Gets the value of the _orthoFlipped member variable. If this is true, the orthographic projection or equivalent will be flipped vertically.
 
void setClearColor (const GLColor &n)
 Sets the clear color to the passed color.
 
void setClearColor (const float &r, const float &g, const float &b, const float &a)
 Sets the color color using the passed float values.
 
void setClearColor (float *n)
 Sets the clear color using a pointer to enough memory to contain four float values.
 
void setPerformClear (const bool &n)
 Sets the '_performClear' member variable. If it's true (the default) the context will clear to its clear color prior to drawing. The clear is performed before the render prep callback.
 
virtual string vertexShaderString ()
 Gets the vertex shader string.
 
virtual void setGeometryShaderString (const string &n)
 Sets the geometry shader string.
 
virtual string geometryShaderString ()
 Gets the geometry shader string.
 
virtual string fragmentShaderString ()
 Gets the fragment shader string.
 
uint32_t program () const
 Gets the program ID.
 

Related Functions

(Note that these are not member functions.)

using ISFSceneRef = std::shared_ptr< ISFScene >
 ISFSceneRef is a shared pointer around an ISFScene instance. More...
 
ISFSceneRef CreateISFSceneRef ()
 Creates and returns an ISFScene. The scene makes a new GL context which shares the context of the global buffer pool.
 
ISFSceneRef CreateISFSceneRefUsing (const VVGL::GLContextRef &inCtx)
 Creates and returns an ISFScene. The scene uses the passed GL context to do its drawing.
 

Additional Inherited Members

- Public Types inherited from VVGL::GLScene
using RenderCallback = std::function< void(const GLScene &inScene)>
 This defines the interface for a function/lambda that is used for encapsulating user-provided drawing code. Both the render callback and the render cleanup callback use this type. More...
 
using RenderPrepCallback = std::function< void(const GLScene &inScene, const bool &inSceneReshaped, const bool &inPgmChanged)>
 This defines the interface for the render prep callback, which is executed prior to the render callback. More...
 

Detailed Description

Subclass of GLScene- the primary interface for rendering and interacting with an ISF file.

Notes on use:

Member Function Documentation

◆ createAndRenderABuffer() [1/2]

virtual VVGL::GLBufferRef VVISF::ISFScene::createAndRenderABuffer ( const VVGL::Size inSize = VVGL::Size(640., 480.),
map< int32_t, VVGL::GLBufferRef > *  outPassDict = nullptr,
const VVGL::GLBufferPoolRef &  inPoolRef = nullptr 
)
virtual

Creates a buffer of the appropriate type (defaults to 8 bits per channel unless the ISF explicitly requires a floating point texture) and renders into it.

Parameters
inSizeThe size of the frame you want to render.
outPassDictEither null or a ptr to a valid map instance of the appropriate type- the output of each render pass is stored in this map.
inPoolRefThe buffer pool to use to create GL resources for this frame (defaults to the global buffer pool).

◆ createAndRenderABuffer() [2/2]

virtual VVGL::GLBufferRef VVISF::ISFScene::createAndRenderABuffer ( const VVGL::Size inSize,
const double &  inRenderTime,
map< int32_t, VVGL::GLBufferRef > *  outPassDict = nullptr,
const VVGL::GLBufferPoolRef &  inPoolRef = nullptr 
)
virtual

Creates a buffer of the appropriate type (defaults to 8 bits per channel unless the ISF explicitly requires a floating point texture) and renders into it.

Parameters
inSizeThe size of the frame you want to render.
inRenderTimeThe explicit time to use when rendering the frame.
outPassDictEither null or a ptr to a valid map instance of the appropriate type- the output of each render pass is stored in this map.
inPoolRefThe buffer pool to use to create GL resources for this frame (defaults to the global buffer pool).

◆ inputNamed()

ISFAttrRef VVISF::ISFScene::inputNamed ( const string &  inName)

!{

Locates and returns the attribute/INPUT matching the passed name.

Friends And Related Function Documentation

◆ ISFSceneRef

using ISFSceneRef = std::shared_ptr<ISFScene>
related

ISFSceneRef is a shared pointer around an ISFScene instance.

ISFScene is a subclass of GLScene, and like its parent, you should strive to work exclusively with ISFSceneRef instead of ISFScene directly.


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