Added callbacks
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <NBGraphics/OGLObjects.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -38,6 +39,12 @@ class OGLWindow {
|
||||
THROW(GLFWError(GLFWError::Codes::NOT_MAIN));
|
||||
}
|
||||
}
|
||||
template<typename... Args>
|
||||
using CallbackFuncType = void (*)(GLFWwindow*, Args...);
|
||||
template<typename... Args>
|
||||
struct CallbackSetterFuncType {
|
||||
typedef CallbackFuncType<Args...> (*type)(GLFWwindow*, CallbackFuncType<Args...>);
|
||||
};
|
||||
|
||||
protected:
|
||||
static std::atomic<unsigned int> _count;
|
||||
@@ -95,6 +102,7 @@ class OGLWindow {
|
||||
const std::vector<std::array<int, 2>>& integerHints={},
|
||||
const std::vector<std::tuple<int, std::string>>& stringHints={}
|
||||
);
|
||||
|
||||
OGLWindow(OGLWindow&&) = delete;
|
||||
OGLWindow(const OGLWindow&) = delete;
|
||||
~OGLWindow();
|
||||
@@ -106,14 +114,15 @@ class OGLWindow {
|
||||
inline std::string getTitle() const { return _title; }
|
||||
std::array<int, 2> getSize() const;
|
||||
bool shouldClose() const;
|
||||
inline void processEvents() const { CheckForMainThread(); glfwPollEvents(); }
|
||||
inline void refresh() const { glfwSwapBuffers(_window_ptr); }
|
||||
inline void pollEvents() const { CheckForMainThread(); glfwPollEvents(); }
|
||||
inline void swapBuffers() const { glfwSwapBuffers(_window_ptr); }
|
||||
|
||||
void setSize(unsigned int x, unsigned int y);
|
||||
void setTitle(const std::string&);
|
||||
void shouldClose(bool);
|
||||
/* template<enum Callbacks, typename Func>
|
||||
void setCallBack(Func); */
|
||||
|
||||
template<enum Callbacks, typename Func>
|
||||
void setCallback(std::function<Func> callback);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user