GLUtils
Functions
Name | |
---|---|
GLuint | createProgram(const GLuint * shaders)<br>helper function for shader linking - overloaded |
GLuint | createProgram(const std::vector< GLuint > & shaderList)<br>helper function for shader linking |
GLuint | createShaderFromFile(GLenum eShaderType, const std::string & filename, const std::string & sourceToInject)<br>helper function for shader compiling and loading |
GLuint | createShaderFromSource(GLenum eShaderType, const std::string & strShaderText)<br>helper function for shader compiling |
GLuint | createTexture(const std::string & fileName, bool mipmap, bool clampToEdge) |
void | deleteProgramAndShaders(GLuint program)<br>deletes the shader program and all attached shaders |
void | injectSourceIntoShader(std::string & source, const std::string & shaderName, const std::string & sourceToInject) |
bool | linkProgram(GLuint program) |
bool | linkProgram(GLuint program) |
bool | loadTexImage2D(const std::string & fileName, GLenum target) |
Functions Documentation
function createProgram
GLuint createProgram(
const GLuint * shaders
)
GLuint createProgram(
const GLuint * shaders
)
helper function for shader linking - overloaded
Parameters:
- shaders zero ended array of shader ids - for example {vsid, fsid, 0}
See: createProgram
Return: opengl shader program id or 0 on failure
This is the overloaded version of createProgram().
function createProgram
GLuint createProgram(
const std::vector< GLuint > & shaderList
)
GLuint createProgram(
const std::vector< GLuint > & shaderList
)
helper function for shader linking
Parameters:
- shaderList array of compiled shaders to attach, you can use createShaderFromSource() for example to fill the array
Return: opengl shader program id or 0 on failure
The function internaly uses glCreateProgram, glAttachShader to attach all supplied shaders and finally glLinkProgram. Any GLSL errors and warnings are printed to stderr.
function createShaderFromFile
GLuint createShaderFromFile(
GLenum eShaderType,
const std::string & filename,
const std::string & sourceToInject
)
GLuint createShaderFromFile(
GLenum eShaderType,
const std::string & filename,
const std::string & sourceToInject
)
helper function for shader compiling and loading
Parameters:
- eShaderType we support GL_VERTEX_SHADER, GL_FRAGMENT_SHADER and GL_GEOMETRY_SHADER values
- filename file to use as a shader source
- sourceToInject text to insert right after the glsl version declaration, do nothing if its an empty string
Return: opengl shader id or 0 on failure
This function loads shader source from file named filename and calls createShaderFromSource().
function createShaderFromSource
GLuint createShaderFromSource(
GLenum eShaderType,
const std::string & strShaderText
)
GLuint createShaderFromSource(
GLenum eShaderType,
const std::string & strShaderText
)
helper function for shader compiling
Parameters:
- eShaderType we support GL_VERTEX_SHADER, GL_FRAGMENT_SHADER and GL_GEOMETRY_SHADER values
- strShaderText GLSL code to be used as a glShaderSource argument
Return: opengl shader id or 0 on failure
The function internaly uses glCreateShader, glShaderSource and glCompileShader sequence. glGetShaderiv is used to detect compile errors, the function prints GLSL errors and warnings to stderr.
function createTexture
GLuint createTexture(
const std::string & fileName,
bool mipmap,
bool clampToEdge
)
GLuint createTexture(
const std::string & fileName,
bool mipmap,
bool clampToEdge
)
function deleteProgramAndShaders
void deleteProgramAndShaders(
GLuint program
)
void deleteProgramAndShaders(
GLuint program
)
deletes the shader program and all attached shaders
You should delete all shader programs before your application terminates.
function injectSourceIntoShader
void injectSourceIntoShader(
std::string & source,
const std::string & shaderName,
const std::string & sourceToInject
)
void injectSourceIntoShader(
std::string & source,
const std::string & shaderName,
const std::string & sourceToInject
)
function linkProgram
static bool linkProgram(
GLuint program
)
static bool linkProgram(
GLuint program
)
function linkProgram
static bool linkProgram(
GLuint program
)
static bool linkProgram(
GLuint program
)
function loadTexImage2D
bool loadTexImage2D(
const std::string & fileName,
GLenum target
)
bool loadTexImage2D(
const std::string & fileName,
GLenum target
)
Updated on 2025-05-31 at 12:55:31 +0000