Avara3D 0.2.0
C++ API reference
ImguiContext.h
1//
2// ImguiContext.h
3// avara3d
4//
5// Created by Morgan Davis on 8/10/26.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_RENDER_BACKEND_OPENGL_IMGUICONTEXT_H
10#define AVARA3D_RENDER_BACKEND_OPENGL_IMGUICONTEXT_H
11
12#include <memory>
13#include <vector>
14
15struct ImFont;
16struct ImGuiContext;
17
18namespace a3d {
19
20 class Font;
21 class RenderContext;
22
23 class ImguiContext {
24
25 public:
26 // [Internal Lifecycle Functions]
27
28 ImguiContext();
29
30 ImguiContext(const ImguiContext&) = delete;
31 ImguiContext& operator=(const ImguiContext&) = delete;
32
33 ImguiContext(ImguiContext&&) = delete;
34 ImguiContext& operator=(ImguiContext&&) = delete;
35
36 ~ImguiContext();
37
38 // [Internal Member Functions]
39
40 void startup(const RenderContext& context);
41 void shutdown();
42
43 ImFont* addFont(std::unique_ptr<Font> font);
44 ImFont* defaultFont() const;
45
46 void beginFrame(const RenderContext& context);
47 void endFrame();
48
49 bool isStarted() const;
50
51 private:
52 // [Private Member Functions]
53
54 void makeCurrent() const;
55 void updateDisplayMetrics(const RenderContext& context);
56 void rebuildDeviceObjects();
57
58 // [Private Member Variables]
59
60 ImGuiContext* _context;
61 std::vector<std::unique_ptr<Font>> _fontSources;
62 ImFont* _defaultFont;
63 bool _fontAtlasDirty;
64 bool _frameActive;
65 bool _started;
66 };
67
68}
69
70#endif // AVARA3D_RENDER_BACKEND_OPENGL_IMGUICONTEXT_H