JNGL
App.hpp
Go to the documentation of this file.
1 // Copyright 2019-2021 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
5 #pragma once
6 
7 #include <memory>
8 #include <string>
9 
10 namespace jngl {
11 class ShaderProgram;
12 
26 class App {
27 public:
28  [[deprecated("Use jngl::App::instance().setDisplayName instead")]] explicit App(
29  std::string displayName);
30  ~App();
31  App(const App&) = delete;
32  App& operator=(const App&) = delete;
33  App(App&&) = delete;
34  App& operator=(App&&) = delete;
35 
37  static App& instance();
38 
40  [[nodiscard]] std::string getDisplayName() const;
41 
42  void setDisplayName(const std::string&);
43 
45  void mainLoop();
46 
50  void setPixelArt(bool);
51 
53  static bool isPixelArt();
54 
55  void updateProjectionMatrix() const;
56 
57 private:
58  App();
59 
60  void registerShaderProgram(ShaderProgram*);
61  void unregisterShaderProgram(ShaderProgram*);
62 
63  friend ShaderProgram;
64 
65  struct Impl;
67 
68  static App* self;
69 };
70 
71 } // namespace jngl
There can only be one instance of this class which will be created before the window is shown.
Definition: App.hpp:26
void mainLoop()
Starts the main loop, which calls jngl::Work::step and jngl::Work::draw.
std::string getDisplayName() const
The display name of the app is used by jngl::writeConfig() for example.
static App & instance()
Access the instance, creates it if it doesn't exist.
void setPixelArt(bool)
Activates pixel-perfect magnifying of textures (nearest-neighbor interpolation)
static bool isPixelArt()
If pixel-perfect magnifying is activated (see setPixelArt)
Linked vertex and fragment shaders.
JNGL's main namespace.
Definition: App.hpp:10