BLT/include/blt/window/window.h

53 lines
1.5 KiB
C
Raw Normal View History

2023-01-16 14:08:28 -05:00
/*
* 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 <functional>
#include <vector>
#ifndef BLT_MAP_FUNC
#include <unordered_map>
#define BLT_MAP_FUNC std::unordered_map
#endif
#define KEY_MAP BLT_MAP_FUNC<integer, bool>
2023-01-16 14:08:28 -05:00
namespace blt {
class window {
protected:
bool windowOpen = true;
std::vector<std::function<void()>> renderFunctions;
2023-01-16 14:08:28 -05:00
public:
window() = default;
virtual void createWindow() = 0;
virtual void startMainLoop() = 0;
2023-01-16 14:08:28 -05:00
virtual void destroyWindow() = 0;
virtual ~window() = 0;
virtual bool setResizeable(bool resizeEnabled) = 0;
virtual bool setWindowSize(int width, int height) = 0;
virtual int getWidth() = 0;
virtual int getHeight() = 0;
virtual bool isWindowOpen() {return windowOpen;};
virtual void registerLoopFunction(std::function<void()> func) {
renderFunctions.push_back(func);
}
2023-01-16 14:08:28 -05:00
virtual bool isKeyDown(int key) = 0;
virtual bool isMouseDown(int button) = 0;
// Function signature is window pointer to this, key press, pressed/released (true/false)
virtual void registerKeyListener(std::function<void(window*, int, bool)> listener) = 0;
// Function signature is window pointer to this, mouse button press, pressed/released (true/false)
virtual void registerMouseListener(std::function<void(window*, int, bool)> listener) = 0;
};
}
#endif