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]); +}