# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

# vl::Shader Class Reference

Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects. More...

`#include <Shader.hpp>`

Inheritance diagram for vl::Shader:

List of all members.

## Public Member Functions

| Shader ()
virtual | ~Shader ()
virtual const char * | className ()
| Returns the name of the class.
GLSLProgram * | gocGLSLProgram ()
const GLSLProgram * | getGLSLProgram () const
GLSLProgram * | getGLSLProgram ()
PixelTransfer * | gocPixelTransfer ()
const PixelTransfer * | getPixelTransfer () const
PixelTransfer * | getPixelTransfer ()
Hint * | gocHint ()
const Hint * | getHint () const
Hint * | getHint ()
CullFace * | gocCullFace ()
const CullFace * | getCullFace () const
CullFace * | getCullFace ()
FrontFace * | gocFrontFace ()
const FrontFace * | getFrontFace () const
FrontFace * | getFrontFace ()
DepthFunc * | gocDepthFunc ()
const DepthFunc * | getDepthFunc () const
DepthFunc * | getDepthFunc ()
DepthMask * | gocDepthMask ()
const DepthMask * | getDepthMask () const
DepthMask * | getDepthMask ()
ColorMask * | gocColorMask ()
const ColorMask * | getColorMask () const
ColorMask * | getColorMask ()
PolygonMode * | gocPolygonMode ()
const PolygonMode * | getPolygonMode () const
PolygonMode * | getPolygonMode ()
ShadeModel * | gocShadeModel ()
const ShadeModel * | getShadeModel () const
ShadeModel * | getShadeModel ()
BlendEquation * | gocBlendEquation ()
const BlendEquation * | getBlendEquation () const
BlendEquation * | getBlendEquation ()
AlphaFunc * | gocAlphaFunc ()
const AlphaFunc * | getAlphaFunc () const
AlphaFunc * | getAlphaFunc ()
Material * | gocMaterial ()
const Material * | getMaterial () const
Material * | getMaterial ()
LightModel * | gocLightModel ()
const LightModel * | getLightModel () const
LightModel * | getLightModel ()
Fog * | gocFog ()
const Fog * | getFog () const
Fog * | getFog ()
PolygonOffset * | gocPolygonOffset ()
const PolygonOffset * | getPolygonOffset () const
PolygonOffset * | getPolygonOffset ()
LogicOp * | gocLogicOp ()
const LogicOp * | getLogicOp () const
LogicOp * | getLogicOp ()
DepthRange * | gocDepthRange ()
const DepthRange * | getDepthRange () const
DepthRange * | getDepthRange ()
LineWidth * | gocLineWidth ()
const LineWidth * | getLineWidth () const
LineWidth * | getLineWidth ()
PointSize * | gocPointSize ()
const PointSize * | getPointSize () const
PointSize * | getPointSize ()
LineStipple * | gocLineStipple ()
const LineStipple * | getLineStipple () const
LineStipple * | getLineStipple ()
PolygonStipple * | gocPolygonStipple ()
const PolygonStipple * | getPolygonStipple () const
PolygonStipple * | getPolygonStipple ()
PointParameter * | gocPointParameter ()
const PointParameter * | getPointParameter () const
PointParameter * | getPointParameter ()
StencilFunc * | gocStencilFunc ()
const StencilFunc * | getStencilFunc () const
StencilFunc * | getStencilFunc ()
StencilOp * | gocStencilOp ()
const StencilOp * | getStencilOp () const
StencilOp * | getStencilOp ()
StencilMask * | gocStencilMask ()
const StencilMask * | getStencilMask () const
StencilMask * | getStencilMask ()
BlendColor * | gocBlendColor ()
const BlendColor * | getBlendColor () const
BlendColor * | getBlendColor ()
BlendFunc * | gocBlendFunc ()
const BlendFunc * | getBlendFunc () const
BlendFunc * | getBlendFunc ()
SampleCoverage * | gocSampleCoverage ()
const SampleCoverage * | getSampleCoverage () const
SampleCoverage * | getSampleCoverage ()
Light * | gocLight (int light_index)
const Light * | getLight (int light_index) const
Light * | getLight (int light_index)
ClipPlane * | gocClipPlane (int plane_index)
const ClipPlane * | getClipPlane (int plane_index) const
ClipPlane * | getClipPlane (int plane_index)
TextureUnit * | gocTextureUnit (int unit_index)
const TextureUnit * | getTextureUnit (int unit_index) const
TextureUnit * | getTextureUnit (int unit_index)
TexEnv * | gocTexEnv (int unit_index)
const TexEnv * | getTexEnv (int unit_index) const
TexEnv * | getTexEnv (int unit_index)
TexGen * | gocTexGen (int unit_index)
const TexGen * | getTexGen (int unit_index) const
TexGen * | getTexGen (int unit_index)
TextureMatrix * | gocTextureMatrix (int unit_index)
const TextureMatrix * | getTextureMatrix (int unit_index) const
TextureMatrix * | getTextureMatrix (int unit_index)
void | reset ()
void | enable (EEnable capability)
void | disable (EEnable capability)
const std::vector< EEnable > & | enables () const
int | isEnabled (EEnable capability) const
void | disableAll ()
bool | blendingEnabled () const
void | setRenderState (RenderState *renderstate)
const RenderState * | renderState (ERenderState type) const
RenderState * | renderState (ERenderState type)
const std::vector< ref < RenderState > > & | renderStates () const
void | eraseRenderState (ERenderState type)
void | eraseRenderState (RenderState *rs)
void | eraseAllRenderStates ()
const GLSLProgram * | glslProgram () const
| Returns the GLSLProgram associated to a Shader (if any).
GLSLProgram * | glslProgram ()
| Returns the GLSLProgram associated to a Shader (if any).
void | setUniform (Uniform *uniform)
| Equivalent to gocUniformSet()->setUniform(...).
const std::vector< ref < Uniform > > & | uniforms () const
| Equivalent to gocUniformSet()->uniforms(...).
void | eraseUniform (const std::string &name)
| Equivalent to gocUniformSet()->eraseUniform(...).
void | eraseUniform (const Uniform *uniform)
| Equivalent to gocUniformSet()->eraseUniform(...).
void | eraseAllUniforms ()
| Equivalent to gocUniformSet()->eraseAllUniforms(...).
Uniform * | gocUniform (const std::string &name)
| Equivalent to gocUniformSet()->gocUniform(...).
Uniform * | getUniform (const std::string &name)
| Equivalent to gocUniformSet()->getUniform(...).
const Uniform * | getUniform (const std::string &name) const
| Equivalent to gocUniformSet()->getUniform(...).
EnableSet * | gocEnableSet ()
EnableSet * | getEnableSet ()
const EnableSet * | getEnableSet () const
RenderStateSet * | gocRenderStateSet ()
RenderStateSet * | getRenderStateSet ()
const RenderStateSet * | getRenderStateSet () const
UniformSet * | gocUniformSet ()
| Returns the UniformSet installed (creating it if no UniformSet has been installed).
UniformSet * | getUniformSet ()
| Returns the UniformSet installed.
const UniformSet * | getUniformSet () const
| Returns the UniformSet installed.
void | setEnableSet (EnableSet *es)
void | setRenderStateSet (RenderStateSet *rss)
void | setUniformSet (UniformSet *us)
| Installs a new UniformSet.
void | setScissor (Scissor *scissor)
| Sets the Scissor to be used when rendering an Actor.
const Scissor * | scissor () const
| Returns the Scissor to be used when rendering an Actor.
Scissor * | scissor ()
| Returns the Scissor to be used when rendering an Actor.
virtual void | update (Camera *camera, Real cur_t)
| Virtual function used to update or animate a Shader during the rendering.
void | setLastUpdateTime (Real time)
| Used internally.
Real | lastUpdateTime () const
| Used internally.
void | initResources ()

