imgui-platform-kit 2.0.0
Cross-platform Dear ImGui application framework
Loading...
Searching...
No Matches
glfw_opengl3_user_interface.h
Go to the documentation of this file.
1
2#pragma once
3
13#if defined(__APPLE__)
14
15#include "imgui.h"
16#include "imgui_impl_glfw.h"
17#include "imgui_impl_opengl3.h"
18
19#include <memory>
20#include <string>
21#include <iostream>
22#include <utility>
23#include <vector>
24#include <filesystem>
25
26#include <stdio.h>
27// Silence OpenGL deprecation warnings on macOS (OpenGL deprecated since 10.14 but still functional)
28#define GL_SILENCE_DEPRECATION
29#include <GLFW/glfw3.h> // Will drag system OpenGL headers
30
31#include "implot.h"
32#include "implot_internal.h"
33
34#include "imgui-node-editor/imgui_node_editor.h"
35namespace ImNodeEditor = ax::NodeEditor;
36
37#include "../user_interface_parameters.h"
38#include "../user_interface_window.h"
39
40namespace imgui_kit
41{
46 struct GLFWbackgroundImageTexture
47 {
48 GLuint texture;
49 BackgroundImageParameters parameters;
50
51 GLFWbackgroundImageTexture()
52 : texture(0)
53 , parameters()
54 {}
55
56 explicit GLFWbackgroundImageTexture(BackgroundImageParameters parameters)
57 : texture(0), parameters(std::move(parameters))
58 {}
59 };
60
69 class UserInterface
70 {
71 private:
72 UserInterfaceParameters parameters;
73 GLFWbackgroundImageTexture backgroundImageTexture;
74 GLFWwindow* window;
75 std::vector<std::shared_ptr<UserInterfaceWindow>> windows;
76 bool shutdownRequest;
77 public:
79 explicit UserInterface(UserInterfaceParameters parameters);
80 ~UserInterface() = default;
81
82 void initialize();
83 void render();
84 void shutdown() const;
85 [[nodiscard]] bool isShutdownRequested() const;
86 template<typename T, typename... Args>
87 void addWindow(Args&&... args)
88 {
89 auto window = std::make_shared<T>(std::forward<Args>(args)...);
90 windows.push_back(std::move(window));
91 }
92 private:
93 void loadIcon() const;
94 void loadFont();
95 void loadBackgroundImage();
96 void renderWindows() const;
97 void renderBackgroundImage() const;
98 void updateLastRenderedFrameDimensions();
99 void updateFontGlobalScale() const;
100 };
101
102}
103
104// Forward declarations of helper functions
105bool LoadTextureFromFile(const char* filename, GLuint* out_texture, int* out_width, int* out_height);
106float GetDpiScale(GLFWwindow* window);
107GLFWmonitor* GetActiveMonitor(GLFWwindow* window);
108#endif
void addWindow(Args &&... args)
Constructs a window of type T and registers it for rendering.
Definition win32_dx12_user_interface.h:157
void shutdown()
Destroys the rendering backend, the ImGui contexts and the platform window.
bool isShutdownRequested() const
Returns true once the user has requested to close the window.
void initialize()
Creates the platform window, sets up the rendering backend and the ImGui/ImPlot/node-editor contexts,...
void render()
Renders one frame: processes platform events and calls render() on every registered window.
UserInterface()
Constructs the interface with default UserInterfaceParameters.
Definition colour_palette.h:11