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-2024 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
3
6
7#pragma once
8
9#include "Pixels.hpp"
10
11#include <array>
12#include <functional>
13#include <string>
14#include <vector>
15
16namespace jngl {
17
19void showWindow(const std::string& title, int width, int height, bool fullscreen = false,
20 std::pair<int, int> minAspectRatio = { 4, 3 },
21 std::pair<int, int> maxAspectRatio = { 16, 9 });
22
27
36void atExit(std::function<void()>);
37
40
43
46
49
52
55
57void setFullscreen(bool);
58
60void setTitle(const std::string& title);
61
62enum class Cursor {
63 ARROW,
64 I,
65};
66void setCursor(Cursor);
67
70
71} // namespace jngl
Contains jngl::Pixels class.
JNGL's main namespace.
Definition: Achievement.hpp:10
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.
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)