45 #ifndef CShaderProgramH 46 #define CShaderProgramH 100 cShaderProgram(
const std::string& a_vertexShader,
const std::string& a_fragmentShader);
106 static cShaderProgramPtr
create() {
return (std::make_shared<cShaderProgram>()); }
109 static cShaderProgramPtr
create(
const std::string& a_vertexShader,
const std::string& a_fragmentShader) {
return (std::make_shared<cShaderProgram>(a_vertexShader, a_fragmentShader)); }
162 void setUniformi(
const char* a_name,
const GLint a_value);
165 void setUniformf(
const char* a_name,
const GLfloat a_value);
177 void setUniformiv(
const char* a_name,
const GLint *a_values,
const int a_count);
180 void setUniformfv(
const char* a_name,
const GLfloat *a_values,
const int a_count);
This class implements a 3D vector.
Definition: CVector3d.h:88
std::vector< cShaderPtr > m_shaders
List of attached shaders.
Definition: CShaderProgram.h:208
GLenum m_geometryOutputType
Geometry shader output primitive type, if applicable.
Definition: CShaderProgram.h:217
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
Implements an OpenGL shader primitive.
bool linkProgram()
This method links the shader program and returns the link status.
Definition: CShaderProgram.cpp:166
void setUniform(const char *a_name, cVector3d &a_value)
This method sets a cVector3d uniform to a specified value.
Definition: CShaderProgram.cpp:447
void attachShader(cShaderPtr a_shader)
This method attaches a shader to the shader program.
Definition: CShaderProgram.cpp:145
int getUniformLocation(const char *a_name)
This method returns the location of a specified uniform.
Definition: CShaderProgram.cpp:354
void use(cGenericObject *a_object, cRenderOptions &a_options)
This method enables the shader program.
Definition: CShaderProgram.cpp:259
void setUniformfv(const char *a_name, const GLfloat *a_values, const int a_count)
This method sets a float array uniform to specified values.
Definition: CShaderProgram.cpp:587
bool m_linked
If true then shader program was successfully linked, false otherwise.
Definition: CShaderProgram.h:193
GLint getId()
This method returns the program ID.
Definition: CShaderProgram.h:143
void setGeometryOutputType(GLenum a_type)
Set the geometry shader output primitype type.
Definition: CShaderProgram.h:149
This class implements a shader program primitive.
Definition: CShaderProgram.h:88
GLuint m_id
OpenGL handle ID for the shader program.
Definition: CShaderProgram.h:190
std::shared_ptr< cShader > cShaderPtr
Definition: CShader.h:109
bool m_enabled
If true then program shader is currently enabled.
Definition: CShaderProgram.h:196
static cShaderProgramPtr create(const std::string &a_vertexShader, const std::string &a_fragmentShader)
Shared cShaderProgram allocator.
Definition: CShaderProgram.h:109
GLint m_geometryVerticesOut
Maximum number of vertices generated by the geometry shader.
Definition: CShaderProgram.h:220
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition: CGenericObject.h:112
This class implements a 3D matrix.
Definition: CMatrix3d.h:97
int getAttributeLocation(const char *a_name)
This method returns the location of a specified attribute.
Definition: CShaderProgram.cpp:322
Implements a base class for all objects.
GLenum m_geometryInputType
Geometry shader input primitive type, if applicable.
Definition: CShaderProgram.h:214
std::map< std::string, int > m_uniformLocList
Map of uniforms and their binding locations.
Definition: CShaderProgram.h:205
static cShaderProgramPtr create()
Shared cShaderProgram allocator.
Definition: CShaderProgram.h:106
GLuint m_shaderCount
Number of shaders that are attached to the shader program.
Definition: CShaderProgram.h:199
virtual ~cShaderProgram()
Destructor of cShaderProgram.
Definition: CShaderProgram.cpp:127
void setUniformiv(const char *a_name, const GLint *a_values, const int a_count)
This method sets an int array uniform to specified values.
Definition: CShaderProgram.cpp:555
bool isUsed()
This method returns true if this shader is currently in use. false otherwise.
Definition: CShaderProgram.h:131
bool m_geometryShaderAttached
Whether or not this program has a geometry shader attached.
Definition: CShaderProgram.h:211
std::shared_ptr< cShaderProgram > cShaderProgramPtr
Definition: CShaderProgram.h:70
cShaderProgram()
Constructor of cShaderProgram.
Definition: CShaderProgram.cpp:61
void bindAttributeLocation(const unsigned int a_index, const char *a_name)
This method binds an attribute to a name.
Definition: CShaderProgram.cpp:294
Definition: CAudioBuffer.cpp:56
void setUniformi(const char *a_name, const GLint a_value)
This method sets an int uniform to a specified value.
Definition: CShaderProgram.cpp:385
std::map< std::string, int > m_attributeLocList
Map of attributes and their binding locations.
Definition: CShaderProgram.h:202
void setGeometryVerticesOut(int a_numVertices)
Set the maximum number of vertices emitted by the gemoetry shader.
Definition: CShaderProgram.h:152
void setUniformf(const char *a_name, const GLfloat a_value)
This method sets a float uniform to a specified value.
Definition: CShaderProgram.cpp:416
void setGeometryInputType(GLenum a_type)
Set the geometry shader input primitype type.
Definition: CShaderProgram.h:146
void disable()
This method disables the shader program.
Definition: CShaderProgram.cpp:277