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, int width, int 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
43
46
49
52
55
58
60void setFullscreen(bool);
61
63void setTitle(const std::string& title);
64
65enum class Cursor : uint8_t {
66 ARROW, //< Default cursor
67 I, //< I-beam cursor used in text editing
68};
70void setCursor(Cursor);
71
74
75} // namespace jngl
Contains jngl::Pixels class.
JNGL's main namespace.
void showWindow(const std::string &title, int width, int 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 window in actual pixels (i.e. ignoring jngl::getScaleFactor)
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 window in actual pixels (i.e. ignoring jngl::getScaleFactor)
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)