easy-gl › ProgramPipeline
ProgramPipeline
Manages a separable program pipeline — a collection of independently compiled program stages. Requires OpenGL 4.1+ or GL_ARB_separate_shader_objects. Non-copyable, movable, RAII.
A separable pipeline lets you mix and match independently compiled vertex and fragment programs without having to link them together into a single Program. Each stage is compiled as a standalone Program via Program::create_separable().
Creating separable programs
// Create separable programs — each is a full Program compiled for one stage
auto vertProg = easygl::Program::create_separable(easygl::ShaderType::Vertex, vertSrc);
auto fragProg = easygl::Program::create_separable(easygl::ShaderType::Fragment, fragSrc);
// Assemble the pipeline
easygl::ProgramPipeline pipeline;
pipeline.create();
pipeline.use_stages(easygl::ShaderStageMask::Vertex, vertProg);
pipeline.use_stages(easygl::ShaderStageMask::Fragment, fragProg);
pipeline.validate();
// At render time: bind the pipeline instead of calling program.use()
pipeline.bind();
// ... draw calls ...
easygl::ProgramPipeline::unbind();
Setting uniforms without binding
With separable programs, use the set_program_uniform* family on the individual program objects. These methods bypass the need to call use():
int loc = vertProg.uniform_location("uMVP");
vertProg.set_program_uniform_matrix4(loc, mvpData);
int colorLoc = fragProg.uniform_location("uColor");
fragProg.set_program_uniform(colorLoc, 1.0f, 0.5f, 0.2f, 1.0f);
See Program — Separable program uniforms for the full list of
set_program_uniform* methods.Method reference
| Method | Description |
|---|---|
create() | Allocate GL pipeline handle. |
destroy() | Free handle. Noexcept. |
bind() | Bind this pipeline as the active program pipeline. |
unbind() [static] | Bind pipeline 0 (disable separable pipeline). |
use_stages(stages, program) | Assign a separable program to one or more pipeline stages. |
set_active_shader_program(program) | Set the active program for glUniform* calls on this pipeline. |
validate() | Validate the pipeline for the current GL state. |
info_log() | Validation log string. |
is_valid_gl_object() | True if the GL handle is currently valid. |
is_created() | True if GL handle is allocated. |
native_handle() | Raw GL integer ID. |
reset_handle_no_gl() | Context-loss recovery: clear handle without a GL call. |