From 91b65bf6e356485e272cfb55de4e00a0b5a2c44b Mon Sep 17 00:00:00 2001 From: Anakin Date: Sat, 12 Nov 2016 12:14:45 +0100 Subject: [PATCH] added drag n drop function, need to clean up before loading the next mesh --- MshViewer/Header/callback.h | 4 +++- MshViewer/Source/OpenGlController.cpp | 1 + MshViewer/Source/callback.cpp | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/MshViewer/Header/callback.h b/MshViewer/Header/callback.h index 52de8c9..c4458e7 100644 --- a/MshViewer/Header/callback.h +++ b/MshViewer/Header/callback.h @@ -8,4 +8,6 @@ extern void mouseMove(GLFWwindow *window, double xpos, double ypos); extern void mouseWheel(GLFWwindow *window, double xoffset, double yoffset); -extern void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods); \ No newline at end of file +extern void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods); + +extern void dragNdrop(GLFWwindow* window, int count, const char** paths); \ No newline at end of file diff --git a/MshViewer/Source/OpenGlController.cpp b/MshViewer/Source/OpenGlController.cpp index 4c57218..cb49950 100644 --- a/MshViewer/Source/OpenGlController.cpp +++ b/MshViewer/Source/OpenGlController.cpp @@ -179,6 +179,7 @@ void OpenGLController::setCallbackFunctions() glfwSetWindowSizeCallback(pWindow, windowResize); glfwSetScrollCallback(pWindow, mouseWheel); glfwSetKeyCallback(pWindow, keyPress); + glfwSetDropCallback(pWindow, dragNdrop); } glm::mat4 OpenGLController::getModelMatrix(unsigned int index) diff --git a/MshViewer/Source/callback.cpp b/MshViewer/Source/callback.cpp index e93e599..efdcd0c 100644 --- a/MshViewer/Source/callback.cpp +++ b/MshViewer/Source/callback.cpp @@ -98,3 +98,10 @@ void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods) } } } + +void dragNdrop(GLFWwindow* window, int count, const char** paths) +{ + OpenGLController* controller = reinterpret_cast(glfwGetWindowUserPointer(window)); + if(count > 0) + controller->loadMsh(paths[0]); +}