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
45
50
55
58
61
64
66void setFullscreen(bool);
67
69void setTitle(const std::string& title);
70
71enum class Cursor : uint8_t {
72 ARROW, //< Default cursor
73 I, //< I-beam cursor used in text editing
74};
76void setCursor(Cursor);
77
80
85void readPixels(uint8_t* buffer);
86
87} // 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 window in actual 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 window in actual pixels (i.e.
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)