Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
ShaderProgram.h File Reference

Wrapper around a linked OpenGL GLSL program with uniform caching. More...

#include <string>
#include <unordered_map>
#include "Types.h"
#include "graphics/GLForward.h"
+ Include dependency graph for ShaderProgram.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mnd::ShaderProgram
 Linked GLSL program with cached uniform locations. More...
 

Namespaces

namespace  mnd
 

Detailed Description

Wrapper around a linked OpenGL GLSL program with uniform caching.

ShaderProgram objects are created by GraphicsAPI::CreateShaderProgram() from GLSL source strings (loaded from .vert / .frag files at runtime). Once built, they are owned by shared_ptr and shared by Material instances.

Uniform upload flow

shader->Bind();
shader->SetUniform("uModel", modelMatrix); // cached location lookup
shader->SetTexture("uDiffuse", texture); // binds to next texture unit

Uniform locations are cached after the first lookup to avoid repeated glGetUniformLocation calls, which are expensive if issued every frame.

See also
GraphicsAPI::CreateShaderProgram, Material

Definition in file ShaderProgram.h.