5#include <unordered_set>
7#include "../util/position.hpp"
8#include "../types/types.hpp"
9#include "../util/color.hpp"
11#include "../engine/exception.hpp"
68 Window(
int width,
int height, std::string title,
bool fullscreen =
false);
77 static void _processInput(GLFWwindow* win,
int key,
int scanCode,
int action,
int mods);
79 static void _scrollCallback(GLFWwindow *window,
double xOffset,
double yOffset);
Owns the application window, OpenGL context and the frame loop.
Definition window.hpp:34
bool shouldClose()
Reports whether the window has been asked to close.
Definition window.cpp:135
static void _characterCallback(GLFWwindow *window, unsigned int codepoint)
Raw GLFW character input callback, forwarded to Input.
Definition window.cpp:50
float deltaTime
Seconds elapsed since the previous frame.
Definition window.hpp:41
void swapBuffers()
Swaps the front and back framebuffers.
Definition window.cpp:147
static std::unordered_set< Key > prevKeysPressed
Keys held the previous frame (for edge detection).
Definition window.hpp:59
void onResize(int w, int h)
Updates cached state in response to a resize.
Definition window.cpp:152
void setTitle(std::string title)
Sets the window title.
Definition window.cpp:159
void endFrame()
Ends a frame: swaps buffers and polls events.
Definition window.cpp:196
int instantFps
FPS estimated from the latest frame's delta time.
Definition window.hpp:39
int frameCount
Frames counted in the current second.
Definition window.hpp:37
static void _mouseEnterCallback(GLFWwindow *window, int e)
Raw GLFW cursor enter/leave callback, forwarded to Mouse.
Definition window.cpp:42
int getInstantFPS()
Returns the instantaneous FPS from the latest frame.
Definition window.cpp:209
void beginFrame()
Begins a frame: updates timing and prepares for rendering.
Definition window.cpp:167
static void _processInput(GLFWwindow *win, int key, int scanCode, int action, int mods)
Raw GLFW keyboard callback, forwarded to Input.
Definition window.cpp:26
void fill(const Color &c)
Clears the framebuffer to a solid color.
Definition window.cpp:163
static void _mouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
Raw GLFW mouse button callback, forwarded to Mouse.
Definition window.cpp:38
double lastTime
Timestamp used for the per-second FPS counter.
Definition window.hpp:36
static Window * getInstance()
Returns the singleton instance.
Definition window.cpp:218
static std::unordered_set< Key > keysPressed
Keys held this frame.
Definition window.hpp:58
~Window()
Destroys the window and releases GLFW resources.
Definition window.cpp:129
static Window * instance
Definition window.hpp:43
double getDeltaTime()
Returns the time elapsed since the previous frame.
Definition window.cpp:214
double lastFrameTime
Timestamp of the previous frame.
Definition window.hpp:40
GLFWwindow * main
Underlying GLFW window handle.
Definition window.hpp:42
static void _scrollCallback(GLFWwindow *window, double xOffset, double yOffset)
Raw GLFW scroll callback, forwarded to Mouse.
Definition window.cpp:72
void pollEvents()
Processes pending window and input events.
Definition window.cpp:139
int fps
Frames rendered in the last full second.
Definition window.hpp:38
Dimensions dimensions
Current window size in pixels.
Definition window.hpp:60
static void _mouseMoveCallback(GLFWwindow *window, double _x, double _y)
Raw GLFW cursor move callback, forwarded to Mouse.
Definition window.cpp:46
int getFPS()
Returns the frames-per-second over the last full second.
Definition window.cpp:205
void loadGLAD()
Loads OpenGL function pointers via GLAD.
Definition window.cpp:143
Definition audiomanager.cpp:4
void resizeCallback(GLFWwindow *window, int w, int h)
GLFW framebuffer resize callback.
Definition window.cpp:16
RGBA color stored as normalized floating-point components.
Definition color.hpp:12
Holds an integer width/height pair.
Definition dimensions.hpp:9