diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9edcad4..b4e5051 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -10,6 +10,7 @@ set(hdrs include/pw/core/quaternion.hpp include/pw/core/serialize.hpp include/pw/core/image.hpp + include/pw/core/point.hpp include/pw/core/size.hpp include/pw/core/timer.hpp include/pw/core/globals.hpp diff --git a/src/core/include/pw/core/debug.hpp b/src/core/include/pw/core/debug.hpp index b90ec8f..4b6904b 100644 --- a/src/core/include/pw/core/debug.hpp +++ b/src/core/include/pw/core/debug.hpp @@ -40,13 +40,13 @@ class debug { public: enum level { - kNone, //!< nothing will be logged, even no errors - kError, //!< only errors will be logged - kWarning, //!< log warnings (non-critical errors) - kMessage, //!< log messages (something to note but not an error) - kNotify, //!< log some more information - kInfo, //!< log verbose information - kAll = 0xFF //!< log absolutely everything + none, //!< nothing will be logged, even no errors + error, //!< only errors will be logged + warning, //!< log warnings (non-critical errors) + message, //!< log messages (something to note but not an error) + notification, //!< log some more information + info, //!< log verbose information + all = 0xFF //!< log absolutely everything }; /** @@ -94,11 +94,11 @@ public: * @brief get the stream interface of the logger * @return return a temporary object that will write and flush the logger */ - static stream s(enum level level = kInfo); + static stream s(enum level level = info); - inline static stream d() { return s(debug::kInfo); } - inline static stream e() { return s(debug::kError); } - inline static stream w() { return s(debug::kWarning); } + inline static stream d() { return s(debug::info); } + inline static stream e() { return s(debug::error); } + inline static stream w() { return s(debug::warning); } /** * @brief returns the instance of the logger @@ -115,10 +115,11 @@ public: typedef std::function Callback; typedef std::vector CallbackList; + ~debug(); + protected: debug(); - ~debug(); CallbackList _callbacks; enum level _level; diff --git a/src/core/include/pw/core/point.hpp b/src/core/include/pw/core/point.hpp new file mode 100644 index 0000000..d9e628e --- /dev/null +++ b/src/core/include/pw/core/point.hpp @@ -0,0 +1,29 @@ +#ifndef PW_CORE_POINT_HPP +#define PW_CORE_SIZE_HPP + +#include + +namespace pw { + +template +struct point_ { + + T_ p[2] = { 0, 0 }; + + point_() = default; + point_(T_ x,T_ y) : p( {x,y} ) {} + + const T_ x() { return p[0]; } + const T_ y() { return p[1]; } + +}; + +typedef point_ point; + +typedef point_ pointi; +typedef point_ pointf; +typedef point_ pointd; + +} + +#endif diff --git a/src/core/include/pw/core/size.hpp b/src/core/include/pw/core/size.hpp index 5c0bff3..465ecf6 100644 --- a/src/core/include/pw/core/size.hpp +++ b/src/core/include/pw/core/size.hpp @@ -35,6 +35,8 @@ struct size_ { T_ dim[2] = { 0, 0 }; + size_() = default; + size_(T_ w,T_ h) : dim( { w, h }) {} const T_ width() { return dim[0]; } diff --git a/src/core/src/debug.cpp b/src/core/src/debug.cpp index bde8146..141e363 100644 --- a/src/core/src/debug.cpp +++ b/src/core/src/debug.cpp @@ -60,7 +60,7 @@ struct tpFileLog { debug::debug() : - _level(debug::kNotify) + _level(debug::notification) { #if defined(_WINCE) _callbacks.add(new tpFileLog()); diff --git a/src/scripting/src/script_core.cpp b/src/scripting/src/script_core.cpp index 5ccb314..cb4f6e2 100644 --- a/src/scripting/src/script_core.cpp +++ b/src/scripting/src/script_core.cpp @@ -3,6 +3,7 @@ #include "pw/core/vector.hpp" #include "pw/core/quaternion.hpp" #include "pw/core/axisangle.hpp" +#include "pw/core/debug.hpp" namespace pw { @@ -50,6 +51,13 @@ void script_core::load(sol::table &ns) "axis",scripting::property(&axisangled::axis,&axisangled::set_axis), "angle",scripting::property(&axisangled::angle,&axisangled::set_angle) ); + + + ns.new_usertype("debug", + "new",sol::no_constructor, + "get",&debug::get + ); + } diff --git a/src/system/include/pw/system/input.hpp b/src/system/include/pw/system/input.hpp index 03c0462..d9e63b6 100644 --- a/src/system/include/pw/system/input.hpp +++ b/src/system/include/pw/system/input.hpp @@ -2,6 +2,7 @@ #define PW_SYSTEM_INPUT_HPP #include +#include namespace pw { @@ -10,14 +11,19 @@ public: static input& get(); + point mouse_position() const { return _mouse_position; } + protected: - struct impl; - std::unique_ptr _impl; + friend class window; -private: input(); ~input() = default; + +private: + + point _mouse_position; + }; } diff --git a/src/system/src/input.cpp b/src/system/src/input.cpp index b39e941..a59acc3 100644 --- a/src/system/src/input.cpp +++ b/src/system/src/input.cpp @@ -1,24 +1,11 @@ #include "pw/system/input.hpp" -#include "GLFW/glfw3.h" - namespace pw { -struct input::impl { - - - - - GLFWwindow *_window; -}; - input::input() - : _impl(new input::impl()) { - } - input &input::get() { static input instance; @@ -26,7 +13,4 @@ input &input::get() } - - - } diff --git a/src/system/src/window.cpp b/src/system/src/window.cpp index 246a42e..a82b014 100644 --- a/src/system/src/window.cpp +++ b/src/system/src/window.cpp @@ -35,15 +35,43 @@ struct window::impl { // window_context _context; + static void drop_callback(GLFWwindow* window, int count, const char** paths) + { + std::cout << __FUNCTION__ << std::endl; + } + + static void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) + { + std::cout << __FUNCTION__ << std::endl; + } + + static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) + { + std::cout << __FUNCTION__ << std::endl; +// input::get()._mouse_position + } + + static void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) + { + input::get()._mouse_position = point(xpos,ypos); + } static void key_callback(GLFWwindow *window,int key, int scancode, int action, int mods) { + std::cout << __FUNCTION__ << std::endl; } + static void character_callback(GLFWwindow* window, unsigned int codepoint) + { + std::cout << __FUNCTION__ << std::endl; + } + static void charmods_callback(GLFWwindow* window, unsigned int codepoint, int mods) + { + std::cout << __FUNCTION__ << std::endl; + } - - static void framebuffer_size_callback(GLFWwindow* window, int width, int height) + static void framebuffer_size_callback(GLFWwindow* window, int width, int height) { window::impl* impl = static_cast(glfwGetWindowUserPointer(window)); // impl->on_resize(width,height); @@ -62,6 +90,16 @@ struct window::impl { glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback); glfwSetKeyCallback(_window, window::impl::key_callback); + glfwSetCharCallback(_window, character_callback); + glfwSetCharModsCallback(_window, charmods_callback); + glfwSetScrollCallback(_window, scroll_callback); + + glfwSetDropCallback(_window, drop_callback); + + glfwSetCursorPosCallback(_window, cursor_pos_callback); + glfwSetMouseButtonCallback(_window, mouse_button_callback); + glfwSetScrollCallback(_window, scroll_callback); + #if 0