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

A compiled OpenGL ES shader specialized for a set of features. More...

#include <RGLShader.h>

+ Inheritance diagram for RGLShader:

Public Types

enum  Features : UInt32
 Feature flags controlling shader specialization. More...
 

Public Member Functions

 ~RGLShader () noexcept
 Deletes the underlying GL shader object.
 
GLuint id () const noexcept
 Returns the GL shader object name.
 
GLenum type () const noexcept
 Returns the GL shader stage (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER).
 
CZBitset< Featuresfeatures () const noexcept
 Returns the feature flags this shader was compiled for.
 
RGLDevicedevice () const noexcept
 Returns the device this shader belongs to.
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Static Public Member Functions

static std::shared_ptr< RGLShaderGetOrMake (RGLDevice *device, CZBitset< Features > features, GLenum type) noexcept
 Returns the cached shader for the given device, feature set, and type, compiling it if needed.
 

Static Public Attributes

static constexpr CZBitset< FeaturesVertFeatures { HasImage | HasMask }
 Subset of Features that affect the vertex shader (the rest only affect the fragment shader).
 

Detailed Description

A compiled OpenGL ES shader specialized for a set of features.

The GL backend uses a single über-shader whose behavior is controlled by preprocessor defines derived from a Features bitmask. RGLShader compiles one variant per (feature set, shader type) and caches it in the RGLDevice's per-thread context data. Programs (RGLProgram) combine a vertex and a fragment variant sharing the same feature set.

Member Enumeration Documentation

◆ Features

enum Features : UInt32

Feature flags controlling shader specialization.

The lowest 2 bits encode the blend mode, the middle bits are boolean capabilities, and the upper 4 bits encode an optional image effect.

Enumerator
BlendSrc 

Source blend mode (replace destination).

BlendSrcOver 

Source-over blend mode.

BlendDstIn 

Destination-in blend mode (mask by source alpha).

HasImage 

Samples a source image texture.

ImageExternal 

The source texture is an external (GL_TEXTURE_EXTERNAL_OES) sampler.

HasMask 

Samples a mask texture.

MaskExternal 

The mask texture is an external sampler.

ReplaceImageColor 

Replaces the image RGB with a solid color, keeping its alpha.

HasFactorR 

Applies the red-channel multiplier.

HasFactorG 

Applies the green-channel multiplier.

HasFactorB 

Applies the blue-channel multiplier.

HasFactorA 

Applies the alpha-channel multiplier.

PremultSrc 

The source color is premultiplied alpha.

HasPixelSize 

Provides the pixelSize uniform (texel size for effects).

VibrancyH 

Horizontal vibrancy blur pass.

VibrancyLightV 

Vertical vibrancy blur pass with light-tone saturation.

VibrancyDarkV 

Vertical vibrancy blur pass with dark-tone saturation.

Constructor & Destructor Documentation

◆ ~RGLShader()

~RGLShader ( )
noexcept

Deletes the underlying GL shader object.

Member Function Documentation

◆ GetOrMake()

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

Returns the cached shader for the given device, feature set, and type, compiling it if needed.

Parameters
deviceThe target device (uses its per-thread context data).
featuresThe feature flags describing the desired shader variant.
typeThe GL shader stage (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER).
Returns
The compiled shader, or nullptr on compilation failure.

◆ id()

GLuint id ( ) const
inlinenoexcept

Returns the GL shader object name.

◆ type()

GLenum type ( ) const
inlinenoexcept

Returns the GL shader stage (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER).

◆ features()

CZBitset< Features > features ( ) const
inlinenoexcept

Returns the feature flags this shader was compiled for.

◆ device()

RGLDevice * device ( ) const
inlinenoexcept

Returns the device this shader belongs to.

Member Data Documentation

◆ VertFeatures

constexpr CZBitset<Features> VertFeatures { HasImage | HasMask }
staticconstexpr

Subset of Features that affect the vertex shader (the rest only affect the fragment shader).