Orrery
A GPU-accelerated N-body gravitational simulator
Toggle main menu visibility
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
34
namespace
orrery::viz {
35
37
struct
WindowOptions
{
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
59
enum class
Key
: std::uint8_t {
60
kQuit,
61
kPause,
62
kBrighter,
63
kDarker,
64
kReset,
65
kCapture,
66
};
67
69
class
ViewerWindow
{
70
public
:
78
explicit
ViewerWindow
(
const
WindowOptions
& options);
79
80
~ViewerWindow
();
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
123
private:
124
struct State;
125
std::unique_ptr<State> state_;
126
};
127
128
}
// namespace orrery::viz
camera.hpp
The camera, as three angles and a distance.
orrery::viz::OrbitCamera
A camera that orbits a point.
Definition
camera.hpp:42
orrery::viz::ViewerWindow::loader
static GlProcedureLoader loader() noexcept
How the renderer resolves OpenGL entry points.
orrery::viz::ViewerWindow::poll
void poll()
Handle everything that has happened since the last call.
orrery::viz::ViewerWindow::ViewerWindow
ViewerWindow(const WindowOptions &options)
Create the window and make its context current on this thread.
orrery::viz::ViewerWindow::request_close
void request_close() noexcept
Ask the window to close, which the loop notices on its next turn.
orrery::viz::ViewerWindow::held
bool held(Key key) const noexcept
Whether key is held down now, for the controls that should repeat.
orrery::viz::ViewerWindow::pressed
bool pressed(Key key) const noexcept
Whether key went down during the most recent poll.
orrery::viz::ViewerWindow::width
std::size_t width() const noexcept
The size of the drawable surface in pixels.
gl_api.hpp
The OpenGL entry points this renderer uses, and only those.
orrery::viz::GlProcedureLoader
void(*(*)(const char *))() GlProcedureLoader
How a function is fetched from the driver.
Definition
gl_api.hpp:97
orrery::viz::WindowOptions
How the window is created.
Definition
viewer_window.hpp:37
orrery::viz::WindowOptions::vertical_sync
bool vertical_sync
Whether presenting waits for the display's refresh.
Definition
viewer_window.hpp:52
orrery::viz::WindowOptions::visible
bool visible
Whether the window appears on screen.
Definition
viewer_window.hpp:45
orrery::viz::Key
Key
The keys the viewer asks about.
Definition
viewer_window.hpp:59
orrery
viz
viewer_window.hpp
Generated by
1.17.0