Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
ShaderProgram Class Reference

ShaderProgram is a class that represents an OpenGL shader program. It is responsible for managing the compilation, linking, and use of shaders in an OpenGL application. It allows setting uniforms such as floats, vectors, and matrices, as well as determining if tessellation shaders are part of the program. More...

#include <ShaderProgram.h>

Public Member Functions

 ShaderProgram ()
 Default constructor for ShaderProgram. Initializes the shader program ID to 0.
 
 ~ShaderProgram ()=default
 Destructor for ShaderProgram. Frees the resources associated with the shader program.
 
void Unload ()
 Unloads the shader program, deleting it from OpenGL.
 
void Compose (std::vector< Shader * > shaders)
 Compiles and links the provided shaders into the shader program.
 
unsigned int GetID ()
 Gets the ID of the shader program.
 
bool GetTesselation ()
 Checks if the shader program uses tessellation shaders.
 
void Use ()
 Activates the shader program for use in OpenGL rendering.
 
void setFloat (const GLchar *name, GLfloat value)
 Sets a float uniform in the shader program.
 
void setInteger (const GLchar *name, GLint value)
 Sets an integer uniform in the shader program.
 
void setVector2f (const GLchar *name, GLfloat x, GLfloat y)
 Sets a 2D vector uniform in the shader program.
 
void setVector2f (const GLchar *name, const Vector2 &value)
 Sets a 2D vector uniform in the shader program.
 
void setVector3f (const GLchar *name, GLfloat x, GLfloat y, GLfloat z)
 Sets a 3D vector uniform in the shader program.
 
void setVector3f (const GLchar *name, const Vector3 &value)
 Sets a 3D vector uniform in the shader program.
 
void setVector4f (const GLchar *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 Sets a 4D vector uniform in the shader program.
 
void setVector4f (const GLchar *name, const Vector4 &value)
 Sets a 4D vector uniform in the shader program.
 
void setMatrix4 (const GLchar *name, const Matrix4 &matrix)
 Sets a 4x4 matrix uniform in the shader program.
 

Detailed Description

ShaderProgram is a class that represents an OpenGL shader program. It is responsible for managing the compilation, linking, and use of shaders in an OpenGL application. It allows setting uniforms such as floats, vectors, and matrices, as well as determining if tessellation shaders are part of the program.

Constructor & Destructor Documentation

◆ ShaderProgram()

ShaderProgram::ShaderProgram ( )

Default constructor for ShaderProgram. Initializes the shader program ID to 0.

◆ ~ShaderProgram()

ShaderProgram::~ShaderProgram ( )
default

Destructor for ShaderProgram. Frees the resources associated with the shader program.

Member Function Documentation

◆ Compose()

void ShaderProgram::Compose ( std::vector< Shader * > shaders)

Compiles and links the provided shaders into the shader program.

Parameters
shadersA vector of Shader objects to be attached and linked into the program.

◆ GetID()

unsigned int ShaderProgram::GetID ( )

Gets the ID of the shader program.

Returns
The OpenGL ID of the shader program.

◆ GetTesselation()

bool ShaderProgram::GetTesselation ( )

Checks if the shader program uses tessellation shaders.

Returns
True if the shader program has tessellation shaders, otherwise false.

◆ setFloat()

void ShaderProgram::setFloat ( const GLchar * name,
GLfloat value )

Sets a float uniform in the shader program.

Parameters
nameThe name of the uniform variable.
valueThe value to set for the uniform variable.

◆ setInteger()

void ShaderProgram::setInteger ( const GLchar * name,
GLint value )

Sets an integer uniform in the shader program.

Parameters
nameThe name of the uniform variable.
valueThe value to set for the uniform variable.

◆ setMatrix4()

void ShaderProgram::setMatrix4 ( const GLchar * name,
const Matrix4 & matrix )

Sets a 4x4 matrix uniform in the shader program.

Parameters
nameThe name of the uniform variable.
matrixThe matrix to set for the uniform variable.

◆ setVector2f() [1/2]

void ShaderProgram::setVector2f ( const GLchar * name,
const Vector2 & value )

Sets a 2D vector uniform in the shader program.

Parameters
nameThe name of the uniform variable.
valueThe 2D vector to set for the uniform variable.

◆ setVector2f() [2/2]

void ShaderProgram::setVector2f ( const GLchar * name,
GLfloat x,
GLfloat y )

Sets a 2D vector uniform in the shader program.

Parameters
nameThe name of the uniform variable.
xThe x component of the vector.
yThe y component of the vector.

◆ setVector3f() [1/2]

void ShaderProgram::setVector3f ( const GLchar * name,
const Vector3 & value )

Sets a 3D vector uniform in the shader program.

Parameters
nameThe name of the uniform variable.
valueThe 3D vector to set for the uniform variable.

◆ setVector3f() [2/2]

void ShaderProgram::setVector3f ( const GLchar * name,
GLfloat x,
GLfloat y,
GLfloat z )

Sets a 3D vector uniform in the shader program.

Parameters
nameThe name of the uniform variable.
xThe x component of the vector.
yThe y component of the vector.
zThe z component of the vector.

◆ setVector4f() [1/2]

void ShaderProgram::setVector4f ( const GLchar * name,
const Vector4 & value )

Sets a 4D vector uniform in the shader program.

Parameters
nameThe name of the uniform variable.
valueThe 4D vector to set for the uniform variable.

◆ setVector4f() [2/2]

void ShaderProgram::setVector4f ( const GLchar * name,
GLfloat x,
GLfloat y,
GLfloat z,
GLfloat w )

Sets a 4D vector uniform in the shader program.

Parameters
nameThe name of the uniform variable.
xThe x component of the vector.
yThe y component of the vector.
zThe z component of the vector.
wThe w component of the vector.

◆ Unload()

void ShaderProgram::Unload ( )

Unloads the shader program, deleting it from OpenGL.

◆ Use()

void ShaderProgram::Use ( )

Activates the shader program for use in OpenGL rendering.


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