How to Shaders
Intro to the engine's shading API - GLSLProgram
Manage shaders via the GLSLProgram
GLSLProgram.hpp - class declarationsGLSLProgram.cpp - class implementationExample shader implementations
Basic pixel position & color manipulation.
#version 450 core
uniform mat4 model_view;
uniform mat4 projection;
layout(location = 0) in vec4 position;
layout(location = 0) out vec4 vertex_pos;
void main(void)
{
gl_Position = projection * model_view * position;
vertex_pos = position;
}#version 450 core
struct material
{
vec4 emissive;
};
// Incoming vertex position
layout(location = 0) in vec4 vertex_pos;
uniform material mat;
out vec4 outputF;
void main(void)
{
outputF = mat.emissive;
} Require the shader class in your application
Instantiate a shader program object
Compile & Build the shader program from your sources
std::string and char* sources are accepted can be file path or a shader code as a string
Example
Compile shader from file
Build the comiled shader
Use the shader or change the shader that is currently in use
Bind current shader
Unbind current shader
Last updated