sofa::helper::gl::GLSLShader Class Reference

#include <GLSLShader.h>

Collaboration diagram for sofa::helper::gl::GLSLShader:

Collaboration graph
[legend]

Public Member Functions

 GLSLShader ()
 ~GLSLShader ()
void AddHeader (const std::string &header)
 This builds a header before any shader contents.
void AddDefineMacro (const std::string &name, const std::string &value)
std::string LoadTextFile (const std::string &strFile)
 This loads our text file for each shader and returns it in a string.
void InitShaders (const std::string &strVertex, const std::string &stdGeometry, const std::string &strFragment)
 This loads a vertex, geometry and fragment shader.
void InitShaders (const std::string &strVertex, const std::string &strFragment)
 This loads a vertex and fragment shader.
GLint GetVariable (std::string strVariable)
 This returns an ID for a variable in our shader.
void Release ()
 This releases our memory for our shader.
GLint GetGeometryInputType ()
void SetGeometryInputType (GLint v)
GLint GetGeometryOutputType ()
void SetGeometryOutputType (GLint v)
GLint GetGeometryVerticesOut ()
void SetGeometryVerticesOut (GLint v)
GLhandleARB GetProgram ()
 These are our basic get functions for our private data.
GLhandleARB GetVertexS ()
GLhandleARB GetGeometryS ()
GLhandleARB GetFragmentS ()
void SetInt (GLint variable, int newValue)
 Below are functions to set an integer or a float.
void SetFloat (GLint variable, float newValue)
void SetInt2 (GLint variable, int i1, int i2)
 Below are functions to set more than 1 integer or float.
void SetInt3 (GLint variable, int i1, int i2, int i3)
void SetInt4 (GLint variable, int i1, int i2, int i3, int i4)
void SetFloat2 (GLint variable, float v0, float v1)
void SetFloat3 (GLint variable, float v0, float v1, float v2)
void SetFloat4 (GLint variable, float v0, float v1, float v2, float v3)
void SetIntVector (GLint variable, GLsizei count, const GLint *value)
 Below are functions to set a vector of integer or float.
void SetIntVector2 (GLint variable, GLsizei count, const GLint *value)
void SetIntVector3 (GLint variable, GLsizei count, const GLint *value)
void SetIntVector4 (GLint variable, GLsizei count, const GLint *value)
void SetFloatVector (GLint variable, GLsizei count, const float *value)
void SetFloatVector2 (GLint variable, GLsizei count, const float *value)
void SetFloatVector3 (GLint variable, GLsizei count, const float *value)
void SetFloatVector4 (GLint variable, GLsizei count, const float *value)
void TurnOn ()
 These 2 functions turn on and off our shader.
void TurnOff ()

Static Public Member Functions

static bool InitGLSL ()
 This is used to load all of the extensions and checks compatibility.

Protected Member Functions

bool CompileShader (GLint target, const std::string &source, GLhandleARB &shader)
 This function compiles a shader and check the log.

Protected Attributes

std::string header
GLhandleARB m_hVertexShader
 This handle stores our vertex shader information.
GLhandleARB m_hGeometryShader
 This handle stores our geometry shader information.
GLhandleARB m_hFragmentShader
 This handle stores our fragment shader information.
GLhandleARB m_hProgramObject
 This handle stores our program information which encompasses our shader.
GLint geometry_input_type
GLint geometry_output_type
GLint geometry_vertices_out

Detailed Description

Definition at line 50 of file GLSLShader.h.


Constructor & Destructor Documentation

sofa::helper::gl::GLSLShader::GLSLShader (  ) 

sofa::helper::gl::GLSLShader::~GLSLShader (  ) 

Definition at line 82 of file GLSLShader.cpp.


Member Function Documentation

void sofa::helper::gl::GLSLShader::AddDefineMacro ( const std::string &  name,
const std::string &  value 
)

Definition at line 94 of file GLSLShader.cpp.

References AddHeader().

