Overview     Modules     Class Hierarchy     Classes     Members  

tlp::GlShader Class Reference

#include <GlShaderProgram.h>

List of all members.


Detailed Description

A class to manage shader objects, components of a shader program.

This class allow to create and compile OpenGL shader object. Shaders are used to program the graphics processing unit (GPU) rendering pipeline. The three existing types of shaders are managed :

-> Vertex shader : run once for each vertex given to the graphics processor. The purpose is to transform each vertex's 3D position in virtual space to the 2D coordinate at which it appears on the screen (as well as a depth value for the Z-buffer). Vertex shaders can manipulate properties such as position, color, and texture coordinate, but cannot create new vertices. The output of the vertex shader goes to the next stage in the pipeline, which is either a geometry shader if present or the rasterizer otherwise.

-> Geometry shader : can add and remove vertices from a mesh. Geometry shaders can be used to generate geometry procedurally or to add volumetric detail to existing meshes that would be too costly to process on the CPU. If geometry shaders are being used, the output is then sent to the rasterizer.

-> Fragment shader (Pixel shader) : calculate the color of individual pixels. The input to this stage comes from the rasterizer, which fills in the polygons being sent through the graphics pipeline.

Shaders source codes have to be written with the "OpenGL Shading Language (GLSL)"

Public Member Functions

Friends


Constructor & Destructor Documentation

tlp::GlShader::GlShader ShaderType  shaderType  ) 
 

Vertex and Fragment shader constructor

Use this constructor to create either a vertex shader or a fragment shader

Parameters:
shaderType Type of the shader to create, Vertex or Fragment

tlp::GlShader::GlShader GLenum  inputPrimitiveType,
GLenum  outputPrimitiveType
 

Geometry shader constructor

Use this constructor to create a geometry shader

Parameters:
inputPrimitiveType the type of graphic primitive the geometry shader takes as input. (must be one from the following list : GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_EXT, GL_TRIANGLES, GL_TRIANGLES_ADJACENCY_EXT)
outputPrimitiveType the type of graphics primitives the geometry shader will output (must be one of the following list : GL_POINTS, GL_LINE_STRIP, GL_TRIANGLE_STRIP)

tlp::GlShader::~GlShader  ) 
 

GlShader destructor


Member Function Documentation

void tlp::GlShader::compileFromSourceCode const std::string &  shaderSrc  ) 
 

Set the shader source code from a C++ string and compile it.

Parameters:
shaderSrc a C++ string containing the shader source code

void tlp::GlShader::compileFromSourceCode const char *  shaderSrc  ) 
 

Set the shader source code from a C string and compile it.

Parameters:
shaderSrc a C string containing the shader source code

void tlp::GlShader::compileFromSourceFile const std::string &  shaderSrcFilename  ) 
 

Set the shader source code from a file and compile it.

Parameters:
shaderSrcFilename the absolute path of the file containing the shader source code

std::string tlp::GlShader::getCompilationLog  )  const [inline]
 

Return the log output by the shader compiler

GLenum tlp::GlShader::getInputPrimitiveType  )  const [inline]
 

Method only relevant for geometry shaders. Return the graphic primitive type this geometry shader takes as input.

GLenum tlp::GlShader::getOutputPrimitiveType  )  const [inline]
 

Method only relevant for geometry shaders. Return the graphics primitives type this geometry shader will output.

GLuint tlp::GlShader::getShaderId  )  const [inline]
 

Return the GL identifier of this shader object

ShaderType tlp::GlShader::getShaderType  )  const [inline]
 

Return the type of the shader (Vertex, Geometry or Fragment)

bool tlp::GlShader::isCompiled  )  const [inline]
 

Return true if the shader compilation was successfull, false otherwise

void tlp::GlShader::setInputPrimitiveType const GLenum  inputPrimitiveType  )  [inline]
 

Method only relevant for geometry shaders. Set the graphic primitive type this geometry shader takes as input. Note that when modifying the input primitive type, the associated shader program (whose object is from type GlShaderProgram) has to be relinked for changes to take effect.

Parameters:
inputPrimitiveType the type of graphic primitive the geometry shader takes as input. (must be one from the following list : GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_EXT, GL_TRIANGLES, GL_TRIANGLES_ADJACENCY_EXT)

void tlp::GlShader::setOutputPrimitiveType const GLenum  outputPrimitiveType  )  [inline]
 

Method only relevant for geometry shaders. Set the graphics primitives type this geometry shader will output. Note that when modifying the output primitive type, the associated shader program (whose object is from type GlShaderProgram) has to be relinked for changes to take effect.

Parameters:
outputPrimitiveType the type of graphics primitives the geometry shader will output (must be one of the following list : GL_POINTS, GL_LINE_STRIP, GL_TRIANGLE_STRIP)


Friends And Related Function Documentation

friend class GlShaderProgram [friend]
 



Tulip Software by LaBRI Visualization Team    2001 - 2010