Class Renderer
Defined in File renderer.h
Inheritance Relationships
Base Type
public CE::Rendering::Renderer(Class Renderer)
Class Documentation
-
class Renderer : public CE::Rendering::Renderer
Declaration:
finalImplements rendering commands using a separately owned OpenGL context.
initialize() makes that context current before loading GL entry points; deinitialize() deletes all tracked GPU resources before releasing it. The supplied context must outlive this renderer. Destruction attempts owner-thread cleanup; failed context recovery invalidates retained handles without OpenGL calls. A stopped renderer cannot be restarted with its old cached assets.
Public Functions
-
explicit Renderer(::CE::Rendering::OpenGL::Context &context)
Borrow a compatible OpenGL presentation context without initializing it.
- Parameters:
context – Adapter/window kept alive through renderer destruction and resource cleanup. Initialize on its graphics owner before resource uploads or draws; construction performs no native calls.
-
virtual ~Renderer() override
Attempt owner-thread native cleanup while the borrowed context is still alive.
If cleanup/context recovery fails, report it and abandon the lifetime without unsafe native calls. Prefer explicit deinitialize() after quiescing loading/rendering; destruction is not cross-thread cancellation.
-
void set_native_diagnostics(bool enabled)
Opt into renderer-command OpenGL debug observation before initialization.
- Parameters:
enabled – Requested observation; GL 4.3/KHR_debug support is optional.
- Throws:
CE::Exceptions::failed_operation – Once initialized or stopped. Existing host callbacks remain host-owned; unsupported diagnostics do not reject an otherwise supported renderer.
-
virtual void initialize() override
Make the borrowed context current, load entry points and establish an OpenGL 3.3-or-newer resource domain.
Call on the intended context owner. Already-initialized calls require that owner and reselect the context; a stopped renderer throws failed_operation and cannot restart. Startup failure attempts context release without masking the original error; publication of the domain occurs only after native startup succeeds.
-
virtual void deinitialize() override
Unbind the current program, delete all tracked resources, stop diagnostics and release the context.
No-op before initialization/after completed shutdown. Otherwise requires the original owner, makes its context current and permanently stops this renderer. Retained logical handles become unusable; quiesce loading/frame consumption first. Native/context failures may propagate, so keep the borrowed context alive for recovery.
-
inline virtual ::CE::Rendering::GraphicsDomain graphics_domain() const noexcept override
Declaration:
[[nodiscard]]Optional portable domain token; custom adapters may return an empty token.
-
virtual void maintain_resources() override
Unbind the current program and collect retired native objects even without a fresh frame.
Requires initialized live owner/current context; does not make another context current. Optional diagnostic reporting occurs on the owner. It neither recycles simulation frames nor presents.
-
virtual void render(const ::CE::Rendering::Frame &frame) override
Play active passes and packets in authored order on the live owner/current context.
- Parameters:
frame – Stable published frame borrowed through the call; retain it without writes/recycle. Every packet validates common contracts and must use a same-domain OpenGL pipeline/geometry/images/samplers. Copied packet values drive playback; live cameras/assets are not queried. Failures may leave earlier draws/state applied. Does not clear, present or recycle the frame.
-
virtual void clear() override
Clear color and depth buffers after enabling depth writes and disabling scissor.
Requires initialized live owner/current context; current clear color applies. Does not present or restore the previous depth-write/scissor state.
-
virtual void set_viewport(::CE::Platform::FramebufferSize size) override
Set native viewport origin to zero and retain the playback framebuffer extent.
- Parameters:
size – Nonnegative pixel width/height; zero minimized extents are allowed. Negative dimensions throw invalid_args before viewport mutation; live owner/current context is required. Retained clips resolve against this stored pixel extent.
-
virtual void set_depth_test(bool enabled) override
Set the legacy native depth-test enable flag on the live owner/current context.
- Parameters:
enabled – Whether to enable GL_DEPTH_TEST. Retained pipeline draws later reapply their complete fixed depth state; camera dimensionality does not determine it.
-
virtual void set_clear_colour(float r, float g, float b, float a) override
Set native clear color on the live owner/current context.
-
virtual void set_camera_matrices(const glm::mat4 &projection, const glm::mat4 &view) override
Copy legacy renderer matrix observations on the live owner/current context.
- Parameters:
projection – Borrowed matrix copied during the call.
view – Borrowed matrix copied during the call. Retained packet playback uses its resolved parameter values rather than consulting a live camera or these legacy observations.
-
std::shared_ptr<::CE::Rendering::OpenGL::ResourceLifetime> resources() const
Declaration:
[[nodiscard]]See also
- Throws:
CE::Exceptions::failed_operation – Before initialization or for foreign/stopped/noncurrent native access. Retaining the returned lifetime does not keep the borrowed platform context alive.
- Returns:
Retained native lifetime after checking initialized state and live owner/current context.
-
explicit Renderer(::CE::Rendering::OpenGL::Context &context)