Referenced by sofa::component::visualmodel::OglShader::addDefineMacro().

void sofa::helper::gl::GLSLShader::AddHeader ( const std::string &  header  ) 

This builds a header before any shader contents.

Definition at line 88 of file GLSLShader.cpp.

Referenced by AddDefineMacro().

bool sofa::helper::gl::GLSLShader::CompileShader ( GLint  target,
const std::string &  source,
GLhandleARB &  shader 
) [protected]

This function compiles a shader and check the log.

Definition at line 126 of file GLSLShader.cpp.

Referenced by InitShaders().

GLhandleARB sofa::helper::gl::GLSLShader::GetFragmentS (  )  [inline]

Definition at line 85 of file GLSLShader.h.

References m_hFragmentShader.

GLint sofa::helper::gl::GLSLShader::GetGeometryInputType (  )  [inline]

GLint sofa::helper::gl::GLSLShader::GetGeometryOutputType (  )  [inline]

GLhandleARB sofa::helper::gl::GLSLShader::GetGeometryS (  )  [inline]

Definition at line 84 of file GLSLShader.h.

References m_hGeometryShader.

GLint sofa::helper::gl::GLSLShader::GetGeometryVerticesOut (  )  [inline]

GLhandleARB sofa::helper::gl::GLSLShader::GetProgram (  )  [inline]

These are our basic get functions for our private data.

Definition at line 82 of file GLSLShader.h.

References m_hProgramObject.

GLint sofa::helper::gl::GLSLShader::GetVariable ( std::string  strVariable  ) 

GLhandleARB sofa::helper::gl::GLSLShader::GetVertexS (  )  [inline]

Definition at line 83 of file GLSLShader.h.

References m_hVertexShader.

bool sofa::helper::gl::GLSLShader::InitGLSL (  )  [static]

void sofa::helper::gl::GLSLShader::InitShaders ( const std::string &  strVertex,
const std::string &  strFragment 
) [inline]

This loads a vertex and fragment shader.

Definition at line 72 of file GLSLShader.h.

References InitShaders().

void sofa::helper::gl::GLSLShader::InitShaders ( const std::string &  strVertex,
const std::string &  stdGeometry,
const std::string &  strFragment 
)

This loads a vertex, geometry and fragment shader.

This function loads a vertex and fragment shader file.

Definition at line 159 of file GLSLShader.cpp.

References CompileShader(), geometry_input_type, geometry_output_type, geometry_vertices_out, header, LoadTextFile(), m_hFragmentShader, m_hGeometryShader, m_hProgramObject, m_hVertexShader, and Release().

Referenced by InitShaders(), and sofa::component::visualmodel::OglShader::initVisual().

std::string sofa::helper::gl::GLSLShader::LoadTextFile ( const std::string &  strFile  ) 

This loads our text file for each shader and returns it in a string.

This function loads and returns a text file for our shaders.

Definition at line 100 of file GLSLShader.cpp.

Referenced by InitShaders().

void sofa::helper::gl::GLSLShader::Release (  ) 

This releases our memory for our shader.

This function frees all of our shader data.

Definition at line 268 of file GLSLShader.cpp.

References m_hFragmentShader, m_hGeometryShader, m_hProgramObject, and m_hVertexShader.

Referenced by InitShaders(), and sofa::component::visualmodel::OglShader::~OglShader().

void sofa::helper::gl::GLSLShader::SetFloat ( GLint  variable,
float  newValue 
)

Definition at line 234 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setFloat().

void sofa::helper::gl::GLSLShader::SetFloat2 ( GLint  variable,
float  v0,
float  v1 
)

Definition at line 235 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setFloat2().

void sofa::helper::gl::GLSLShader::SetFloat3 ( GLint  variable,
float  v0,
float  v1,
float  v2 
)

Definition at line 236 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setFloat3().

void sofa::helper::gl::GLSLShader::SetFloat4 ( GLint  variable,
float  v0,
float  v1,
float  v2,
float  v3 
)

