Skip to content

GLUtils ​

Functions ​

Name
GLuintcreateProgram(const GLuint * shaders)<br>helper function for shader linking - overloaded
GLuintcreateProgram(const std::vector< GLuint > & shaderList)<br>helper function for shader linking
GLuintcreateShaderFromFile(GLenum eShaderType, const std::string & filename, const std::string & sourceToInject)<br>helper function for shader compiling and loading
GLuintcreateShaderFromSource(GLenum eShaderType, const std::string & strShaderText)<br>helper function for shader compiling
GLuintcreateTexture(const std::string & fileName, bool mipmap, bool clampToEdge)
voiddeleteProgramAndShaders(GLuint program)<br>deletes the shader program and all attached shaders
voidinjectSourceIntoShader(std::string & source, const std::string & shaderName, const std::string & sourceToInject)
boollinkProgram(GLuint program)
boollinkProgram(GLuint program)
boolloadTexImage2D(const std::string & fileName, GLenum target)

Functions Documentation ​

function createProgram ​

cpp
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 ​

cpp
GLuint createProgram(
    const std::vector< GLuint > & shaderList
)

helper function for shader linking

Parameters:

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 ​

cpp
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 ​

cpp
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 ​

cpp
GLuint createTexture(
    const std::string & fileName,
    bool mipmap,
    bool clampToEdge
)

function deleteProgramAndShaders ​

cpp
void deleteProgramAndShaders(
    GLuint program
)

deletes the shader program and all attached shaders

You should delete all shader programs before your application terminates.

function injectSourceIntoShader ​

cpp
void injectSourceIntoShader(
    std::string & source,
    const std::string & shaderName,
    const std::string & sourceToInject
)

function linkProgram ​

cpp
static bool linkProgram(
    GLuint program
)

function linkProgram ​

cpp
static bool linkProgram(
    GLuint program
)

function loadTexImage2D ​

cpp
bool loadTexImage2D(
    const std::string & fileName,
    GLenum target
)

Updated on 2026-09-11 at 21:24:25 +0000