A helper class that supports rendering of a collection of fragments from various fields. More...
#include <FragmentPainter.hpp>
A helper class that supports rendering of a collection of fragments from various fields.
A collection of fragments may be all data sets of a fragmented field, as well as some subset of such that is determined by a FragmentSelector. For each geometrical region, there may be multiple fields available (as specified by the VertexFieldCollection), which are all shuffled to a collection of Vertex Buffer Object, ready to be used by some fragment shader that needs to be implemented in a child class.
Within the fragment shader, the respective field data will be available as arrays under the names under which they are stored in the VertexFieldCollection . For instance, the constructor of a child class would contain the following line:
(*this)["normalvectors"] = new VBOField<TypedNormalArray<Eagle::tvector3> >(this, "vectorfield");
It defines that the child class will use some input field named "vectorfield" that is provided to the fragment shader under the name "normalvectors".
Via the FragmentSelector this class also supports selective drawing of regions of interest.
RefPtr< ValueSet > Wizt::FragmentPainter::CacheableVariables | ( | const RefPtr< ValuePool > & | Context | ) | const [virtual] |
Return a set of variables for which the results shall be cached, i.e.
there resides an OpenGL object for each state of each of those variables. They are all kept in memory until the cache is full. A typical example are fields. So when the user switches from one field to another field, and back to the first one, the OpenGL object does not need to be recomputed again, but is retrieved from the Cache. A typical counter example is a floating point value, since that one has an infinite number of possibilities. And it is unlikely that a user will accidentally switch back to an old value of a float slider, thus caching relative to float values is not reasonable. It is still possible, however, and could make sense if float values are rounded.
A typical implementation of this function, assuming two slots "MyGrid" and "MyField") looks like this:
RefPtr<ValueSet> CacheableVariables(const RefPtr<ValuePool>&Context) const { RefPtr<ValueSet> retval = new ValueSet( MyGrid(Context) ); *retval << (*MyField)(Context); return retval; }
Reimplemented in Wizt::VertexRenderObject.
string Wizt::FragmentPainter::FragmentSelectionField | ( | ) | const [virtual] |
Return the name of the field that will be responsible for the coordinates of the fields.
By default, this will be "Positions".
Referenced by GLCacheField(), and renderFragments().
string Wizt::FragmentPainter::GLCacheField | ( | const RefPtr< ValuePool > & | Context | ) | const [virtual] |
The name of the field that will be used for caching opengl VBO's at each of this fragments.
This is a temporary workaround. It will NOT work correctly if a VBO depends on multiple fields. The VBO will only change if the GLCacheField changes (ie., its fragments).
The will be ONE VBO per fragment of this GLCacheField.
Per default, this will be the FragmentSelectionField().
If a rendering method implements a vector field visualization of Grid that does not change, then this function would refer to the name of that vector field. However, if the coordinates changes but not the vector field, it will still display the same. This needs to be reworked.
Reimplemented in VectorViz::VectorSpeckle.
References FragmentSelectionField().
void Wizt::FragmentPainter::setRendererParameters | ( | VGLRenderContext & | Context, | |
const RefPtr< VBO::Renderer > & | theRenderer, | |||
const RefPtr< CreativeArrayBase > & | VertexCoordinates, | |||
const RefPtr< GLProgram > & | theShaderProgram | |||
) | const [virtual] |
Given a Renderer, which usually is has been created by the createRenderer() virtual function, modify its parameters, depending on the context.
In contrast to the cacheable variables (see CacheableVariables() ), these parameters that are modified here do not require re-creation of a VBO object. This function will be called just before the VBO object is called to re-render the already loaded data.
theShaderProgram | The Program which will be used for rendering. It will be null if no Shader Program is used. |
Reimplemented in Wizt::SplatRenderObject.