Avara3D 0.2.0
C++ API reference
RenderContext.h
1//
2// RenderContext.h
3// avara3d
4//
5// Created by Morgan Davis on 4/24/18.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_RENDER_CONTEXT_RENDERCONTEXT_H
10#define AVARA3D_RENDER_CONTEXT_RENDERCONTEXT_H
11
12#include <memory>
13
14#include "a3d/Math.h"
15
16namespace a3d {
17
18 class Camera;
19 class Image;
20 class Material;
21 class Node;
22 class Renderer;
23 class RenderContext;
24 class Scene;
25 class VisualWorld;
26
35
36 public:
37 // [Public Types]
38
40 enum class Antialiasing : uint8_t {
41 None = 0,
42 Msaa2X = 2,
43 Msaa4X = 4,
44 Msaa8X = 8,
45 Msaa16X = 16
46 };
47
48 // [Public Member Functions]
49
51 virtual bool vSyncEnabled() const = 0;
52
54 virtual void vSyncEnabled(bool enabled) = 0;
55
58
64 std::unique_ptr<Image> snapshot() const;
65
68
69 // [Internal Lifecycle Functions]
70
72
73 RenderContext(const RenderContext&) = delete;
74 RenderContext& operator=(const RenderContext&) = delete;
75
76 RenderContext(RenderContext&&) = delete;
77 RenderContext& operator=(RenderContext&&) = delete;
78
79 virtual ~RenderContext();
80
81 // [Internal Member Functions]
82
83 virtual void pollEvents();
84
85 virtual void beginFrame(const Scene& scene) = 0;
86 virtual void endFrame(const Scene& scene) = 0;
87
88 virtual void swapBuffers() = 0;
89
90 virtual math::uvec2 viewportLogicalSize() const = 0; // DIPs
91 virtual math::uvec2 framebufferSize() const = 0;
92 math::vec2 viewportScale() const;
93
94 void attachedToVisualWorld(VisualWorld* world);
95 void detachedFromVisualWorld(VisualWorld* world);
96
97 virtual unsigned defaultFramebuffer() const = 0;
98
99 Renderer* renderer() const;
100
101 protected:
102 // [Protected Member Variables]
103
104 Antialiasing _antialiasing;
105 VisualWorld* _visualWorld;
106 std::unique_ptr<Renderer> _renderer;
107 };
108
109}
110
111#endif // AVARA3D_RENDER_CONTEXT_RENDERCONTEXT_H
Abstract rendering destination used by VisualWorld.
Definition: RenderContext.h:34
std::unique_ptr< Image > snapshot() const
Captures the current framebuffer into a new Image at framebuffer resolution.
Antialiasing antialiasing() const
Returns the antialiasing mode selected when the rendering target was created.
VisualWorld * visualWorld() const
Returns the attached VisualWorld, or nullptr if none is attached.
Antialiasing
Selects multisample antialiasing requested for the rendering target.
Definition: RenderContext.h:40
virtual bool vSyncEnabled() const =0
Returns whether presentation synchronization is enabled for this context.
virtual void vSyncEnabled(bool enabled)=0
Enables or disables presentation synchronization when supported by the concrete context.
Owns a scene graph and the worlds used to simulate and render it.
Definition: Scene.h:44
Manages the visual presentation, camera, and visual queries for a Scene.
Definition: VisualWorld.h:53