## Protected Attributes

Real | mLastUpdateTime
ref< RenderStateSet > | mRenderStateSet
ref< EnableSet > | mEnableSet
ref< UniformSet > | mUniformSet
ref< Scissor > | mScissor

## Detailed Description

Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects.

A Shader represents a rendering pass. Using the Effect class you can assign more rendering passes to an Actor. You can also specify different sets of rendering passes for each Effect LOD, for more information see Effect.

Remarks:
  The Uniforms defined in the Actor and the ones defined in the Shader must not overlap, that is, an Actor must not define Uniforms present in the Shader and vice versa.

See also:
  Effect, Actor

## Constructor & Destructor Documentation

Shader::Shader | ( |  | ) |

Shader::~Shader | ( |  | ) | `[virtual]`

## Member Function Documentation

virtual const char* vl::Shader::className | ( |  | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Object.

GLSLProgram * Shader::gocGLSLProgram | ( |  | ) |

const GLSLProgram* vl::Shader::getGLSLProgram | ( |  | ) | const`[inline]`

GLSLProgram* vl::Shader::getGLSLProgram | ( |  | ) | `[inline]`

PixelTransfer * Shader::gocPixelTransfer | ( |  | ) |

const PixelTransfer* vl::Shader::getPixelTransfer | ( |  | ) | const`[inline]`

PixelTransfer* vl::Shader::getPixelTransfer | ( |  | ) | `[inline]`

Hint * Shader::gocHint | ( |  | ) |

const Hint* vl::Shader::getHint | ( |  | ) | const`[inline]`

Hint* vl::Shader::getHint | ( |  | ) | `[inline]`

CullFace * Shader::gocCullFace | ( |  | ) |

const CullFace* vl::Shader::getCullFace | ( |  | ) | const`[inline]`

CullFace* vl::Shader::getCullFace | ( |  | ) | `[inline]`

FrontFace * Shader::gocFrontFace | ( |  | ) |

const FrontFace* vl::Shader::getFrontFace | ( |  | ) | const`[inline]`

FrontFace* vl::Shader::getFrontFace | ( |  | ) | `[inline]`

DepthFunc * Shader::gocDepthFunc | ( |  | ) |

const DepthFunc* vl::Shader::getDepthFunc | ( |  | ) | const`[inline]`

DepthFunc* vl::Shader::getDepthFunc | ( |  | ) | `[inline]`

DepthMask * Shader::gocDepthMask | ( |  | ) |

const DepthMask* vl::Shader::getDepthMask | ( |  | ) | const`[inline]`

DepthMask* vl::Shader::getDepthMask | ( |  | ) | `[inline]`

ColorMask * Shader::gocColorMask | ( |  | ) |

const ColorMask* vl::Shader::getColorMask | ( |  | ) | const`[inline]`

ColorMask* vl::Shader::getColorMask | ( |  | ) | `[inline]`

PolygonMode * Shader::gocPolygonMode | ( |  | ) |

const PolygonMode* vl::Shader::getPolygonMode | ( |  | ) | const`[inline]`

PolygonMode* vl::Shader::getPolygonMode | ( |  | ) | `[inline]`

ShadeModel * Shader::gocShadeModel | ( |  | ) |

const ShadeModel* vl::Shader::getShadeModel | ( |  | ) | const`[inline]`

ShadeModel* vl::Shader::getShadeModel | ( |  | ) | `[inline]`

BlendEquation * Shader::gocBlendEquation | ( |  | ) |

const BlendEquation* vl::Shader::getBlendEquation | ( |  | ) | const`[inline]`

BlendEquation* vl::Shader::getBlendEquation | ( |  | ) | `[inline]`

AlphaFunc * Shader::gocAlphaFunc | ( |  | ) |

const AlphaFunc* vl::Shader::getAlphaFunc | ( |  | ) | const`[inline]`

AlphaFunc* vl::Shader::getAlphaFunc | ( |  | ) | `[inline]`

Material * Shader::gocMaterial | ( |  | ) |

const Material* vl::Shader::getMaterial | ( |  | ) | const`[inline]`

Material* vl::Shader::getMaterial | ( |  | ) | `[inline]`

LightModel * Shader::gocLightModel | ( |  | ) |

const LightModel* vl::Shader::getLightModel | ( |  | ) | const`[inline]`

LightModel* vl::Shader::getLightModel | ( |  | ) | `[inline]`

Fog * Shader::gocFog | ( |  | ) |

const Fog* vl::Shader::getFog | ( |  | ) | const`[inline]`

Fog* vl::Shader::getFog | ( |  | ) | `[inline]`

PolygonOffset * Shader::gocPolygonOffset | ( |  | ) |

const PolygonOffset* vl::Shader::getPolygonOffset | ( |  | ) | const`[inline]`

PolygonOffset* vl::Shader::getPolygonOffset | ( |  | ) | `[inline]`

LogicOp * Shader::gocLogicOp | ( |  | ) |

const LogicOp* vl::Shader::getLogicOp | ( |  | ) | const`[inline]`

LogicOp* vl::Shader::getLogicOp | ( |  | ) | `[inline]`

DepthRange * Shader::gocDepthRange | ( |  | ) |

const DepthRange* vl::Shader::getDepthRange | ( |  | ) | const`[inline]`

DepthRange* vl::Shader::getDepthRange | ( |  | ) | `[inline]`

LineWidth * Shader::gocLineWidth | ( |  | ) |

const LineWidth* vl::Shader::getLineWidth | ( |  | ) | const`[inline]`

LineWidth* vl::Shader::getLineWidth | ( |  | ) | `[inline]`

PointSize * Shader::gocPointSize | ( |  | ) |

const PointSize* vl::Shader::getPointSize | ( |  | ) | const`[inline]`

PointSize* vl::Shader::getPointSize | ( |  | ) | `[inline]`

LineStipple * Shader::gocLineStipple | ( |  | ) |

const LineStipple* vl::Shader::getLineStipple | ( |  | ) | const`[inline]`

LineStipple* vl::Shader::getLineStipple | ( |  | ) | `[inline]`

PolygonStipple * Shader::gocPolygonStipple | ( |  | ) |

const PolygonStipple* vl::Shader::getPolygonStipple | ( |  | ) | const`[inline]`

PolygonStipple* vl::Shader::getPolygonStipple | ( |  | ) | `[inline]`

PointParameter * Shader::gocPointParameter | ( |  | ) |

const PointParameter* vl::Shader::getPointParameter | ( |  | ) | const`[inline]`

PointParameter* vl::Shader::getPointParameter | ( |  | ) | `[inline]`

StencilFunc * Shader::gocStencilFunc | ( |  | ) |

const StencilFunc* vl::Shader::getStencilFunc | ( |  | ) | const`[inline]`

StencilFunc* vl::Shader::getStencilFunc | ( |  | ) | `[inline]`

StencilOp * Shader::gocStencilOp | ( |  | ) |

const StencilOp* vl::Shader::getStencilOp | ( |  | ) | const`[inline]`

StencilOp* vl::Shader::getStencilOp | ( |  | ) | `[inline]`

StencilMask * Shader::gocStencilMask | ( |  | ) |

const StencilMask* vl::Shader::getStencilMask | ( |  | ) | const`[inline]`

StencilMask* vl::Shader::getStencilMask | ( |  | ) | `[inline]`

BlendColor * Shader::gocBlendColor | ( |  | ) |

const BlendColor* vl::Shader::getBlendColor | ( |  | ) | const`[inline]`

BlendColor* vl::Shader::getBlendColor | ( |  | ) | `[inline]`

BlendFunc * Shader::gocBlendFunc | ( |  | ) |

const BlendFunc* vl::Shader::getBlendFunc | ( |  | ) | const`[inline]`

BlendFunc* vl::Shader::getBlendFunc | ( |  | ) | `[inline]`

SampleCoverage * Shader::gocSampleCoverage | ( |  | ) |

const SampleCoverage* vl::Shader::getSampleCoverage | ( |  | ) | const`[inline]`

SampleCoverage* vl::Shader::getSampleCoverage | ( |  | ) | `[inline]`

Light * Shader::gocLight | ( | int | light_index | ) |

const Light* vl::Shader::getLight | ( | int | light_index | ) | const`[inline]`

Light* vl::Shader::getLight | ( | int | light_index | ) | `[inline]`

ClipPlane * Shader::gocClipPlane | ( | int | plane_index | ) |

const ClipPlane* vl::Shader::getClipPlane | ( | int | plane_index | ) | const`[inline]`

ClipPlane* vl::Shader::getClipPlane | ( | int | plane_index | ) | `[inline]`

TextureUnit * Shader::gocTextureUnit | ( | int | unit_index | ) |

const TextureUnit* vl::Shader::getTextureUnit | ( | int | unit_index | ) | const`[inline]`

TextureUnit* vl::Shader::getTextureUnit | ( | int | unit_index | ) | `[inline]`

TexEnv * Shader::gocTexEnv | ( | int | unit_index | ) |

const TexEnv* vl::Shader::getTexEnv | ( | int | unit_index | ) | const`[inline]`

TexEnv* vl::Shader::getTexEnv | ( | int | unit_index | ) | `[inline]`

TexGen * Shader::gocTexGen | ( | int | unit_index | ) |

const TexGen* vl::Shader::getTexGen | ( | int | unit_index | ) | const`[inline]`

TexGen* vl::Shader::getTexGen | ( | int | unit_index | ) | `[inline]`

TextureMatrix * Shader::gocTextureMatrix | ( | int | unit_index | ) |

const TextureMatrix* vl::Shader::getTextureMatrix | ( | int | unit_index | ) | const`[inline]`

TextureMatrix* vl::Shader::getTextureMatrix | ( | int | unit_index | ) | `[inline]`

void vl::Shader::reset | ( |  | ) | `[inline]`

void vl::Shader::enable | ( | EEnable | capability | ) | `[inline]`

void vl::Shader::disable | ( | EEnable | capability | ) | `[inline]`

const std::vector<EEnable>& vl::Shader::enables | ( |  | ) | const`[inline]`

int vl::Shader::isEnabled | ( | EEnable | capability | ) | const`[inline]`

void vl::Shader::disableAll | ( |  | ) | `[inline]`

bool vl::Shader::blendingEnabled | ( |  | ) | const`[inline]`

void vl::Shader::setRenderState | ( | RenderState * | renderstate | ) | `[inline]`

const RenderState* vl::Shader::renderState | ( | ERenderState | type | ) | const`[inline]`

RenderState* vl::Shader::renderState | ( | ERenderState | type | ) | `[inline]`

const std::vector< ref<RenderState> >& vl::Shader::renderStates | ( |  | ) | const`[inline]`

void vl::Shader::eraseRenderState | ( | ERenderState | type | ) | `[inline]`

void vl::Shader::eraseRenderState | ( | RenderState * | rs | ) | `[inline]`

void vl::Shader::eraseAllRenderStates | ( |  | ) | `[inline]`

const GLSLProgram* vl::Shader::glslProgram | ( |  | ) | const`[inline]`

Returns the GLSLProgram associated to a Shader (if any).

GLSLProgram* vl::Shader::glslProgram | ( |  | ) | `[inline]`

Returns the GLSLProgram associated to a Shader (if any).

void vl::Shader::setUniform | ( | Uniform * | uniform | ) | `[inline]`

Equivalent to gocUniformSet()->setUniform(...).

const std::vector< ref<Uniform> >& vl::Shader::uniforms | ( |  | ) | const`[inline]`

Equivalent to gocUniformSet()->uniforms(...).

void vl::Shader::eraseUniform | ( | const std::string & | name | ) | `[inline]`

Equivalent to gocUniformSet()->eraseUniform(...).

void vl::Shader::eraseUniform | ( | const Uniform * | uniform | ) | `[inline]`

Equivalent to gocUniformSet()->eraseUniform(...).

void vl::Shader::eraseAllUniforms | ( |  | ) | `[inline]`

Equivalent to gocUniformSet()->eraseAllUniforms(...).

Uniform* vl::Shader::gocUniform | ( | const std::string & | name | ) | `[inline]`

Equivalent to gocUniformSet()->gocUniform(...).

Uniform* vl::Shader::getUniform | ( | const std::string & | name | ) | `[inline]`

Equivalent to gocUniformSet()->getUniform(...).

const Uniform* vl::Shader::getUniform | ( | const std::string & | name | ) | const`[inline]`

Equivalent to gocUniformSet()->getUniform(...).

EnableSet* vl::Shader::gocEnableSet | ( |  | ) | `[inline]`

EnableSet* vl::Shader::getEnableSet | ( |  | ) | `[inline]`

const EnableSet* vl::Shader::getEnableSet | ( |  | ) | const`[inline]`

RenderStateSet* vl::Shader::gocRenderStateSet | ( |  | ) | `[inline]`

RenderStateSet* vl::Shader::getRenderStateSet | ( |  | ) | `[inline]`

const RenderStateSet* vl::Shader::getRenderStateSet | ( |  | ) | const`[inline]`

UniformSet* vl::Shader::gocUniformSet | ( |  | ) | `[inline]`

Returns the UniformSet installed (creating it if no UniformSet has been installed).

See also:
  - setUniform()
  - uniforms()
  - eraseUniform(const std::string& name)
  - eraseUniform(const Uniform* uniform)
  - eraseAllUniforms()
  - getUniform()

UniformSet* vl::Shader::getUniformSet | ( |  | ) | `[inline]`

Returns the UniformSet installed.

See also:
  - setUniform()
  - uniforms()
  - eraseUniform(const std::string& name)
  - eraseUniform(const Uniform* uniform)
  - eraseAllUniforms()
  - getUniform()

const UniformSet* vl::Shader::getUniformSet | ( |  | ) | const`[inline]`

Returns the UniformSet installed.

See also:
  - setUniform()
  - uniforms()
  - eraseUniform(const std::string& name)
  - eraseUniform(const Uniform* uniform)
  - eraseAllUniforms()
  - getUniform()

void vl::Shader::setEnableSet | ( | EnableSet * | es | ) | `[inline]`

void vl::Shader::setRenderStateSet | ( | RenderStateSet * | rss | ) | `[inline]`

void vl::Shader::setUniformSet | ( | UniformSet * | us | ) | `[inline]`

Installs a new UniformSet.

See also:
  - setUniform()
  - uniforms()
  - eraseUniform(const std::string& name)
  - eraseUniform(const Uniform* uniform)
  - eraseAllUniforms()
  - getUniform()

void vl::Shader::setScissor | ( | Scissor * | scissor | ) | `[inline]`

Sets the Scissor to be used when rendering an Actor.

Note:
  You can also define a Scissor on a per-Actor basis using the function Actor::setScissor(). In case both the Shader's and the Actor's Scissor are defined the Actor's Scissor is used.

See also:
  - Scissor
  - Actor::setScissor()

const Scissor* vl::Shader::scissor | ( |  | ) | const`[inline]`

Returns the Scissor to be used when rendering an Actor.

See also:
  - Scissor
  - Shader::setScissor()
  - Actor::setScissor()

Scissor* vl::Shader::scissor | ( |  | ) | `[inline]`

Returns the Scissor to be used when rendering an Actor.

See also:
  - Scissor
  - Shader::setScissor()
  - Actor::setScissor()

virtual void vl::Shader::update | ( | Camera * | camera,
|  | Real | cur_t |
| ) |  |  | `[inline, virtual]`

Virtual function used to update or animate a Shader during the rendering.

Parameters:

  | camera | the camera used for the current rendering.
  | cur_t | the current animation time.

void vl::Shader::setLastUpdateTime | ( | Real | time | ) | `[inline]`

Used internally.

Real vl::Shader::lastUpdateTime | ( |  | ) | const`[inline]`

Used internally.

void vl::Shader::initResources | ( |  | ) | `[inline]`

## Member Data Documentation

Real vl::Shader::mLastUpdateTime`[protected]`

ref<RenderStateSet> vl::Shader::mRenderStateSet`[protected]`

ref<EnableSet> vl::Shader::mEnableSet`[protected]`

ref<UniformSet> vl::Shader::mUniformSet`[protected]`

ref<Scissor> vl::Shader::mScissor`[protected]`

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

- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/Shader.hpp
- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/Shader.cpp

Visualization Library v2009.07 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Mon Aug 10 21:41:42 2009.
Permission is granted to use this page to write and publish articles regarding Visualization Library.