diff --git a/CMakeLists.txt b/CMakeLists.txt index f5cf3b7..3cfb496 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) include(cmake/color.cmake) -set(BLT_VERSION 0.15.10) +set(BLT_VERSION 0.15.11) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/commit.sh b/commit.sh new file mode 100644 index 0000000..16242cc --- /dev/null +++ b/commit.sh @@ -0,0 +1,5 @@ +#!/bin/bash +git add * +git commit +git push -u github main +git push -u tpgc main diff --git a/include/blt/std/vector.h b/include/blt/std/vector.h index 57bde2e..9120c04 100644 --- a/include/blt/std/vector.h +++ b/include/blt/std/vector.h @@ -103,17 +103,17 @@ namespace blt return buffer_; } - constexpr inline T* data() const + constexpr inline const T* data() const { return buffer_; } - constexpr inline iterator begin() const noexcept + constexpr inline iterator begin() noexcept { return data(); } - constexpr inline iterator end() const noexcept + constexpr inline iterator end() noexcept { return data() + size(); } diff --git a/include/blt/window/window.h b/include/blt/window/window.h new file mode 100644 index 0000000..1ade406 --- /dev/null +++ b/include/blt/window/window.h @@ -0,0 +1,71 @@ +/* + * Created by Brett on 16/01/23. + * Licensed under GNU General Public License V3.0 + * See LICENSE file for license detail + */ + +#ifndef BLT_WINDOW_H +#define BLT_WINDOW_H + +#include +#include + +#ifndef BLT_MAP_FUNC + #include + #define BLT_MAP_FUNC std::unordered_map +#endif + +#define KEY_MAP BLT_MAP_FUNC + +namespace blt { + +class window { + protected: + bool m_windowOpen = true; + int m_width = 800, m_height = 600; + + std::vector> renderFunctions{}; + std::vector> keyListeners{}; + std::vector> mouseListeners{}; + + KEY_MAP keysDown{}; + KEY_MAP mouseDown{}; + public: + window() = default; + window(int width_, int height_) { + m_width = width_; + m_height = height_; + } + virtual void createWindow() = 0; + virtual void startMainLoop() = 0; + virtual void destroyWindow() = 0; + virtual ~window() = 0; + + virtual inline bool setResizeable(bool resizeEnabled) = 0; + virtual inline bool setWindowSize(int width_, int height_) = 0; + [[nodiscard]] inline int getWidth() const {return m_width;}; + [[nodiscard]] inline int getHeight() const {return m_height;}; + + [[nodiscard]] virtual inline bool isWindowOpen() const {return m_windowOpen;}; + virtual inline void closeWindow(){ + m_windowOpen = false; + } + virtual inline void registerLoopFunction(const std::function& func) { + renderFunctions.push_back(func); + } + + virtual inline bool isKeyDown(int key) const { return keysDown.at(key); } + virtual inline bool isMouseDown(int button) const {return mouseDown.at(button);}; + // Function signature is window pointer to this, key press, pressed/released (true/false) + virtual inline void registerKeyListener(const std::function& listener) { + keyListeners.push_back(listener); + } + // Function signature is window pointer to this, mouse button press, pressed/released (true/false) + virtual inline void registerMouseListener(const std::function& listener) { + mouseListeners.push_back(listener); + } +}; + +} + +#endif \ No newline at end of file