GLSLProgram Class Reference

#include <GLSLProgram.h>

List of all members.

Public Member Functions

 GLSLProgram ()
 ~GLSLProgram ()
void attach (GLSLShader &s)
 attach a shader
void detach (GLSLShader &s)
 attach a shader
void link ()
 link program after all shaders are attached
void use () const
void set_gl_texture (GLTexture &tex, const char *texName, unsigned texunit) const
 set up texture for a particular shader name
void set_gl_texture (GLShadowFrameBuffer &tex, const char *texName, unsigned texunit) const
void set_gl_texture_unit (const char *texname, unsigned texunit) const
void set_uniform (const char *name, const Vector &value) const
 set uniform variable
void set_uniform (const char *name, const float value) const
unsigned get_vertex_attrib_index (const char *name) const
 get vertex attribute index

Static Public Member Functions

static void use_fixed ()
 use fixed function pipeline instead of particular program

Protected Attributes

unsigned int id_
bool linked_
std::list< GLSLShader * > attached_shaders_

Static Protected Attributes

static const
GLSLProgram
used_program_

Private Member Functions

 GLSLProgram (const GLSLProgram &)
GLSLProgramoperator= (const GLSLProgram &)


Detailed Description

this class handles an OpenGL GLSL Program, that is a link unit of shaders.
Note:
needs OpenGL 2.0

Definition at line 33 of file GLSLProgram.h.


Constructor & Destructor Documentation

GLSLProgram::GLSLProgram (  ) 

Definition at line 28 of file GLSLProgram.cpp.

References DIALOG_ASSERT, glCreateProgram, GLStateExtension::hasShaders(), and id_.

GLSLProgram::~GLSLProgram (  ) 

Definition at line 38 of file GLSLProgram.cpp.

References attached_shaders_, glDeleteProgram, glDetachShader, id_, Logger::log(), use_fixed(), and used_program_.

GLSLProgram::GLSLProgram ( const GLSLProgram  )  [private]


Member Function Documentation

void GLSLProgram::attach ( GLSLShader s  ) 

attach a shader

Definition at line 58 of file GLSLProgram.cpp.

References attached_shaders_, GLSLShader::getId(), glAttachShader, id_, and linked_.

Referenced by GLSLShaderSetup::GLSLShaderSetup().

void GLSLProgram::detach ( GLSLShader s  ) 

attach a shader

Definition at line 65 of file GLSLProgram.cpp.

References attached_shaders_, GLSLShader::getId(), glDetachShader, id_, and linked_.

void GLSLProgram::link (  ) 

link program after all shaders are attached

Definition at line 85 of file GLSLProgram.cpp.

References S3D::dialogExit(), S3D::formatStringBuffer(), GL_FALSE, GL_INFO_LOG_LENGTH, GL_LINK_STATUS, glGetProgramInfoLog, glGetProgramiv, glLinkProgram, id_, and linked_.

Referenced by GLSLShaderSetup::GLSLShaderSetup().

void GLSLProgram::use (  )  const

use this program

Note:
link program before using it!

Definition at line 105 of file GLSLProgram.cpp.

References DIALOG_ASSERT, glUseProgram, id_, linked_, and used_program_.

Referenced by GLSLShaderSetup::use().

void GLSLProgram::use_fixed (  )  [static]

use fixed function pipeline instead of particular program

Definition at line 164 of file GLSLProgram.cpp.

References glUseProgram, and used_program_.

Referenced by GLSLShaderSetup::use_fixed(), and ~GLSLProgram().

void GLSLProgram::set_gl_texture ( GLTexture tex,
const char *  texName,
unsigned  texunit 
) const

set up texture for a particular shader name

Definition at line 112 of file GLSLProgram.cpp.

References DIALOG_ASSERT, GLTexture::draw(), GL_TEXTURE0, glActiveTexture, glGetUniformLocation, glUniform1i, id_, and used_program_.

Referenced by GLSLShaderSetup::set_gl_texture().

void GLSLProgram::set_gl_texture ( GLShadowFrameBuffer tex,
const char *  texName,
unsigned  texunit 
) const

Definition at line 122 of file GLSLProgram.cpp.

References GLShadowFrameBuffer::bindDepthTexture(), DIALOG_ASSERT, GL_TEXTURE0, glActiveTexture, glGetUniformLocation, glUniform1i, id_, and used_program_.

void GLSLProgram::set_gl_texture_unit ( const char *  texname,
unsigned  texunit 
) const

Definition at line 132 of file GLSLProgram.cpp.

References DIALOG_ASSERT, GL_TEXTURE0, glActiveTexture, glGetUniformLocation, glUniform1i, id_, and used_program_.

Referenced by GLSLShaderSetup::set_gl_texture_unit().

void GLSLProgram::set_uniform ( const char *  name,
const Vector value 
) const

set uniform variable

Definition at line 141 of file GLSLProgram.cpp.

References DIALOG_ASSERT, glGetUniformLocation, glUniform3f, id_, and used_program_.

Referenced by GLSLShaderSetup::set_uniform().

void GLSLProgram::set_uniform ( const char *  name,
const float  value 
) const

Definition at line 149 of file GLSLProgram.cpp.

References DIALOG_ASSERT, glGetUniformLocation, glUniform1f, id_, and used_program_.

unsigned GLSLProgram::get_vertex_attrib_index ( const char *  name  )  const

get vertex attribute index

Definition at line 157 of file GLSLProgram.cpp.

References DIALOG_ASSERT, glGetAttribLocation, id_, and used_program_.

Referenced by GLSLShaderSetup::get_vertex_attrib_index().

GLSLProgram& GLSLProgram::operator= ( const GLSLProgram  )  [private]


Member Data Documentation

unsigned int GLSLProgram::id_ [protected]

Definition at line 68 of file GLSLProgram.h.

Referenced by attach(), detach(), get_vertex_attrib_index(), GLSLProgram(), link(), set_gl_texture(), set_gl_texture_unit(), set_uniform(), use(), and ~GLSLProgram().

bool GLSLProgram::linked_ [protected]

Definition at line 69 of file GLSLProgram.h.

Referenced by attach(), detach(), link(), and use().

std::list<GLSLShader*> GLSLProgram::attached_shaders_ [protected]

Definition at line 70 of file GLSLProgram.h.

Referenced by attach(), detach(), and ~GLSLProgram().

const GLSLProgram * GLSLProgram::used_program_ [static, protected]

Definition at line 71 of file GLSLProgram.h.

Referenced by get_vertex_attrib_index(), set_gl_texture(), set_gl_texture_unit(), set_uniform(), use(), use_fixed(), and ~GLSLProgram().


The documentation for this class was generated from the following files:
Generated on Mon Feb 16 15:15:02 2009 for Scorched3D by  doxygen 1.5.3