MetaImGUI 1.0.0
ImGui Application Template for C++20
Loading...
Searching...
No Matches
MetaImGUI::WindowManager Class Reference

Manages GLFW window creation, lifecycle, and input handling. More...

#include <WindowManager.h>

Public Member Functions

 WindowManager (std::string title, int width, int height)
 Construct a new Window Manager.
 
 ~WindowManager ()
 
 WindowManager (const WindowManager &)=delete
 
WindowManageroperator= (const WindowManager &)=delete
 
 WindowManager (WindowManager &&)=delete
 
WindowManageroperator= (WindowManager &&)=delete
 
bool Initialize ()
 Initialize the window and GLFW.
 
void Shutdown ()
 Shutdown and cleanup the window.
 
bool ShouldClose () const
 Check if the window should close.
 
void PollEvents ()
 Poll for input events.
 
void BeginFrame ()
 Prepare the window for a new frame.
 
void EndFrame ()
 Present the rendered frame.
 
void GetFramebufferSize (int &width, int &height) const
 Get the current framebuffer size.
 
void GetWindowSize (int &width, int &height) const
 Get the current window size.
 
GLFWwindow * GetNativeWindow () const
 Get the GLFW window pointer (for ImGui integration)
 
void RequestClose ()
 Request the window to close.
 
void SetFramebufferSizeCallback (std::function< void(int, int)> callback)
 Set framebuffer size callback.
 
void SetKeyCallback (std::function< void(int, int, int, int)> callback)
 Set key input callback.
 
void SetWindowCloseCallback (std::function< void()> callback)
 Set window close callback.
 
void CancelClose ()
 Cancel a close request (clears the should close flag)
 
void SetContextLossCallback (std::function< bool()> callback)
 Set context loss callback.
 
bool ValidateContext ()
 Check if context is valid and attempt recovery if not.
 

Detailed Description

Manages GLFW window creation, lifecycle, and input handling.

WindowManager encapsulates all GLFW-specific operations, providing a clean interface for window management without exposing GLFW details to the application.

Definition at line 35 of file WindowManager.h.

Constructor & Destructor Documentation

◆ WindowManager() [1/3]

MetaImGUI::WindowManager::WindowManager ( std::string  title,
int  width,
int  height 
)

Construct a new Window Manager.

Parameters
titleWindow title
widthInitial window width
heightInitial window height

Definition at line 33 of file WindowManager.cpp.

◆ ~WindowManager()

MetaImGUI::WindowManager::~WindowManager ( )

Definition at line 36 of file WindowManager.cpp.

References Shutdown().

◆ WindowManager() [2/3]

MetaImGUI::WindowManager::WindowManager ( const WindowManager )
delete

◆ WindowManager() [3/3]

MetaImGUI::WindowManager::WindowManager ( WindowManager &&  )
delete

Member Function Documentation

◆ BeginFrame()

void MetaImGUI::WindowManager::BeginFrame ( )

Prepare the window for a new frame.

Definition at line 131 of file WindowManager.cpp.

References GL_CONTEXT_LOST, LOG_ERROR, LOG_WARNING, and ValidateContext().

◆ CancelClose()

void MetaImGUI::WindowManager::CancelClose ( )

Cancel a close request (clears the should close flag)

Definition at line 221 of file WindowManager.cpp.

◆ EndFrame()

void MetaImGUI::WindowManager::EndFrame ( )

Present the rendered frame.

Definition at line 161 of file WindowManager.cpp.

References LOG_ERROR, and ValidateContext().

◆ GetFramebufferSize()

void MetaImGUI::WindowManager::GetFramebufferSize ( int &  width,
int &  height 
) const

Get the current framebuffer size.

Parameters
widthOutput: framebuffer width
heightOutput: framebuffer height

Definition at line 176 of file WindowManager.cpp.

◆ GetNativeWindow()

GLFWwindow * MetaImGUI::WindowManager::GetNativeWindow ( ) const
inline

Get the GLFW window pointer (for ImGui integration)

Returns
GLFWwindow pointer

Definition at line 102 of file WindowManager.h.

◆ GetWindowSize()

void MetaImGUI::WindowManager::GetWindowSize ( int &  width,
int &  height 
) const

Get the current window size.

Parameters
widthOutput: window width
heightOutput: window height

Definition at line 185 of file WindowManager.cpp.

◆ Initialize()

bool MetaImGUI::WindowManager::Initialize ( )

Initialize the window and GLFW.

Returns
true if initialization succeeded, false otherwise

Definition at line 40 of file WindowManager.cpp.

References LOG_ERROR, and LOG_INFO.

◆ operator=() [1/2]

WindowManager & MetaImGUI::WindowManager::operator= ( const WindowManager )
delete

◆ operator=() [2/2]

WindowManager & MetaImGUI::WindowManager::operator= ( WindowManager &&  )
delete

◆ PollEvents()

void MetaImGUI::WindowManager::PollEvents ( )

Poll for input events.

Definition at line 127 of file WindowManager.cpp.

◆ RequestClose()

void MetaImGUI::WindowManager::RequestClose ( )

Request the window to close.

Definition at line 194 of file WindowManager.cpp.

◆ SetContextLossCallback()

void MetaImGUI::WindowManager::SetContextLossCallback ( std::function< bool()>  callback)

Set context loss callback.

Parameters
callbackFunction to call when OpenGL context is lost (for recovery)
Returns
true if context was successfully recreated

Definition at line 227 of file WindowManager.cpp.

◆ SetFramebufferSizeCallback()

void MetaImGUI::WindowManager::SetFramebufferSizeCallback ( std::function< void(int, int)>  callback)

Set framebuffer size callback.

Parameters
callbackFunction to call when framebuffer size changes

Definition at line 200 of file WindowManager.cpp.

◆ SetKeyCallback()

void MetaImGUI::WindowManager::SetKeyCallback ( std::function< void(int, int, int, int)>  callback)

Set key input callback.

Parameters
callbackFunction to call when key is pressed

Definition at line 207 of file WindowManager.cpp.

◆ SetWindowCloseCallback()

void MetaImGUI::WindowManager::SetWindowCloseCallback ( std::function< void()>  callback)

Set window close callback.

Parameters
callbackFunction to call when window close is requested

Definition at line 214 of file WindowManager.cpp.

◆ ShouldClose()

bool MetaImGUI::WindowManager::ShouldClose ( ) const

Check if the window should close.

Returns
true if the window should close

Definition at line 123 of file WindowManager.cpp.

◆ Shutdown()

void MetaImGUI::WindowManager::Shutdown ( )

Shutdown and cleanup the window.

Definition at line 109 of file WindowManager.cpp.

Referenced by ~WindowManager().

◆ ValidateContext()

bool MetaImGUI::WindowManager::ValidateContext ( )

Check if context is valid and attempt recovery if not.

Returns
true if context is valid or was successfully recovered

Definition at line 231 of file WindowManager.cpp.

References GL_CONTEXT_LOST, and LOG_WARNING.

Referenced by BeginFrame(), and EndFrame().


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