Owns the application window, OpenGL context and the frame loop.
More...
#include <window.hpp>
|
| | Window (int width, int height, std::string title, bool fullscreen=false) |
| | Creates the window and OpenGL context.
|
| |
| | ~Window () |
| | Destroys the window and releases GLFW resources.
|
| |
| bool | shouldClose () |
| | Reports whether the window has been asked to close.
|
| |
| void | swapBuffers () |
| | Swaps the front and back framebuffers.
|
| |
| void | pollEvents () |
| | Processes pending window and input events.
|
| |
| void | loadGLAD () |
| | Loads OpenGL function pointers via GLAD.
|
| |
| void | onResize (int w, int h) |
| | Updates cached state in response to a resize.
|
| |
| void | setTitle (std::string title) |
| | Sets the window title.
|
| |
| void | fill (const Color &c) |
| | Clears the framebuffer to a solid color.
|
| |
| void | beginFrame () |
| | Begins a frame: updates timing and prepares for rendering.
|
| |
| void | endFrame () |
| | Ends a frame: swaps buffers and polls events.
|
| |
| int | getFPS () |
| | Returns the frames-per-second over the last full second.
|
| |
| int | getInstantFPS () |
| | Returns the instantaneous FPS from the latest frame.
|
| |
| double | getDeltaTime () |
| | Returns the time elapsed since the previous frame.
|
| |
|
| static void | _characterCallback (GLFWwindow *window, unsigned int codepoint) |
| | Raw GLFW character input callback, forwarded to Input.
|
| |
| static void | _processInput (GLFWwindow *win, int key, int scanCode, int action, int mods) |
| | Raw GLFW keyboard callback, forwarded to Input.
|
| |
| static void | _scrollCallback (GLFWwindow *window, double xOffset, double yOffset) |
| | Raw GLFW scroll callback, forwarded to Mouse.
|
| |
| static Window * | getInstance () |
| | Returns the singleton instance.
|
| |
|
| static std::unordered_set< Key > | keysPressed |
| | Keys held this frame.
|
| |
| static std::unordered_set< Key > | prevKeysPressed |
| | Keys held the previous frame (for edge detection).
|
| |
|
| static void | _mouseButtonCallback (GLFWwindow *window, int button, int action, int mods) |
| | Raw GLFW mouse button callback, forwarded to Mouse.
|
| |
| static void | _mouseEnterCallback (GLFWwindow *window, int e) |
| | Raw GLFW cursor enter/leave callback, forwarded to Mouse.
|
| |
| static void | _mouseMoveCallback (GLFWwindow *window, double _x, double _y) |
| | Raw GLFW cursor move callback, forwarded to Mouse.
|
| |
|
| double | lastTime |
| | Timestamp used for the per-second FPS counter.
|
| |
| int | frameCount |
| | Frames counted in the current second.
|
| |
| int | fps |
| | Frames rendered in the last full second.
|
| |
| int | instantFps |
| | FPS estimated from the latest frame's delta time.
|
| |
| double | lastFrameTime = 0.0 |
| | Timestamp of the previous frame.
|
| |
| float | deltaTime = 0.0f |
| | Seconds elapsed since the previous frame.
|
| |
| GLFWwindow * | main |
| | Underlying GLFW window handle.
|
| |
Owns the application window, OpenGL context and the frame loop.
Wraps a GLFW window: creates the context, pumps input/events, tracks frame timing (FPS and delta time) and exposes per-frame begin/end hooks. Implemented as a singleton accessible via getInstance.
◆ Window()
| cangine::Window::Window |
( |
int |
width, |
|
|
int |
height, |
|
|
std::string |
title, |
|
|
bool |
fullscreen = false |
|
) |
| |
Creates the window and OpenGL context.
- Parameters
-
| width | Initial width in pixels. |
| height | Initial height in pixels. |
| title | Window title. |
| fullscreen | Whether to open in fullscreen mode. |
◆ ~Window()
| cangine::Window::~Window |
( |
| ) |
|
Destroys the window and releases GLFW resources.
◆ _characterCallback()
| void cangine::Window::_characterCallback |
( |
GLFWwindow * |
window, |
|
|
unsigned int |
codepoint |
|
) |
| |
|
static |
Raw GLFW character input callback, forwarded to Input.
- Parameters
-
| window | Window receiving input. |
| codepoint | Unicode codepoint typed. |
◆ _mouseButtonCallback()
| void cangine::Window::_mouseButtonCallback |
( |
GLFWwindow * |
window, |
|
|
int |
button, |
|
|
int |
action, |
|
|
int |
mods |
|
) |
| |
|
staticprivate |
Raw GLFW mouse button callback, forwarded to Mouse.
◆ _mouseEnterCallback()
| void cangine::Window::_mouseEnterCallback |
( |
GLFWwindow * |
window, |
|
|
int |
e |
|
) |
| |
|
staticprivate |
Raw GLFW cursor enter/leave callback, forwarded to Mouse.
◆ _mouseMoveCallback()
| void cangine::Window::_mouseMoveCallback |
( |
GLFWwindow * |
window, |
|
|
double |
_x, |
|
|
double |
_y |
|
) |
| |
|
staticprivate |
Raw GLFW cursor move callback, forwarded to Mouse.
◆ _processInput()
| void cangine::Window::_processInput |
( |
GLFWwindow * |
win, |
|
|
int |
key, |
|
|
int |
scanCode, |
|
|
int |
action, |
|
|
int |
mods |
|
) |
| |
|
static |
Raw GLFW keyboard callback, forwarded to Input.
◆ _scrollCallback()
| void cangine::Window::_scrollCallback |
( |
GLFWwindow * |
window, |
|
|
double |
xOffset, |
|
|
double |
yOffset |
|
) |
| |
|
static |
Raw GLFW scroll callback, forwarded to Mouse.
◆ beginFrame()
| void cangine::Window::beginFrame |
( |
| ) |
|
Begins a frame: updates timing and prepares for rendering.
◆ endFrame()
| void cangine::Window::endFrame |
( |
| ) |
|
Ends a frame: swaps buffers and polls events.
◆ fill()
| void cangine::Window::fill |
( |
const Color & |
c | ) |
|
Clears the framebuffer to a solid color.
- Parameters
-
◆ getDeltaTime()
| double cangine::Window::getDeltaTime |
( |
| ) |
|
Returns the time elapsed since the previous frame.
- Returns
- Delta time in seconds.
◆ getFPS()
| int cangine::Window::getFPS |
( |
| ) |
|
Returns the frames-per-second over the last full second.
- Returns
- Averaged FPS.
◆ getInstance()
| Window * cangine::Window::getInstance |
( |
| ) |
|
|
static |
Returns the singleton instance.
- Returns
- Pointer to the Window instance.
◆ getInstantFPS()
| int cangine::Window::getInstantFPS |
( |
| ) |
|
Returns the instantaneous FPS from the latest frame.
- Returns
- Instantaneous FPS.
◆ loadGLAD()
| void cangine::Window::loadGLAD |
( |
| ) |
|
Loads OpenGL function pointers via GLAD.
◆ onResize()
| void cangine::Window::onResize |
( |
int |
w, |
|
|
int |
h |
|
) |
| |
Updates cached state in response to a resize.
- Parameters
-
| w | New width in pixels. |
| h | New height in pixels. |
◆ pollEvents()
| void cangine::Window::pollEvents |
( |
| ) |
|
Processes pending window and input events.
◆ setTitle()
| void cangine::Window::setTitle |
( |
std::string |
title | ) |
|
Sets the window title.
- Parameters
-
◆ shouldClose()
| bool cangine::Window::shouldClose |
( |
| ) |
|
Reports whether the window has been asked to close.
- Returns
true if the window should close.
◆ swapBuffers()
| void cangine::Window::swapBuffers |
( |
| ) |
|
Swaps the front and back framebuffers.
◆ deltaTime
| float cangine::Window::deltaTime = 0.0f |
|
private |
Seconds elapsed since the previous frame.
◆ dimensions
Current window size in pixels.
◆ fps
Frames rendered in the last full second.
◆ frameCount
| int cangine::Window::frameCount |
|
private |
Frames counted in the current second.
◆ instance
| Window * cangine::Window::instance = nullptr |
|
staticprivate |
◆ instantFps
| int cangine::Window::instantFps |
|
private |
FPS estimated from the latest frame's delta time.
◆ keysPressed
| std::unordered_set< Key > cangine::Window::keysPressed |
|
static |
◆ lastFrameTime
| double cangine::Window::lastFrameTime = 0.0 |
|
private |
Timestamp of the previous frame.
◆ lastTime
| double cangine::Window::lastTime |
|
private |
Timestamp used for the per-second FPS counter.
◆ main
| GLFWwindow* cangine::Window::main |
|
private |
Underlying GLFW window handle.
◆ prevKeysPressed
| std::unordered_set< Key > cangine::Window::prevKeysPressed |
|
static |
Keys held the previous frame (for edge detection).
The documentation for this class was generated from the following files: