Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
viewer_window.hpp
Go to the documentation of this file.
1#pragma once
2
26
27#include <cstddef>
28#include <memory>
29#include <string>
30
31#include "orrery/viz/camera.hpp"
32#include "orrery/viz/gl_api.hpp"
33
34namespace orrery::viz {
35
38 std::size_t width = 1280;
39 std::size_t height = 720;
40 std::string title = "Orrery";
41
45 bool visible = true;
46
52 bool vertical_sync = true;
53};
54
59enum class Key : std::uint8_t {
60 kQuit,
61 kPause,
62 kBrighter,
63 kDarker,
64 kReset,
65 kCapture,
66};
67
70public:
78 explicit ViewerWindow(const WindowOptions& options);
79
81
82 ViewerWindow(const ViewerWindow&) = delete;
83 ViewerWindow& operator=(const ViewerWindow&) = delete;
84 ViewerWindow(ViewerWindow&&) = delete;
85 ViewerWindow& operator=(ViewerWindow&&) = delete;
86
88 [[nodiscard]] static GlProcedureLoader loader() noexcept;
89
95 [[nodiscard]] std::size_t width() const noexcept;
96 [[nodiscard]] std::size_t height() const noexcept;
97
98 [[nodiscard]] bool should_close() const noexcept;
99
101 void request_close() noexcept;
102
110 void poll();
111
113 [[nodiscard]] bool pressed(Key key) const noexcept;
114
116 [[nodiscard]] bool held(Key key) const noexcept;
117
118 void present();
119
120 [[nodiscard]] OrbitCamera& camera() noexcept;
121 [[nodiscard]] const OrbitCamera& camera() const noexcept;
122
123private:
124 struct State;
125 std::unique_ptr<State> state_;
126};
127
128} // namespace orrery::viz
The camera, as three angles and a distance.
A camera that orbits a point.
Definition camera.hpp:42
static GlProcedureLoader loader() noexcept
How the renderer resolves OpenGL entry points.
void poll()
Handle everything that has happened since the last call.
ViewerWindow(const WindowOptions &options)
Create the window and make its context current on this thread.
void request_close() noexcept
Ask the window to close, which the loop notices on its next turn.
bool held(Key key) const noexcept
Whether key is held down now, for the controls that should repeat.
bool pressed(Key key) const noexcept
Whether key went down during the most recent poll.
std::size_t width() const noexcept
The size of the drawable surface in pixels.
The OpenGL entry points this renderer uses, and only those.
void(*(*)(const char *))() GlProcedureLoader
How a function is fetched from the driver.
Definition gl_api.hpp:97
How the window is created.
Definition viewer_window.hpp:37
bool vertical_sync
Whether presenting waits for the display's refresh.
Definition viewer_window.hpp:52
bool visible
Whether the window appears on screen.
Definition viewer_window.hpp:45
Key
The keys the viewer asks about.
Definition viewer_window.hpp:59