FuncDoodle
Loading...
Searching...
No Matches
FuncDoodle::Platform::Window Class Reference

Abstraction over a GLFW window with input, rendering, and lifecycle utilities. More...

#include <Window.h>

Public Types

using DropCallback = std::function<void(Window*, int, const char**)>
 Callback type invoked for file-drop events.
using ErrorCallback = void (*)(int err, const char* desc)
 Callback type invoked for GLFW errors.
using CloseCallback = std::function<void(Window*)>
 Callback type invoked when the window is asked to close.

Public Member Functions

 Window (WindowSpec spec)
 Creates a window from an initial specification.
 ~Window ()
void SetTitle (const char *title)
 Sets the window title.
void SetIcon (std::filesystem::path icon)
 Sets the window icon from a file path.
void SetDropCallback (DropCallback cb)
 Sets callback for file drop events.
void SetCloseCallback (CloseCallback cb)
 Sets callback for window close events.
void SetShouldClose (bool shouldClose)
 Requests the window to close.
bool ShouldClose ()
 Returns whether the window should close.
void GetFramebufferSize (int *width, int *height)
 Retrieves framebuffer size in pixels.
void SwapBuffers ()
 Swaps front and back buffers.
void SetCursorHidden (bool hidden)
 Enables or disables cursor visibility.
bool GetCursorHidden () const
 Returns whether the cursor is currently hidden.
void InitImGui ()
 Initializes ImGui for this window.

Static Public Member Functions

static void SetErrorCallback (ErrorCallback cb)
 Sets GLFW error callback.
static void PollEvents ()
 Polls OS and input events.
static void InitGlfw ()
 Initializes GLFW (must be called once before creating windows).

Protected Attributes

DropCallback mp_DropCallback
 Stored file-drop callback.
CloseCallback mp_CloseCallback
 Stored close callback.

Static Private Member Functions

static void GlfwDropTrampoline (GLFWwindow *glfwWin, int count, const char **paths)
static void GlfwCloseTrampoline (GLFWwindow *glfwWin)

Private Attributes

GLFWwindow * m_Handle
bool m_CursorHidden
WindowSpec m_Spec
GLFWcursor * m_BlankCursor = nullptr

Detailed Description

Abstraction over a GLFW window with input, rendering, and lifecycle utilities.

Member Typedef Documentation

◆ CloseCallback

using FuncDoodle::Platform::Window::CloseCallback = std::function<void(Window*)>

Callback type invoked when the window is asked to close.

◆ DropCallback

using FuncDoodle::Platform::Window::DropCallback = std::function<void(Window*, int, const char**)>

Callback type invoked for file-drop events.

◆ ErrorCallback

using FuncDoodle::Platform::Window::ErrorCallback = void (*)(int err, const char* desc)

Callback type invoked for GLFW errors.

Constructor & Destructor Documentation

◆ Window()

FuncDoodle::Platform::Window::Window ( WindowSpec spec)

Creates a window from an initial specification.

Parameters
specWindow creation parameters.

◆ ~Window()

FuncDoodle::Platform::Window::~Window ( )

Member Function Documentation

◆ GetCursorHidden()

bool FuncDoodle::Platform::Window::GetCursorHidden ( ) const
inlinenodiscard

Returns whether the cursor is currently hidden.

◆ GetFramebufferSize()

void FuncDoodle::Platform::Window::GetFramebufferSize ( int * width,
int * height )

Retrieves framebuffer size in pixels.

◆ GlfwCloseTrampoline()

void FuncDoodle::Platform::Window::GlfwCloseTrampoline ( GLFWwindow * glfwWin)
staticprivate

◆ GlfwDropTrampoline()

void FuncDoodle::Platform::Window::GlfwDropTrampoline ( GLFWwindow * glfwWin,
int count,
const char ** paths )
staticprivate

◆ InitGlfw()

void FuncDoodle::Platform::Window::InitGlfw ( )
static

Initializes GLFW (must be called once before creating windows).

◆ InitImGui()

void FuncDoodle::Platform::Window::InitImGui ( )

Initializes ImGui for this window.

◆ PollEvents()

void FuncDoodle::Platform::Window::PollEvents ( )
static

Polls OS and input events.

◆ SetCloseCallback()

void FuncDoodle::Platform::Window::SetCloseCallback ( CloseCallback cb)

Sets callback for window close events.

◆ SetCursorHidden()

void FuncDoodle::Platform::Window::SetCursorHidden ( bool hidden)

Enables or disables cursor visibility.

◆ SetDropCallback()

void FuncDoodle::Platform::Window::SetDropCallback ( DropCallback cb)

Sets callback for file drop events.

◆ SetErrorCallback()

void FuncDoodle::Platform::Window::SetErrorCallback ( ErrorCallback cb)
static

Sets GLFW error callback.

◆ SetIcon()

void FuncDoodle::Platform::Window::SetIcon ( std::filesystem::path icon)

Sets the window icon from a file path.

◆ SetShouldClose()

void FuncDoodle::Platform::Window::SetShouldClose ( bool shouldClose)

Requests the window to close.

◆ SetTitle()

void FuncDoodle::Platform::Window::SetTitle ( const char * title)

Sets the window title.

◆ ShouldClose()

bool FuncDoodle::Platform::Window::ShouldClose ( )

Returns whether the window should close.

◆ SwapBuffers()

void FuncDoodle::Platform::Window::SwapBuffers ( )

Swaps front and back buffers.

Member Data Documentation

◆ m_BlankCursor

GLFWcursor* FuncDoodle::Platform::Window::m_BlankCursor = nullptr
private

◆ m_CursorHidden

bool FuncDoodle::Platform::Window::m_CursorHidden
private

◆ m_Handle

GLFWwindow* FuncDoodle::Platform::Window::m_Handle
private

◆ m_Spec

WindowSpec FuncDoodle::Platform::Window::m_Spec
private

◆ mp_CloseCallback

CloseCallback FuncDoodle::Platform::Window::mp_CloseCallback
protected

Stored close callback.

◆ mp_DropCallback

DropCallback FuncDoodle::Platform::Window::mp_DropCallback
protected

Stored file-drop callback.


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