The Vish Visualization Shell 0.3
Vish
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Wizt::RenderBasin::Program Class Referenceabstract

Base class for abstract shader/render programs. More...

#include <ocean/Anemonia/RenderBasin.hpp>

Inheritance diagram for Wizt::RenderBasin::Program:
Wizt::Anemone::SpecializedTentacle< Anemone::Program > Wizt::RenderNamespace::ProgramVariables Wizt::Anemone::Tentacle MemCore::ReferenceBase< Tentacle > Wizt::GLProgram Wizt::WebGLProgram

Classes

struct  Parameters
 Program parameters that need to be set before linking shader stages. More...
 
struct  Parameters.Geometry
 
struct  Parameters.Geometry.Output
 

Public Types

using Setup = std::function< Parameters(const Parameters &MaximumValues)>
 The setup function when linking a program, which is given maximum values as possible by the current implementation and needs to specify the actually required values for a given shader.
 
using SourceCode_t = std::map< std::string, glsl >
 Map from filename to source code.
 
using Sources_t = std::map< std::string, MemCore::Filetime >
 File names and file modification/access/creation time.
 
- Public Types inherited from MemCore::ReferenceBase< Tentacle >
using reference_domain_t = Tentacle
 The type of the base class.
 
using SelfPtr_t = WeakPtr< Tentacle, Tentacle >
 Type for a pointer to this object itself.
 

Public Member Functions

 Program ()
 Constructor.
 
virtual void setAllUniforms (const Anemone &A) const =0
 Set all uniform variables.
 
bool SourceHasChanged () const
 Check if any of the registered source files (mySources) has changed.
 
virtual void use () const =0
 Use the program.
 
- Public Member Functions inherited from Wizt::Anemone::Tentacle
virtual bool activate (const Anemone &)=0
 Activate this tentacle.
 
virtual bool deactivate (const Anemone &)=0
 Deactivate this tentacle.
 
virtual const char * getSamplerType () const
 If this tentacle refers to some texture sampler in a shader, then hereby return the type of this sampler is it occurs in the code.
 
virtual int getTextureUnit () const
 Get the texture unit number which was specified during construction, if positive then it refers to some texture unit that is used in an associated shader.
 
virtual size_t memsize () const
 Return the memory occupied by this buffer if it occupies memory at all. Otherwise, returns 0 (default).
 
virtual size_t NumberOfElements () const
 Returns the number of elements provided and used by this object, if it refers to countable elements.
 
virtual bool updateValue (VRenderContext &Context)
 Possibly update a tentacle from settings in a context.
 
- Public Member Functions inherited from MemCore::ReferenceBase< Tentacle >
auto getObjectCountID () const noexcept
 Get a unique ID for this object in the given domain.
 
bool isIdentical (const WeakPtr< Tentacle, Tentacle > &PossibleSelf) const noexcept
 Check if this object is identical to the one used by the given pointer.
 
void mkAutoDestructive ()
 Marks this object as being automatically destructed, e.g.
 
refcount_t refcount () const noexcept
 The strong reference count.
 
 ReferenceBase (Tentacle *that) noexcept
 Constructor, initializes reference counter to zero.
 
const auto & self () const
 Return weak pointer to the object self.
 
refcount_t wrefcount () const noexcept
 The weak reference count.
 
- Public Member Functions inherited from Wizt::RenderNamespace::ProgramVariables
ProgramVariablesmerge (const ProgramVariables &, substitutes_t &substitutes, const std::string &src_original, const std::string &src_substitute)
 Merge a set of program variables into this current one and substitute the variable names by another string thereby.
 
void remove (const substitutes_t &substitutes)
 Remove all variables as given in the set.
 
template<class T >
void setMandatoryValue (const std::string &name, const T &t, bool isMandatory=true)
 Set a value that will raise an exception if that variable is not used in the shader program.
 
void setPointValue (const std::string &name, const Eagle::FixedArray< double, 3 > &v)
 Set an vec3 uniform that is suspect to coordinate shifting.
 
void setValue (const std::string &name, const Eagle::FixedArray< double, 2 > &v)
 Set an vec2 uniform.
 
void setValue (const std::string &name, const Eagle::FixedArray< double, 3 > &v)
 Set an vec3 uniform.
 
void setValue (const std::string &name, const Eagle::FixedArray< double, 4 > &v)
 Set an vec4 uniform.
 
void setValue (const std::string &name, const Eagle::FixedArray< float, 4 > &v)
 Set an vec4 uniform of floats.
 
void setValue (const std::string &name, const Eagle::FixedArray< int, 2 > &v)
 Set an vec2 uniform.
 
void setValue (const std::string &name, const Eagle::FixedArray< int, 3 > &v)
 Set an vec3 uniform.
 
void setValue (const std::string &name, const Eagle::Quadratic< 3, float > &M)
 Set an integer uniform.
 
void setValue (const std::string &name, double d)
 Set a floating point uniform.
 
void setValue (const std::string &name, int i)
 Set an integer uniform.
 

Public Attributes

