VISH  0.2
Static Public Member Functions
Wizt::GLColormap Struct Reference

A colormap can be used in two ways: as 1D texture, or as colortable. More...

#include </home/werner/origo/vish/ocean/GLvish/VGLColormap.hpp>

List of all members.

Static Public Member Functions


Detailed Description

A colormap can be used in two ways: as 1D texture, or as colortable.

Which method to use depends on the usage scenario:

Activate this colormap in specified shader program under the given name and specified texture unit.

Typical usage scenario:

static const char fragmentshader_src[] =
"\n"
//Reference to the 1D texture that store the colormap
"uniform sampler1D ColormapTexture;\n"
"\n"
"void main (void)\n"
"{\n"
"       gl_FragColor = texture1D(ColormapTexture, gl_TexCoord[1].r );\n"
"}\n"
;
void MyObject::render(VRenderContext&Context) const
{
VColormap Cmap; 
        myColormap << Context >> Cmap;

RefPtr<ValueSet> CmapValues = new ValueSet(myColormap(Context) );
        TextureCreator&TC = Context[ *myState ][ this ][ CmapValues ]( TEXTURE() );

RefPtr<GLTexture1D> CmapTexture = Cmap->Enable(TC, 1);

        try
        {
        RefPtr<Program> MyProgram  = new Program(colormap_vertex_shader, colormap_fragment_shader); 
                MyProgram->setUniformTexture( "ColormapTexture"  , *CmapTexture);


                ... RENDER CODE ...

        }
        catch(const Program::Error&E)
        {
                E.print("Compiled program not usable");
        }
}

This example uses the GLCache of the VRenderContext to store the textures. A colormap requires an OpenGL texture to store its values. This texture needs to be stored somewhere. In theory, it could also be stored in the object's local State object. This would work well when the program is run, but the problem occurs during destruction: The texture object needs to be destroyed within an OpenGL context, but the VObject's local state doesn't have one. The GLCache however will be destructed in an OpenGL context and therefore must be used for proper clean up. Otherwise, the application will terminate with a segfault when closing.

See also:
Colorizer::getColormap()

Member Function Documentation

void Wizt::GLColormap::Disable ( const RefPtr< Colormap > &  Cmap) [static]

Disable this colormap, i.e.

switch off Colortable mode.

bool Wizt::GLColormap::Enable ( const RefPtr< Colormap > &  Cmap,
const RefPtr< GLTexture1D > &  CmapTexture,
const bool  clampP = true 
) [static]

Enable this colormap, as 1D texture or as colortable.

Parameters:
Cmap1DIf a valid pointer, set the colormap as 1D texture, otherwise as a colortable.
clampPclamp values, not repeating
Note:
If the colormap is set via a colortable, then the PixelTransfer() may be applied elsewhere. It affects subsequent operations of loading a texture. Binding an existing texture will however not be affected by the colormap then, it is required to reload the texture.
RefPtr< GLTexture1D > Wizt::GLColormap::Enable ( const RefPtr< Colormap > &  Cmap,
TextureCreator CmapTC,
int  TextureUnit,
const bool  clampP = true 
) [static]

Activate a 1D texture from the virtual color values and put these into the specified texture creator.

Parameters:
CmapTCThe Texture creator, as retrieved from an OpenGL Cache
TextureUnitThe Texture unit (OpenGL ActiveTexture) which is to be used for this texture.
clampPclamp values, not repeating

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