JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
ShaderProgram Class Reference

Linked vertex and fragment shaders. More...

#include <jngl/ShaderProgram.hpp>

Classes

struct  Context
 Lifetime object when the ShaderProgram is in use. More...
 

Public Member Functions

 ShaderProgram (const Shader &vertex, const Shader &fragment)
 
 ShaderProgram (const ShaderProgram &)=delete
 
 ShaderProgram (ShaderProgram &&) noexcept
 
ShaderProgram & operator= (const ShaderProgram &)=delete
 
ShaderProgram & operator= (ShaderProgram &&) noexcept
 
Context use () const
 
int getAttribLocation (const std::string &name) const
 
int getUniformLocation (const std::string &name) const
 Returns the location of a uniform variable for use with Context::setUniform.
 

Detailed Description

Linked vertex and fragment shaders.

Definition at line 17 of file ShaderProgram.hpp.

Member Function Documentation

◆ getUniformLocation()

int getUniformLocation ( const std::string & name) const
nodiscard

Returns the location of a uniform variable for use with Context::setUniform.

The returned location is stable for the lifetime of the ShaderProgram and is typically queried once (e.g. in a constructor) and then cached.

Parameters
namename of the uniform variable as declared in the GLSL source. Note that GLSL compilers strip away uniforms that aren't actually read by the shader, so this may fail even if the variable appears in the source.
Returns
a non-negative location identifying the uniform
Exceptions
std::runtime_errorif no active uniform with the given name exists in the linked shader program.

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