pulsatrix 1.1.0
Loading...
Searching...
No Matches
window.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <functional>
8#include <string>
9#include <vector>
10
12
13// Only compiled when PULSATRIX_ENABLE_VIZ builds pulsatrix_viz (see root CMakeLists.txt) --
14// this is the one header in the viz module allowed to assume ImGui/ImPlot/GLFW are present.
15// pulsatrix_core never includes this header or links pulsatrix_viz (charter non-negotiable
16// #2's plugin-boundary discipline, extended to the native viz module).
17struct GLFWwindow;
18
19namespace pulsatrix {
20
30class VizWindow {
31public:
38 VizWindow(const std::string& title, int width, int height);
41 VizWindow(const std::string& title, int width, int height, const VizFontOptions& fonts);
43 [[nodiscard]] const std::vector<VizFontFile>& fonts() const { return fonts_; }
44
46
47 VizWindow(const VizWindow&) = delete;
48 VizWindow& operator=(const VizWindow&) = delete;
49
55 void run(const std::function<void()>& draw_frame);
56
63 void run(const std::function<void()>& draw_frame, const std::function<void(int, int)>& after_render);
64
67
68private:
69 GLFWwindow* window_;
70 std::vector<VizFontFile> fonts_;
71};
72
73} // namespace pulsatrix
Owns a GLFW window, OpenGL3 context, and ImGui/ImPlot context for the lifetime of one demo app....
Definition window.hpp:30
VizWindow & operator=(const VizWindow &)=delete
VizWindow(const std::string &title, int width, int height, const VizFontOptions &fonts)
The same, with chosen fonts. The three-argument form uses DefaultVizFontOptions(): ImGui's default fo...
const std::vector< VizFontFile > & fonts() const
The fonts merged into the default font, in priority order.
Definition window.hpp:43
void run(const std::function< void()> &draw_frame)
Runs the main loop, calling draw_frame() once per frame between ImGui::NewFrame()/ImGui::Render(),...
VizWindow(const VizWindow &)=delete
void run(const std::function< void()> &draw_frame, const std::function< void(int, int)> &after_render)
Same as run(draw_frame), plus after_render(framebuffer_width, framebuffer_height) called once per fra...
void request_close()
Asks the main loop to exit after the current frame (e.g. a scripted/screenshot run).
VizWindow(const std::string &title, int width, int height)
Creates the GLFW window, OpenGL3 context, and ImGui/ImPlot contexts.
Fonts for the ImGui windows that cover every script: the default font first, then system fonts merged...
Definition acquisition_functions.hpp:16
Which fonts a VizWindow loads.
Definition fonts.hpp:20