diff --git a/res/shaders/basic.glsl b/res/shaders/basic.glsl index e69de29..19aceda 100644 --- a/res/shaders/basic.glsl +++ b/res/shaders/basic.glsl @@ -0,0 +1,21 @@ +#type vertex +#version 330 + +in vec3 position; + +uniform mat4 model; +uniform mat4 view; +uniform mat4 proj; + +void main() { + gl_Position = proj * view * model * vec4(position, 1.0); +} + +#type fragment +#version 330 + +out vec4 outColour; + +void main() { + outColour = vec4(0.58, 0.61, 0.627, 1.0); +} diff --git a/src/inferno.cpp b/src/inferno.cpp index d410a45..1b15a5c 100644 --- a/src/inferno.cpp +++ b/src/inferno.cpp @@ -10,7 +10,7 @@ #include #include -namespace inferno { +using namespace inferno; Inferno::Inferno() { @@ -45,8 +45,6 @@ void Inferno::uiPreset() int Inferno::run() { - mWin->setKeyCallback(&handleKbd); - mWin->setMouseCallback(&handlePtr); mWin->setFPSMode(); while (true) { @@ -61,10 +59,12 @@ int Inferno::run() ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags); // KBD & MOUSE + double xpos, ypos; + glfwGetCursorPos(mWin->getGLFWWindow(), &xpos, &ypos); + + std::cout << mouseDelta.x << " " << mouseDelta.y << std::endl; - - - + ImGui::Begin("Preview"); ImGui::End(); @@ -94,22 +94,4 @@ int Inferno::run() delete mWin; return 0; -} - -void handleKbd(int key, int scan, int action, int mod) -{ - -} - -void handlePtr(double x, double y) -{ - int iX = floor(x); - int iY = floor(x); - static int oX, oY; - glm::vec2 mouseDelta = { iX - oX, iY - oY }; - Inferno::GetInstance().mouseDelta = mouseDelta; - oX = iX; - oY = iY; -} - -} +} \ No newline at end of file diff --git a/src/inferno.hpp b/src/inferno.hpp index 0c5e215..24f7f16 100644 --- a/src/inferno.hpp +++ b/src/inferno.hpp @@ -7,7 +7,6 @@ namespace inferno { class Window; -class GLFWwindow; class RasterizeRenderer; class Scene; @@ -24,9 +23,6 @@ public: public: glm::vec2 mouseDelta; glm::vec3 kbdDelta; -private: - friend void handleKbd(int key, int scan, int action, int mod); - friend void handlePtr(double x, double y); private: RasterizeRenderer* mRasterRenderer; @@ -36,7 +32,4 @@ private: Window* mWin; }; -void handleKbd(int key, int scan, int action, int mod); -void handlePtr(double x, double y); - } diff --git a/src/window.cpp b/src/window.cpp index 45efd95..35631a5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -22,7 +22,6 @@ void Window::init(std::string title, int width, int height) setupGLFW(title); glfwSetKeyCallback(getGLFWWindow(), glfwKeyCallback); - glfwSetCursorPosCallback(getGLFWWindow(), glfwMouseCallback); setupImGui(); } @@ -66,21 +65,11 @@ void Window::setKeyCallback(KeyCallback callback) mKeyCallback = callback; } -void Window::setMouseCallback(MouseCallback callback) -{ - mMouseCallback = callback; -} - KeyCallback Window::getKeyCallback() { return mKeyCallback; } -MouseCallback Window::getMouseCallback() -{ - return mMouseCallback; -} - bool Window::newFrame() { glfwPollEvents(); @@ -196,14 +185,6 @@ void Window::glfwKeyCallback(GLFWwindow* window, int key, int scancode, int acti } } -void Window::glfwMouseCallback(GLFWwindow* window, double xpos, double ypos) -{ - if (Window::GetInstance().getMouseCallback() != nullptr) - { - Window::GetInstance().getMouseCallback()(xpos, ypos); - } -} - void Window::glfwErrorCallback(int error, const char* description) { spdlog::error("[GLFW {0}] {1}", error, description); } diff --git a/src/window.hpp b/src/window.hpp index 539941b..79f1013 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -40,9 +40,7 @@ public: void setFPSMode(); void setKeyCallback(KeyCallback callback); - void setMouseCallback(MouseCallback callback); KeyCallback getKeyCallback(); - MouseCallback getMouseCallback(); private: WINDOW_MODE mWinMode = WIN_MODE_DEFAULT; @@ -54,9 +52,7 @@ private: void shutdownGLFW(); static void glfwKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); - static void glfwMouseCallback(GLFWwindow* window, double xpos, double ypos); KeyCallback mKeyCallback = nullptr; - MouseCallback mMouseCallback = nullptr; private: static void glfwErrorCallback(int error, const char* description);