JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
window.hpp
Go to the documentation of this file.
1// Copyright 2012-2025 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include "Pixels.hpp"
8
9#include <array>
10#include <functional>
11#include <string>
12#include <vector>
13
14namespace jngl {
15
22void showWindow(const std::string& title, double width, double height, bool fullscreen = false,
23 std::pair<int, int> minAspectRatio = { 4, 3 },
24 std::pair<int, int> maxAspectRatio = { 16, 9 });
25
30
39void atExit(std::function<void()>);
40
49
52
57
60
63
66
68void setFullscreen(bool);
69
71void setTitle(const std::string& title);
72
73enum class Cursor : uint8_t {
74 ARROW, //< Default cursor
75 I, //< I-beam cursor used in text editing
76 CROSSHAIR, //< Crosshair cursor
77 GRAB, //< Something under the cursor can be grabbed, e.g. an open hand
78 GRABBING, //< Something is being grabbed, e.g. a closed hand
79 POINTER, //< Pointer cursor, typically used for clickable elements
80};
82void setCursor(Cursor);
83
89
95void readPixels(uint8_t* buffer);
96
97} // namespace jngl
Contains jngl::Pixels class.
JNGL's main namespace.
void showWindow(const std::string &title, double width, double height, bool fullscreen=false, std::pair< int, int > minAspectRatio={ 4, 3 }, std::pair< int, int > maxAspectRatio={ 16, 9 })
Creates the main window.
void hideWindow()
Cleans up the window and unloads everything.
void setFullscreen(bool)
Toggle fullscreen window mode.
void setCursor(Cursor)
Allows to change the mouse cursor.
int getWindowWidth()
Returns the width of the canvas in pixels, i.e.
int getDesktopWidth()
Returns the width of the main display in actual pixels.
void atExit(std::function< void()>)
Call this function once when the window is hidden.
int getDesktopHeight()
Returns the height of the main display in actual pixels.
int getWindowHeight()
Returns the height of the canvas in pixels, see getWindowWidth()
void setTitle(const std::string &title)
Sets the main window title.
std::array< Pixels, 2 > getWindowSize()
Returns {width, height} of the window in actual pixels.
std::vector< float > readPixels()
Read red, green and blue values of the whole window frame buffer.
bool getFullscreen()
If the window is displayed fullscreen (always true on mobile devices)