Struct Program

Inheritance Relationships

Base Type

Struct Documentation

struct Program : public CE::Rendering::Resources::Program

Declaration: final

Linked-program handle and legacy mutable uniform access.

Native operations require this program’s live owner/current context. Uniform setters do not select the program: call use() first (bind_pass does so). Missing setters assert in assertion builds and skip the write otherwise; location queries themselves return -1 for missing names. No setter validates every native GLSL type or promises rollback of earlier writes.

See also

OpenGL backend

Public Functions

explicit Program(Handle program)

Take ownership of an already tracked program name.

Parameters:

program – Live owner/current-context handle of ResourceKind::Program. Empty/stopped/current-context failures propagate; a different handle kind throws invalid_args. Construction checks the kind, not link status; require_linked() validates that separately.

virtual void use() override

Select this live program with glUseProgram on its native owner/current context.

Does not resolve material parameters or validate link status.

virtual void bind_pass(const CE::Rendering::Parameters::PassSemantics &pass) override

Select the program, then write nonempty projection/view mappings.

Parameters:

pass – Stable matrices borrowed through the call. Requires native owner/current context; missing uniforms follow setter assertion/skip behavior. Earlier writes are not rolled back if a later lookup fails.

virtual void bind_draw(const CE::Rendering::Parameters::DrawSemantics &draw) override

Write nonempty model/alpha/scale/legacy-texture mappings to the selected program.

Parameters:

draw – Stable copied draw semantics borrowed through the call. Caller first selects this program with use()/bind_pass(). No material packet or image binding is constructed; earlier writes are not rolled back.

void set_material_bindings(MaterialBindings bindings)

Replace legacy semantic-name mappings without retaining caller strings.

Parameters:

bindings – Owned names; empty values omit those roles. Requires live owner/current context; no reflection/type/name validation is performed until use.

inline void require_current() const

Validate this retained native handle’s active owner/current context without selecting the program.

void require_linked() const

Query native link status on the live owner/current context.

Throws:

CE::Exceptions::failed_operation – For an unlinked program or native query error. Does not bind or relink the executable.

inline const ResourceLifetime *resource_domain() const noexcept

Declaration: [[nodiscard]]

Returns:

Borrowed domain identity while retaining this program; identity alone does not authorize native use.

std::vector<Variable> active_uniforms() const

Declaration: [[nodiscard]]

Reflect active uniforms on the live owner/current context.

Returns:

Owned records independent of later vector destruction; an unused uniform may be absent. Invalid/native reflection failures throw failed_operation; no program selection or cache publication occurs.

std::vector<Variable> active_attributes() const

Declaration: [[nodiscard]]

Reflect active vertex attributes on the live owner/current context.

Returns:

Owned native name/type/count/location records. Invalid/native reflection failures propagate; this does not validate compatibility with a pipeline layout.

void set_uniform_vec(const char *name, const glm::vec2 &value)

Write one 2-component floating GLSL vector to this already selected program.

Parameters:
  • name – Nonnull NUL-terminated uniform name, borrowed through lookup.

  • value – Components borrowed through this call and copied by OpenGL. Requires live owner/current context. A missing location asserts in assertion builds and skips the write otherwise; the method does not select the program or reflect the exact uniform type.

void set_uniform_vec(const char *name, const glm::vec3 &value)

Write one 3-component floating GLSL vector to this already selected program.

Parameters:
  • name – Nonnull NUL-terminated uniform name, borrowed through lookup.

  • value – Components borrowed through this call and copied by OpenGL. Requires live owner/current context. A missing location asserts in assertion builds and skips the write otherwise; the method does not select the program or reflect the exact uniform type.

void set_uniform_vec(const char *name, const glm::vec4 &value)

Write one 4-component floating GLSL vector to this already selected program.

Parameters:
  • name – Nonnull NUL-terminated uniform name, borrowed through lookup.

  • value – Components borrowed through this call and copied by OpenGL. Requires live owner/current context. A missing location asserts in assertion builds and skips the write otherwise; the method does not select the program or reflect the exact uniform type.

void set_uniform_matrix(const char *name, const glm::mat2 &value)

Write one 2 by 2 floating matrix to this already selected program, without transposition.

Parameters:
  • name – Nonnull NUL-terminated uniform name borrowed through the call.

  • value – GLM column-major storage borrowed through upload. Requires live owner/current context; absent locations assert/skip rather than selecting another program. Native type compatibility remains the caller’s responsibility.

void set_uniform_matrix(const char *name, const glm::mat3 &value)

Write one 3 by 3 floating matrix to this already selected program, without transposition.

