Window

Window management and context handling.

Overview

Typical use cases:

  • Managing window creation, resizing, and input handling.

Header

<RaeptorCogs/Window.hpp>

Metadata

Author

Estorc

Version

v1.0

Copyright

Copyright (c) 2025 Estorc MIT License.

Enums

Enumerations

Enum

Description

RaeptorCogs::WindowFlags

Window flags enumeration.

enum class RaeptorCogs::WindowFlags : uint32_t

Window flags enumeration.

Defines flags for window state management.

Values:

enumerator NONE

No flags set

enumerator CONTEXT_ONLY

Context only flag (for GLAD initialization)

enumerator DESTROY_AFTER_INIT

Destroy after initialization flag

Classes

Classes

Class

Description

RaeptorCogs::Window

Class representing a window.

class Window : public RaeptorCogs::FlagSet<WindowFlags>

Class representing a window.

Manages window creation, resizing, and input handling.

Public Functions

Window(int width, int height, const std::string &title, GLFWmonitor *monitor, GLFWwindow *share, RaeptorCogs::GAPI::Common::WindowContext *context = nullptr, WindowFlags flags = WindowFlags::NONE)

Constructor for Window.

Note

Initializes the GLFW window with the specified parameters.

Parameters:
  • width – Width of the window.

  • height – Height of the window.

  • title – Title of the window.

  • monitor – Pointer to the GLFW monitor (for fullscreen).

  • share – Pointer to another GLFW window to share resources with.

  • context – Pointer to a custom window context (optional).

  • flagsWindow flags for configuration.

~Window()

Destructor for Window.

Cleans up resources associated with the window.

GLFWwindow *getGLFWWindow() const

Get the underlying GLFW window pointer.

Returns:

Pointer to the GLFWwindow.

unsigned int getWidth() const

Get the width of the window.

Returns:

Width of the window in pixels.

unsigned int getHeight() const

Get the height of the window.

Returns:

Height of the window in pixels.

glm::ivec2 getSize() const

Get the size of the window.

Returns:

Size of the window as a glm::ivec2 (width, height).

glm::ivec2 getMousePosition() const

Get the current mouse position within the window.

Returns:

Mouse position as a glm::ivec2 (x, y).

bool isMouseInWindow() const

Check if the mouse cursor is within the window bounds.

Returns:

true if the mouse is inside the window, false otherwise.

const std::string &getTitle() const

Get the title of the window.

Returns:

Reference to the window title string.

RaeptorCogs::GAPI::Common::WindowContext *getContext() const

Get the window context used for rendering.

Returns:

Pointer to the WindowContext object.

void makeContextCurrent()

Make the window’s context current.

Sets the OpenGL context of this window as the current context for rendering.

void setTitle(const std::string &newTitle)

Set the title of the window.

Parameters:

newTitle – New title for the window.

void setSize(int width, int height)

Set the size of the window.

Note

Resizes the window to the specified dimensions.

Parameters:
  • width – New width of the window in pixels.

  • height – New height of the window in pixels.

void setIcon(const std::vector<std::string> &iconPaths)

Set the icon of the window.

Parameters:

iconPaths – Vector of file paths to the icon images.

void selectCursor(int cursorShape)

Select the cursor shape for the window.

Parameters:

cursorShape – Integer representing the cursor shape.

Private Members

GLFWwindow *window

Pointer to the underlying GLFW window.

Used for low-level window management.

std::string title

Window title.

Holds the current title of the window.

std::unordered_map<int, GLFWcursor*> cursors

Map of custom cursors.

Holds GLFWcursor pointers for different cursor shapes.

RaeptorCogs::GAPI::Common::WindowContext *context = nullptr

Window context for rendering.

Holds the context used for rendering operations.