Skip to main content

ImGuiGlfwOpenGLBackend Class

ImGui backend for GLFW windowing and OpenGL 4.6 rendering. More...

Declaration

class helios::ext::imgui::ImGuiGlfwOpenGLBackend { ... }

Base class

classImGuiBackend

Platform-agnostic interface for ImGui backend implementations. More...

Public Constructors Index

ImGuiGlfwOpenGLBackend (const ImGuiGlfwOpenGLBackend &)=delete
ImGuiGlfwOpenGLBackend (ImGuiGlfwOpenGLBackend &&other) noexcept=delete
ImGuiGlfwOpenGLBackend (GLFWwindow *window)

Constructs and initializes the ImGui backend for GLFW+OpenGL. More...

Public Destructor Index

~ImGuiGlfwOpenGLBackend () override

Destructor; shuts down ImGui backend and releases resources. More...

Public Operators Index

ImGuiGlfwOpenGLBackend &operator= (const ImGuiGlfwOpenGLBackend &)=delete
ImGuiGlfwOpenGLBackend &operator= (ImGuiGlfwOpenGLBackend &&other) noexcept=delete

Public Member Functions Index

voidrenderDrawData (ImDrawData *drawData) override

Renders ImGui draw data using OpenGL. More...

voidnewFrame () override

Starts a new ImGui frame. More...

Private Member Functions Index

voidshutdown () noexcept

Shuts down the ImGui GLFW and OpenGL backend. More...

Private Member Attributes Index

boolinitialized_ = false

Indicates whether the backend has been successfully initialized. More...

Description

ImGui backend for GLFW windowing and OpenGL 4.6 rendering.

Initializes ImGui context, GLFW platform layer, and OpenGL renderer. This backend is non-copyable and non-movable due to resource ownership semantics.

info

Only one instance should exist per application. Creating multiple instances will throw a `std::runtime_error`.

Definition at line 29 of file ImGuiGlfwOpenGLBackend.ixx.

Public Constructors

ImGuiGlfwOpenGLBackend()

helios::ext::imgui::ImGuiGlfwOpenGLBackend::ImGuiGlfwOpenGLBackend (const ImGuiGlfwOpenGLBackend &)
delete

ImGuiGlfwOpenGLBackend()

helios::ext::imgui::ImGuiGlfwOpenGLBackend::ImGuiGlfwOpenGLBackend (ImGuiGlfwOpenGLBackend && other)
noexcept delete

Definition at line 69 of file ImGuiGlfwOpenGLBackend.ixx.

Reference ImGuiGlfwOpenGLBackend.

ImGuiGlfwOpenGLBackend()

helios::ext::imgui::ImGuiGlfwOpenGLBackend::ImGuiGlfwOpenGLBackend (GLFWwindow * window)
inline explicit

Constructs and initializes the ImGui backend for GLFW+OpenGL.

Parameters
window

GLFW window handle. Must be valid for the lifetime of this backend.

Exceptions
std::runtime_error

if ImGui context already exists or initialization fails.

Definition at line 79 of file ImGuiGlfwOpenGLBackend.ixx.

79 explicit ImGuiGlfwOpenGLBackend(GLFWwindow* window) {
80
81 if (ImGui::GetCurrentContext()) {
82 throw std::runtime_error("ImGui context already initialized");
83 }
84
85 IMGUI_CHECKVERSION();
86 ImGui::CreateContext();
87 ImGuiIO& io = ImGui::GetIO();
88 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
89 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
90
91 ImGui::StyleColorsDark();
92
93 if (!ImGui_ImplGlfw_InitForOpenGL(window, true)) {
94 ImGui::DestroyContext();
95 throw std::runtime_error("Failed to initialize GLFW backend for ImGui");
96 }
97
98 if (!ImGui_ImplOpenGL3_Init("#version 460")) {
99 ImGui_ImplGlfw_Shutdown();
100 ImGui::DestroyContext();
101 throw std::runtime_error("Failed to initialize OpenGL 4.6 backend for ImGui");
102 }
103 initialized_ = true;
104 }

Public Destructor

~ImGuiGlfwOpenGLBackend()

helios::ext::imgui::ImGuiGlfwOpenGLBackend::~ImGuiGlfwOpenGLBackend ()
inline

Destructor; shuts down ImGui backend and releases resources.

See Also

shutdown()

Definition at line 129 of file ImGuiGlfwOpenGLBackend.ixx.

130 shutdown();
131 }

Public Operators

operator=()

ImGuiGlfwOpenGLBackend & helios::ext::imgui::ImGuiGlfwOpenGLBackend::operator= (const ImGuiGlfwOpenGLBackend &)
delete

Definition at line 68 of file ImGuiGlfwOpenGLBackend.ixx.

Reference ImGuiGlfwOpenGLBackend.

operator=()

ImGuiGlfwOpenGLBackend & helios::ext::imgui::ImGuiGlfwOpenGLBackend::operator= (ImGuiGlfwOpenGLBackend && other)
noexcept delete

Definition at line 70 of file ImGuiGlfwOpenGLBackend.ixx.

Reference ImGuiGlfwOpenGLBackend.

Public Member Functions

newFrame()

void helios::ext::imgui::ImGuiGlfwOpenGLBackend::newFrame ()
inline virtual

Starts a new ImGui frame.

Definition at line 118 of file ImGuiGlfwOpenGLBackend.ixx.

118 void newFrame() override {
119 ImGui_ImplOpenGL3_NewFrame();
120 ImGui_ImplGlfw_NewFrame();
121 ImGui::NewFrame();
122 }

renderDrawData()

void helios::ext::imgui::ImGuiGlfwOpenGLBackend::renderDrawData (ImDrawData * drawData)
inline virtual

Renders ImGui draw data using OpenGL.

Parameters
drawData

Pointer to ImGui draw data.

Definition at line 111 of file ImGuiGlfwOpenGLBackend.ixx.

111 void renderDrawData(ImDrawData* drawData) override {
112 ImGui_ImplOpenGL3_RenderDrawData(drawData);
113 }

Private Member Functions

shutdown()

void helios::ext::imgui::ImGuiGlfwOpenGLBackend::shutdown ()
inline noexcept

Shuts down the ImGui GLFW and OpenGL backend.

Ensures proper cleanup of the ImGui context, OpenGL, and GLFW resources. After calling this method, the backend will no longer be initialized, and associated resources will be released.

This function is safe to call multiple times but has no effect if the backend is not currently initialized.

info

This method is noexcept and will not throw exceptions.

Definition at line 55 of file ImGuiGlfwOpenGLBackend.ixx.

55 void shutdown() noexcept {
56 if (initialized_) {
57 ImGui_ImplOpenGL3_Shutdown();
58 ImGui_ImplGlfw_Shutdown();
59 ImGui::DestroyContext();
60 initialized_ = false;
61 }
62 }

Private Member Attributes

initialized_

bool helios::ext::imgui::ImGuiGlfwOpenGLBackend::initialized_ = false

Indicates whether the backend has been successfully initialized.

Tracks the initialization state of the ImGui backend to prevent multiple redundant initialization attempts and manage proper shutdown procedures.

info

Modified during initialization and shutdown processes.

Definition at line 41 of file ImGuiGlfwOpenGLBackend.ixx.

41 bool initialized_ = false;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.