JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
other.hpp
Go to the documentation of this file.
1// Copyright 2014-2022 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 <sstream>
8#include <string>
9#include <vector>
10
11namespace jngl {
12
14bool running();
15
21
26
31
35bool canQuit();
36
41void quit() noexcept;
42
45
49[[deprecated("Not really intuitive or robust, use your own calculations instead")]] double getFPS();
50
52unsigned int getStepsPerSecond();
53
55void setStepsPerSecond(unsigned int);
56
60void setAntiAliasing(bool enabled);
61
64
66void setVerticalSync(bool enabled);
67
70
72void setIcon(const std::string& filename);
73
75void setPrefix(const std::string& path);
76
78std::string getPrefix();
79
81void setConfigPath(const std::string& path);
82
90[[deprecated("use jngl::writeConfig and jngl::readConfig instead")]] std::string getConfigPath();
91
94
96void setArgs(std::vector<std::string>);
97
99std::vector<std::string> getArgs();
100
102std::stringstream readAsset(const std::string& filename);
103
111std::string readConfig(const std::string& key);
112
119void writeConfig(const std::string& key, const std::string& value);
120
123
125void openURL(const std::string&);
126
128int round(double v);
129
130} // namespace jngl
JNGL's main namespace.
Definition: Achievement.hpp:10
std::string readConfig(const std::string &key)
Read in a configuration value which has been saved under key.
unsigned int getStepsPerSecond()
How many times Work::step is called per second (default: 60)
void clearBackBuffer()
Clears the back buffer and resets the ModelView matrix, see jngl::reset()
void swapBuffers()
Swaps back and front buffer.
void setPrefix(const std::string &path)
Sets a global prefix which will be prepended whenever images or sounds are loaded.
double getFPS()
Calculates FPS if called once per frame.
std::stringstream readAsset(const std::string &filename)
Returns a stringstream containing the whole file. This will read from the .apk on Android.
void cancelQuit()
Undo quit() or ignore a quit event caused by the user closing the main window.
bool canQuit()
Some platforms (e.g.
int round(double v)
Rounds a double to an integer, just like std::lround.
void openURL(const std::string &)
Opens a link (e.g. https://bixense.com) in the browser.
void setArgs(std::vector< std::string >)
Called by JNGL_MAIN_BEGIN to set command line arguments.
std::string getConfigPath()
void writeConfig(const std::string &key, const std::string &value)
Write value into the persistent storage which can be read in again using jngl::readConfig(key)
void setVerticalSync(bool enabled)
Toggles V-SYNC.
bool getVerticalSync()
Returns whether V-SYNC is enabled. Many devices always enable V-SYNC with no way to turn it off.
void setStepsPerSecond(unsigned int)
How many times Work::step should be called per second (default: 60)
bool running()
Returns true until the main window is closed or quit() has been called.
bool getAntiAliasing()
Returns whether MSAA is enabled. If the device doesn't support it, it will always return false.
std::string getPrefix()
Returns the global prefix set by jngl::setPrefix.
std::string getBinaryPath()
Returns the directory of the currently running binary.
std::string getPreferredLanguage()
Returns user preferred language, i.e. "en" for English, "de" for German.
std::vector< std::string > getArgs()
Returns the command line arguments passed to the executable.
void setConfigPath(const std::string &path)
void quit() noexcept
Emit a quit event which will exit App::mainLoop() and set running() to false.
void updateInput()
Updates the input state.
void setIcon(const std::string &filename)
Sets the icon for the window (Desktop-only)
void setAntiAliasing(bool enabled)
Toggles Multisample anti-aliasing (MSAA)