Vis 2 Demo  1.0
Technical illustration type real-time rendering of geometry
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
vis2::Shader Class Reference

This class converts text files into compiled shader programs. More...

Public Member Functions

 Shader (const std::string &_vertexShader, const std::string &_fragmentShader)
 Constructor. More...
 
 ~Shader ()
 Destructor. More...
 
void useShader ()
 Instructs OpenGL to use this shader for rendering. More...
 
void releaseShader ()
 Instructs OpenGL to use the default pipeline for rendering. More...
 
bool shaderInUse () const
 Returns true if the shader has been bound, false otherwise. More...
 

Public Attributes

GLuint program_handle
 handle to the linked shader program More...
 

Private Member Functions

void loadShader (const std::string &_path_to_shader, GLenum _shaderType, GLuint &_shaderHandle)
 Creates a shader object out of a text file. More...
 
void link ()
 Links the vertex and fragment shaders to one program. More...
 

Private Attributes

GLuint vertex_shader_handle
 handle to the vertex shader object More...
 
GLuint fragment_shader_handle
 handle to the fragment shader object More...
 
bool shader_in_use
 is true when the shader program is bound, false otherwise More...
 

Detailed Description

This class converts text files into compiled shader programs.

Definition at line 10 of file Shader.h.

Constructor & Destructor Documentation

Shader::Shader ( const std::string &  _vertexShader,
const std::string &  _fragmentShader 
)

Constructor.

Loads the shader onto the GK by creating a program out of
the vertex and fragment shaders:

Parameters
[in]_vertexShader
[in]_fragmentShader

Definition at line 7 of file Shader.cpp.

Shader::~Shader ( )

Destructor.

Deletes both shader handles and the program handle.

Definition at line 29 of file Shader.cpp.

Member Function Documentation

void Shader::link ( )
private

Links the vertex and fragment shaders to one program.

It is called in the constructor.

Definition at line 103 of file Shader.cpp.

void Shader::loadShader ( const std::string &  _path_to_shader,
GLenum  _shaderType,
GLuint &  _shaderHandle 
)
private

Creates a shader object out of a text file.

Parameters
[in]_path_to_shadercontains the path to the source code file of the shader.
[in]_shaderTypemarks the shader as vertex or fragment shader.
[out]_shaderHandleis a handle to the compiled shader on the GK.
It is called twice for the vertex and the fragment shaders in the constructor.

Definition at line 48 of file Shader.cpp.

void Shader::releaseShader ( )

Instructs OpenGL to use the default pipeline for rendering.

Definition at line 42 of file Shader.cpp.

bool vis2::Shader::shaderInUse ( ) const
inline

Returns true if the shader has been bound, false otherwise.

Definition at line 32 of file Shader.h.

void Shader::useShader ( )

Instructs OpenGL to use this shader for rendering.

Definition at line 36 of file Shader.cpp.

Member Data Documentation

GLuint vis2::Shader::fragment_shader_handle
private

handle to the fragment shader object

Definition at line 57 of file Shader.h.

GLuint vis2::Shader::program_handle

handle to the linked shader program

Definition at line 34 of file Shader.h.

bool vis2::Shader::shader_in_use
private

is true when the shader program is bound, false otherwise

Definition at line 59 of file Shader.h.

GLuint vis2::Shader::vertex_shader_handle
private

handle to the vertex shader object

Definition at line 56 of file Shader.h.


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