Ream v0.1.0-1
C++ graphics library for Linux
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
RGLProgram Class Referencefinal

A linked OpenGL ES program (vertex + fragment shader) for a given feature set. More...

#include <RGLProgram.h>

+ Inheritance diagram for RGLProgram:

Classes

struct  Locations
 Cached locations of the program's vertex attributes and uniforms. More...
 

Public Member Functions

 ~RGLProgram () noexcept
 Deletes the underlying GL program object.
 
const Locationsloc () const noexcept
 Returns the attribute/uniform locations resolved at link time.
 
GLuint id () const noexcept
 Returns the GL program object name.
 
CZBitset< RGLShader::Featuresfeatures () const noexcept
 Returns the feature flags this program was built for.
 
RGLDevicedevice () const noexcept
 Returns the device this program belongs to.
 
void bind () noexcept
 Makes this program the current one (glUseProgram).
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Static Public Member Functions

static std::shared_ptr< RGLProgramGetOrMake (RGLDevice *device, CZBitset< RGLShader::Features > features) noexcept
 Returns the cached program for the given device and feature set, building it if needed.
 

Detailed Description

A linked OpenGL ES program (vertex + fragment shader) for a given feature set.

Each program is built from an RGLShader pair selected by a set of RGLShader::Features flags. Programs are cached per feature set in the RGLDevice's per-thread context data, so a given feature combination is only linked once per device/context.


Class Documentation

◆ CZ::RGLProgram::Locations

struct CZ::RGLProgram::Locations

Cached locations of the program's vertex attributes and uniforms.

Locations that do not apply to the program's feature set are left unset.

Class Members
GLint pos pos vertex attribute (vertex position).
GLint posProj posProj uniform (position projection matrix).
GLint image image sampler uniform (source texture).
GLint imageProj imageProj uniform (source texture-coordinate matrix).
GLint mask mask sampler uniform (mask texture).
GLint maskProj maskProj uniform (mask texture-coordinate matrix).
GLint factorR factorR uniform (red channel multiplier).
GLint factorG factorG uniform (green channel multiplier).
GLint factorB factorB uniform (blue channel multiplier).
GLint factorA factorA uniform (alpha channel multiplier).
GLint pixelSize pixelSize uniform (texel size, used by effect shaders).

Constructor & Destructor Documentation

◆ ~RGLProgram()

~RGLProgram ( )
noexcept

Deletes the underlying GL program object.

Member Function Documentation

◆ GetOrMake()

static std::shared_ptr< RGLProgram > GetOrMake ( RGLDevice device,
CZBitset< RGLShader::Features features 
)
staticnoexcept

Returns the cached program for the given device and feature set, building it if needed.

Parameters
deviceThe target device (uses its per-thread context data).
featuresThe RGLShader feature flags describing the desired program.
Returns
The program, or nullptr if compilation/linking failed.

◆ loc()

const Locations & loc ( ) const
inlinenoexcept

Returns the attribute/uniform locations resolved at link time.

◆ id()

GLuint id ( ) const
inlinenoexcept

Returns the GL program object name.

◆ features()

CZBitset< RGLShader::Features > features ( ) const
inlinenoexcept

Returns the feature flags this program was built for.

◆ device()

RGLDevice * device ( ) const
inlinenoexcept

Returns the device this program belongs to.

◆ bind()

void bind ( )
noexcept

Makes this program the current one (glUseProgram).