Definition at line 237 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setFloat4().

void sofa::helper::gl::GLSLShader::SetFloatVector ( GLint  variable,
GLsizei  count,
const float *  value 
)

void sofa::helper::gl::GLSLShader::SetFloatVector2 ( GLint  variable,
GLsizei  count,
const float *  value 
)

void sofa::helper::gl::GLSLShader::SetFloatVector3 ( GLint  variable,
GLsizei  count,
const float *  value 
)

void sofa::helper::gl::GLSLShader::SetFloatVector4 ( GLint  variable,
GLsizei  count,
const float *  value 
)

void sofa::helper::gl::GLSLShader::SetGeometryInputType ( GLint  v  )  [inline]

void sofa::helper::gl::GLSLShader::SetGeometryOutputType ( GLint  v  )  [inline]

void sofa::helper::gl::GLSLShader::SetGeometryVerticesOut ( GLint  v  )  [inline]

void sofa::helper::gl::GLSLShader::SetInt ( GLint  variable,
int  newValue 
)

Below are functions to set an integer or a float.

Definition at line 230 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setInt(), and sofa::component::visualmodel::OglShader::setTexture().

void sofa::helper::gl::GLSLShader::SetInt2 ( GLint  variable,
int  i1,
int  i2 
)

Below are functions to set more than 1 integer or float.

Definition at line 231 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setInt2().

void sofa::helper::gl::GLSLShader::SetInt3 ( GLint  variable,
int  i1,
int  i2,
int  i3 
)

Definition at line 232 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setInt3().

void sofa::helper::gl::GLSLShader::SetInt4 ( GLint  variable,
int  i1,
int  i2,
int  i3,
int  i4 
)

Definition at line 233 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setInt4().

void sofa::helper::gl::GLSLShader::SetIntVector ( GLint  variable,
GLsizei  count,
const GLint *  value 
)

Below are functions to set a vector of integer or float.

Definition at line 239 of file GLSLShader.cpp.

Referenced by sofa::component::visualmodel::OglShader::setIntVector().

void sofa::helper::gl::GLSLShader::SetIntVector2 ( GLint  variable,
GLsizei  count,
const GLint *  value 
)

void sofa::helper::gl::GLSLShader::SetIntVector3 ( GLint  variable,
GLsizei  count,
const GLint *  value 
)

void sofa::helper::gl::GLSLShader::SetIntVector4 ( GLint  variable,
GLsizei  count,
const GLint *  value 
)

void sofa::helper::gl::GLSLShader::TurnOff (  ) 

void sofa::helper::gl::GLSLShader::TurnOn (  ) 

These 2 functions turn on and off our shader.

Definition at line 251 of file GLSLShader.cpp.

References m_hProgramObject.

Referenced by sofa::component::visualmodel::OglShader::start().


Field Documentation

Definition at line 152 of file GLSLShader.h.

Referenced by GetGeometryInputType(), GLSLShader(), InitShaders(), and SetGeometryInputType().

std::string sofa::helper::gl::GLSLShader::header [protected]

Definition at line 138 of file GLSLShader.h.

Referenced by GLSLShader(), and InitShaders().

This handle stores our fragment shader information.

Definition at line 147 of file GLSLShader.h.

Referenced by GetFragmentS(), GLSLShader(), InitShaders(), and Release().

This handle stores our geometry shader information.

Definition at line 144 of file GLSLShader.h.

Referenced by GetGeometryS(), GLSLShader(), InitShaders(), and Release().

This handle stores our program information which encompasses our shader.

Definition at line 150 of file GLSLShader.h.

Referenced by GetProgram(), GetVariable(), GLSLShader(), InitShaders(), Release(), TurnOff(), and TurnOn().

This handle stores our vertex shader information.

Definition at line 141 of file GLSLShader.h.

Referenced by GetVertexS(), GLSLShader(), InitShaders(), and Release().


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

Generated on Sun Nov 23 04:24:18 2008 for Sofa by  doxygen 1.5.7.1