Sources_t mySources
 List of file names associated with this program and their respective modification times.
 
bool SilentlyIgnoreUnknownUniforms
 Throw a RenderException if a variable is set that is not used in the program.
 
SourceCode_t SourceCode
 For information only, the last complete source code that was used to compile this shader, indexed by an key word for multiple shader types.
 
NamedTextures_t Textures
 A set of named textures to be used in this Program.
 
- Public Attributes inherited from Wizt::Anemone::Tentacle
Activity_t Activity
 A bit mask telling whether this tentacle should participate in the waving of an Anemone.
 
- Public Attributes inherited from Wizt::RenderNamespace::ProgramVariables
FloatValues_t FloatValues
 A set of floating point values that will be set for this program.
 
IntValues_t IntValues
 A set of integer values that will be set for this program.
 
std::map< std::string, Eagle::FixedArray< int, 2 > > iVec2Values
 A set of 3D integer vectors that will be set for this program as uniforms.
 
std::map< std::string, Eagle::FixedArray< int, 3 > > iVec3Values
 A set of 3D integer vectors that will be set for this program as uniforms.
 
std::map< std::string, std::vector< Eagle::Quadratic< 3, float > > > M33ArrayValues
 A set of matric values that will be set for this program.
 
std::map< std::string, Eagle::Quadratic< 3, float > > M33Values
 A set of matric values that will be set for this program.
 
std::map< std::string, Eagle::FixedArray< double, 3 > > Point3Values
 A set of 3D vectors that will be set for this program as uniforms.
 
std::map< std::string, Eagle::FixedArray< double, 2 > > Vec2Values
 A set of 2D vectors that will be set for this program as uniforms.
 
std::map< std::string, Eagle::FixedArray< double, 3 > > Vec3Values
 A set of 3D vectors that will be set for this program as uniforms.
 
std::map< std::string, Eagle::FixedArray< double, 4 > > Vec4Values
 A set of 4D vectors that will be set for this program as uniforms.
 

Protected Member Functions

virtual ~Program ()=0
 Destructor.
 
- Protected Member Functions inherited from MemCore::ReferenceBase< Tentacle >
virtual void extremeUnction ()
 A virtual function that will be called just before the object is destroyed.
 
ReferenceBaseoperator= (const ReferenceBase &R)
 Protected assignment operator (should not be called).
 
void suicide ()
 Delete this.
 
virtual ~ReferenceBase ()
 Virtual destructor.
 

Detailed Description

Base class for abstract shader/render programs.


Class Documentation

◆ Wizt::RenderBasin::Program::Parameters

struct Wizt::RenderBasin::Program::Parameters

Program parameters that need to be set before linking shader stages.

Allows settings via https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glProgramParameter.xhtml in an OpenGL Context.

Default values are taken from https://www.khronos.org/opengl/wiki/GLAPI/glGet#Geometry_Shaders but an actual shader implementation should use smaller values to help the GLSL compiler on optimizing its code and memory consumption. Some implementations may just reserve the given maximum value even though it's not needed, which then may well overwhelm the graphics hardware.

Actual values on invocation of the createGeometryProgram() feedback function are taken from the current hardware implementation.

◆ Wizt::RenderBasin::Program::Parameters.Geometry

struct Wizt::RenderBasin::Program::Parameters.Geometry

◆ Wizt::RenderBasin::Program::Parameters.Geometry.Output

struct Wizt::RenderBasin::Program::Parameters.Geometry.Output
Class Members
int Components
int Shader_Invocations up to 32
int Total_Components
int Vertices

Member Function Documentation

◆ setAllUniforms()

virtual void Wizt::RenderBasin::Program::setAllUniforms ( const Anemone A) const
pure virtual

Set all uniform variables.

To be called shortly before drawing once a Program's use has been established.

To be implemented by the graphic implementation such as GLvish via GLProgram .

Implemented in Wizt::GLProgram.

◆ SourceHasChanged()

bool Wizt::RenderBasin::Program::SourceHasChanged ( ) const

Check if any of the registered source files (mySources) has changed.

If any source is newer, then it needs to be explicitly modified by accessing the mySources list.

References MemCore::Filetime::str().

Member Data Documentation

◆ SilentlyIgnoreUnknownUniforms

bool Wizt::RenderBasin::Program::SilentlyIgnoreUnknownUniforms

Throw a RenderException if a variable is set that is not used in the program.

If this boolean is set to true, then assignments to non existent uniform variables are silently ignored. Note that a shader program may well contain uniform variables in its source code, but they may vanish during optimized compilation. Setting this flag allows to still assign such removed variables. The default value is false.

Referenced by Wizt::GLProgram::setAllUniforms().

◆ Textures

NamedTextures_t Wizt::RenderBasin::Program::Textures

A set of named textures to be used in this Program.

They must be added to the Anemone in order to be usable since here we only store weak references and the textures are not enabled (this is done by the Anemone).

For any tentacle returning a non-negative getTextureUnit(), it will be set as uniform variable by the shader.

Referenced by Wizt::GLProgram::setAllUniforms().