Parameters:
  • name – Nonnull NUL-terminated uniform name borrowed through the call.

  • value – GLM column-major storage borrowed through upload. Requires live owner/current context; absent locations assert/skip rather than selecting another program. Native type compatibility remains the caller’s responsibility.

virtual void set_uniform_matrix(const char *name, const glm::mat4 &value) override

Write one 4 by 4 floating matrix to this already selected program, without transposition.

Parameters:
  • name – Nonnull NUL-terminated uniform name borrowed through the call.

  • value – GLM column-major storage borrowed through upload. Requires live owner/current context; absent locations assert/skip rather than selecting another program. Native type compatibility remains the caller’s responsibility.

virtual void set_uniform_value(const char *name, float value) override

Write a floating-point uniform to this already selected native program.

Parameters:
  • name – Nonnull NUL-terminated name borrowed through the call.

  • value – Copied scalar; no coercion beyond its declared overload. Requires live owner/current context. Missing names assert in assertion builds and skip the write otherwise; this does not select a program or reflect type compatibility.

virtual void set_uniform_value(const char *name, int value) override

Write a signed integer uniform to this already selected native program.

Parameters:
  • name – Nonnull NUL-terminated name borrowed through the call.

  • value – Copied scalar; no coercion beyond its declared overload. Requires live owner/current context. Missing names assert in assertion builds and skip the write otherwise; this does not select a program or reflect type compatibility.

virtual void set_uniform_value(const char *name, unsigned int value) override

Write a unsigned integer uniform to this already selected native program.

Parameters:
  • name – Nonnull NUL-terminated name borrowed through the call.

  • value – Copied scalar; no coercion beyond its declared overload. Requires live owner/current context. Missing names assert in assertion builds and skip the write otherwise; this does not select a program or reflect type compatibility.

virtual void set_uniform_value(const char *name, bool value) override

Write a boolean uniform to this already selected native program.

Parameters:
  • name – Nonnull NUL-terminated name borrowed through the call.

  • value – Copied scalar; no coercion beyond its declared overload. Requires live owner/current context. Missing names assert in assertion builds and skip the write otherwise; this does not select a program or reflect type compatibility.

template<glm::length_t dim>
inline void set_uniform_vec(const char *name, const glm::vec<dim, glm::f32, glm::defaultp> &value)

Explicit-template compatibility frontend for floating vec2/vec3/vec4 setters.

Template Parameters:

dim – Component count, statically restricted to 2..4.

Parameters:
  • name – Uniform name borrowed through the call.

  • value – Stable vector forwarded to the corresponding overload. Current-program, lifetime, assertion/skip and failure behavior matches that overload.

template<glm::length_t dim>
inline void set_uniform_matrix(const char *name, const glm::mat<dim, dim, glm::f32, glm::defaultp> &value)

Explicit-template compatibility frontend for square mat2/mat3/mat4 setters.

Template Parameters:

dim – Matrix dimension, statically restricted to 2..4.

Parameters:
  • name – Uniform name borrowed through the call.

  • value – Column-major matrix forwarded without transposition. Requires this already selected program’s live owner/current context; overload failure behavior applies.

template<typename T>
inline void set_uniform_value(const char *name, const T &value)

Dispatch an explicit scalar template argument to its native overload.

Template Parameters:

T – Exactly float, int, unsigned int or bool; other types fail static assertion.

Parameters:
  • name – Borrowed uniform name.

  • value – Scalar copied to its matching overload. No program selection/type conversion is added; native affinity and missing-uniform behavior are unchanged.

void print_active_uniforms() const

Query reflection and emit a DEBUG summary with TRACE uniform records.

Requires live owner/current context; reflection failures propagate normally. Logging follows compile/runtime policy; no stdout or event delivery is used.

void print_active_attribs() const

Query reflection and emit a DEBUG summary with TRACE attribute records.

Requires live owner/current context; reflection failures propagate normally, even if logging is disabled.

int get_uniform_location(const char *name)

Query and cache a native uniform location on the live owner/current context.

Parameters:

name – Nonnull NUL-terminated name; cache stores its own string.

Returns:

Location, including -1 when absent/inactive; missing results are cached too. Null names throw invalid_args; native query/allocation failures propagate. This cache is mutable and unsynchronized beyond owner affinity; the program is not relinked or selected.

int get_attribute_location(const char *name)

Query and cache a native attribute location on the live owner/current context.

Parameters:

name – Nonnull NUL-terminated name; cache stores its own string.

Returns:

Location, including -1 when absent/inactive; missing results are cached too. Null names throw invalid_args; native query/allocation failures propagate. This cache is mutable and unsynchronized beyond owner affinity; the program is not relinked or selected.