CG_Labs  2021.2
WindowManager.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "FPSCamera.h"
4 #include "InputHandler.h"
5 
6 #define GLFW_INCLUDE_NONE
7 #include <GLFW/glfw3.h>
8 
9 #include <mutex>
10 #include <unordered_map>
11 #include <memory>
12 
22 {
23 public:
24  enum class SwapStrategy : int {
25  disable_vsync = 0,
26  enable_vsync = 1,
28  };
29  struct WindowDatum {
34  int xpos, ypos;
35  };
36 
37  WindowManager();
39 
40  GLFWwindow* CreateGLFWWindow(std::string const& title, WindowDatum const& data, unsigned int msaa = 1u, bool fullscreen = false, bool resizable = false, SwapStrategy swap = SwapStrategy::enable_vsync);
41  void DestroyWindow(GLFWwindow* const window);
42  void NewImGuiFrame();
43  void RenderImGuiFrame(bool show_gui);
44  void ToggleFullscreenStatusForWindow(GLFWwindow* const window) noexcept;
45 
46 private:
47  std::unordered_map<GLFWwindow*, std::unique_ptr<WindowDatum>> mWindowData;
48 
49  static std::mutex mMutex;
50 };
Definition: InputHandler.h:19
A simple class for creating and interacting with windows, using the GLFW library.
Definition: WindowManager.hpp:22
~WindowManager()
Definition: WindowManager.cpp:85
WindowManager()
Definition: WindowManager.cpp:70
std::unordered_map< GLFWwindow *, std::unique_ptr< WindowDatum > > mWindowData
Definition: WindowManager.hpp:47
void ToggleFullscreenStatusForWindow(GLFWwindow *const window) noexcept
Definition: WindowManager.cpp:235
void RenderImGuiFrame(bool show_gui)
Definition: WindowManager.cpp:228
SwapStrategy
Definition: WindowManager.hpp:24
void NewImGuiFrame()
Definition: WindowManager.cpp:221
GLFWwindow * CreateGLFWWindow(std::string const &title, WindowDatum const &data, unsigned int msaa=1u, bool fullscreen=false, bool resizable=false, SwapStrategy swap=SwapStrategy::enable_vsync)
Definition: WindowManager.cpp:91
static std::mutex mMutex
Definition: WindowManager.hpp:49
void DestroyWindow(GLFWwindow *const window)
Definition: WindowManager.cpp:208
Definition: WindowManager.hpp:29
int windowed_width
Definition: WindowManager.hpp:32
int fullscreen_width
Definition: WindowManager.hpp:33
int ypos
Definition: WindowManager.hpp:34
int fullscreen_height
Definition: WindowManager.hpp:33
FPSCameraf & camera
Definition: WindowManager.hpp:31
InputHandler & input_handler
Definition: WindowManager.hpp:30
int windowed_height
Definition: WindowManager.hpp:32
int xpos
Definition: WindowManager.hpp:34