Mountain  1.0.0
Simple C++ 2D Game Framework
renderer.hpp
1 #pragma once
2 
3 #include <chrono>
4 #include <stack>
5 
6 #include "Mountain/core.hpp"
7 #include "Mountain/rendering/render_target.hpp"
8 #include "Mountain/resource/font.hpp"
10 
11 // ReSharper disable once CppInconsistentNaming
12 struct GLFWwindow;
13 
14 // ReSharper disable once CppInconsistentNaming
15 struct FT_LibraryRec_;
16 // ReSharper disable once CppEnforceTypeAliasCodeStyle
17 // ReSharper disable once CppInconsistentNaming
18 typedef FT_LibraryRec_* FT_Library;
19 
20 namespace Mountain
21 {
23  {
24  const char_t* glsl = "#version 460";
25  int32_t major = 4;
26  int32_t minor = 4;
27  };
28 
30  {
31  std::string str;
32  std::chrono::time_point<std::chrono::system_clock> time;
33  Color color;
34  float_t duration;
35  };
36 
37  class Renderer
38  {
39  public:
40  MOUNTAIN_API static void PushRenderTarget(RenderTarget& renderTarget);
41  MOUNTAIN_API static RenderTarget& PopRenderTarget();
42  MOUNTAIN_API static RenderTarget& GetCurrentRenderTarget();
43  MOUNTAIN_API static RenderTarget& GetDefaultRenderTarget();
44 
45  MOUNTAIN_API static void DebugString(std::string str, float_t duration = 1.f, const Color& color = Color::Magenta());
46  MOUNTAIN_API static void DebugString(DebugStringData data);
47 
48  MOUNTAIN_API static OpenGlVersion& GetOpenGlVersion();
49 
50  private:
51  static inline OpenGlVersion m_GlVersion;
52  static inline FT_Library m_Freetype;
53 
54  static inline std::stack<RenderTarget*> m_RenderTargets;
55  static inline RenderTarget* m_RenderTarget;
56 
57  static inline Pointer<Font> m_DefaultFont;
58  static inline List<DebugStringData> m_DebugStrings;
59 
60  static bool_t Initialize(const std::string& windowTitle, Vector2i windowSize, const OpenGlVersion& glVersion = {});
61  static void PreFrame();
62  static void PostFrame();
63  static void Shutdown();
64 
65  // Needs access to the m_Freetype library instance
66  friend class Font;
67  // Calls Initialize, PreFrame, PostFrame and Shutdown
68  friend class Game;
69  };
70 }
static constexpr Color Magenta()
Constant for Magenta.
A dynamic array implementation. Wrapper around the std::vector class.
Definition: list.hpp:24
Custom Mountain smart pointer. Represents both a std::shared_ptr and a std::weak_ptr.
The Color struct represents a color in RGBA color space.
Definition: color.hpp:26
Defines the Mountain::Pointer class.
Holds the necessary information to draw text using a Font.
Definition: font.hpp:15
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22