The Vish Visualization Shell 0.3
Vish
Public Member Functions | List of all members
Wizt::VRenderOptionUpdater< T > Struct Template Reference

When dealing with Render Anemones, it is frequent that the Anemone does not need to be re-created with each change of inputs. More...

#include <ocean/Anemonia/VRenderOptionUpdater.hpp>

Inheritance diagram for Wizt::VRenderOptionUpdater< T >:
Wizt::RenderBasin::RenderParameter::Updater MemCore::ReferenceBase< Updater >

Public Member Functions

bool updateValue (VRenderContext &Context, RenderBasin::RenderParameter &RP) override
 Virtual update function that is called from Anemone::updateValues().
 
- Public Member Functions inherited from MemCore::ReferenceBase< Updater >
auto getObjectCountID () const noexcept
 Get a unique ID for this object in the given domain.
 
bool isIdentical (const WeakPtr< Updater, Updater > &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 (Updater *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.
 

Additional Inherited Members

- Public Types inherited from MemCore::ReferenceBase< Updater >
using reference_domain_t = Updater
 The type of the base class.
 
using SelfPtr_t = WeakPtr< Updater, Updater >
 Type for a pointer to this object itself.
 
- Protected Member Functions inherited from MemCore::ReferenceBase< Updater >
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

template<typename T>
struct Wizt::VRenderOptionUpdater< T >

When dealing with Render Anemones, it is frequent that the Anemone does not need to be re-created with each change of inputs.

Some input parameters only need to modify part of the render anemone, for instance a uniform parameter or a rendering flag. Class RenderBasin::RenderParameter::Updater provides a mechanism to ease this process.

Each render tentacle can be equipped with an updater object, which are child classes of RenderBasin::RenderParameter::Updater implementing the virtual member function

A set of variable names, with indices associated to each type.
Definition Context.hpp:18
A pointer class which behaves like native C++ pointers, but knows about the lifetime of the reference...
Definition RefPtr.hpp:82
Base class for render parameters, which are Anemone::Tentacle instances that implement an updateValue...
Definition RenderBasin.hpp:1679
bool updateValue(VRenderContext &Context, RenderBasin::RenderParameter &RP) override
Virtual update function that is called from Anemone::updateValues().
Definition VRenderOptionUpdater.hpp:84

Such child classes will usually host a copy of the input slot and call the render parameter's modify() member function.

Class VRenderOptionUpdater allows to modify render parameter depending on whether some flag is set in the options or not. The type of these render parametes is flexible and specified as the template parameters, the value of these parameters and the name of te flag to be tested is given in the constructor.

The following code is an example how to read a flag from some options and to schedule modification of the render anemone (used in Heightfield.cpp and elsewhere):

VRenderObject class member definition:

in<Options> tsOptions;

VRenderObject constructor:

, tsOptions(this, "options", Options("-wireframe") )
FlagList Options
Input type for a list of flags.
Definition VFlagList.hpp:91

Code fragment in the render() function, provided an Anemone:

Anemone&RenderAnemone;
Options myOptions;
tsOptions << Context >> myOptions;
PolygonMode = Context.createRenderParameter( "glPolygonMode", myOptions("wireframe")?1:2 );
PolygonMode->myUpdater = new VRenderOptionUpdater<int>( tsOptions, "wireframe", 1, 2 );
RenderAnemone.insert( PolygonMode );
A reference counting pointer class which keeps objects alive as long as strong pointers to these obje...
Definition RefPtr.hpp:405
Abstract object for elementary render objects.
Definition Anemone.hpp:39
MemCore::WeakPtr< Tentacle > insert(const MemCore::WeakPtr< Tentacle > &T, int OrderDeviation=0)
Insert a specialized Tentacle to this Anemone, returns pointer to the given tentacle if insertion was...
Definition Anemone.hpp:455
A set of strings associated with a boolean, good to store true/false properties for each string.
Definition VFlagList.hpp:20
When dealing with Render Anemones, it is frequent that the Anemone does not need to be re-created wit...
Definition VRenderOptionUpdater.hpp:71

Then, somewhere in the code elsewhere when an existing render anemone is retrieved and ready to be re-used, there needs to be a call to

RenderAnemone.updateValues(Context);
bool updateValues(VRenderContext &Context) const
Update all tentacles with values relative to the given context.
Definition Anemone.cpp:481