From 4269e52e31fe0f41b8ad605fd2ae4f8d473d79c7 Mon Sep 17 00:00:00 2001 From: Brett Date: Tue, 17 Jan 2023 11:09:25 -0500 Subject: [PATCH] Testing pointer nonsense for glut --- include/blt/window/window.h | 19 +++++++++++++++---- src/blt/window/window.cpp | 10 ++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/blt/window/window.cpp diff --git a/include/blt/window/window.h b/include/blt/window/window.h index 0589589..bf09d67 100644 --- a/include/blt/window/window.h +++ b/include/blt/window/window.h @@ -19,27 +19,38 @@ namespace blt { +class window; + +#define WINDOW_MAP BLT_MAP_FUNC + +extern WINDOW_MAP activeWindows; + class window { protected: bool m_windowOpen = true; int m_width, m_height; - std::vector> renderFunctions{}; + std::vector> renderFunctions{}; std::vector> keyListeners{}; std::vector> mouseListeners{}; KEY_MAP keysDown{}; KEY_MAP mouseDown{}; public: - window() = default; + window() { + activeWindows.insert({this, this}); + } window(int width, int height) { + activeWindows.insert({this, this}); m_width = width; m_height = height; } virtual void createWindow() = 0; virtual void startMainLoop() = 0; virtual void destroyWindow() = 0; - virtual ~window() = 0; + virtual ~window() { + activeWindows.insert({this, nullptr}); + }; virtual inline bool setResizeable(bool resizeEnabled) = 0; virtual inline bool setWindowSize(int width, int height) = 0; @@ -50,7 +61,7 @@ class window { virtual inline void closeWindow(){ m_windowOpen = false; } - virtual inline void registerLoopFunction(std::function func) { + virtual inline void registerLoopFunction(std::function func) { renderFunctions.push_back(func); } diff --git a/src/blt/window/window.cpp b/src/blt/window/window.cpp new file mode 100644 index 0000000..14c0517 --- /dev/null +++ b/src/blt/window/window.cpp @@ -0,0 +1,10 @@ +/* + * Created by Brett on 17/01/23. + * Licensed under GNU General Public License V3.0 + * See LICENSE file for license detail + */ +#include + +namespace blt { + WINDOW_MAP activeWindows; +} \ No newline at end of file