CG_Labs  2020.0
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 
21 {
22 public:
23  enum class SwapStrategy : int {
24  disable_vsync = 0,
25  enable_vsync = 1,
27  };
28  struct WindowDatum {
33  int xpos, ypos;
34  };
35 
36  WindowManager();
38 
39  GLFWwindow* CreateGLFWWindow(std::string const& title, WindowDatum const& data, unsigned int msaa = 1u, bool fullscreen = false, bool resizable = false, SwapStrategy swap = SwapStrategy::enable_vsync);
40  void DestroyWindow(GLFWwindow* const window);
41  void NewImGuiFrame();
42  void RenderImGuiFrame();
43  void ToggleFullscreenStatusForWindow(GLFWwindow* const window) noexcept;
44 
45 private:
46  std::unordered_map<GLFWwindow*, std::unique_ptr<WindowDatum>> mWindowData;
47 
48  static std::mutex mMutex;
49 };
WindowManager::WindowDatum::windowed_height
int windowed_height
Definition: WindowManager.hpp:31
WindowManager::~WindowManager
~WindowManager()
Definition: WindowManager.cpp:85
FPSCamera.h
WindowManager::WindowDatum::fullscreen_width
int fullscreen_width
Definition: WindowManager.hpp:32
WindowManager::SwapStrategy
SwapStrategy
Definition: WindowManager.hpp:23
WindowManager::mWindowData
std::unordered_map< GLFWwindow *, std::unique_ptr< WindowDatum > > mWindowData
Definition: WindowManager.hpp:46
WindowManager::CreateGLFWWindow
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
WindowManager::WindowDatum::fullscreen_height
int fullscreen_height
Definition: WindowManager.hpp:32
WindowManager::WindowDatum::camera
FPSCameraf & camera
Definition: WindowManager.hpp:30
WindowManager::WindowDatum
Definition: WindowManager.hpp:28
WindowManager::RenderImGuiFrame
void RenderImGuiFrame()
Definition: WindowManager.cpp:211
WindowManager::mMutex
static std::mutex mMutex
Definition: WindowManager.hpp:48
WindowManager::NewImGuiFrame
void NewImGuiFrame()
Definition: WindowManager.cpp:204
WindowManager::SwapStrategy::late_swap_tearing
@ late_swap_tearing
InputHandler.h
WindowManager::WindowDatum::input_handler
InputHandler & input_handler
Definition: WindowManager.hpp:29
WindowManager::SwapStrategy::disable_vsync
@ disable_vsync
WindowManager::DestroyWindow
void DestroyWindow(GLFWwindow *const window)
Definition: WindowManager.cpp:191
InputHandler
Definition: InputHandler.h:20
WindowManager
A simple class for creating and interacting with windows, using the GLFW library.
Definition: WindowManager.hpp:21
FPSCamera< float, glm::defaultp >
WindowManager::SwapStrategy::enable_vsync
@ enable_vsync
WindowManager::WindowDatum::xpos
int xpos
Definition: WindowManager.hpp:33
WindowManager::WindowManager
WindowManager()
Definition: WindowManager.cpp:70
WindowManager::WindowDatum::windowed_width
int windowed_width
Definition: WindowManager.hpp:31
WindowManager::WindowDatum::ypos
int ypos
Definition: WindowManager.hpp:33
WindowManager::ToggleFullscreenStatusForWindow
void ToggleFullscreenStatusForWindow(GLFWwindow *const window) noexcept
Definition: WindowManager.cpp:217