click-drag rotation
This commit is contained in:
@@ -18,6 +18,8 @@ private:
|
||||
|
||||
static void onCursorPos(GLFWwindow *window, double x, double y);
|
||||
|
||||
static void onMouseButton(GLFWwindow *window, int button, int action, int mods);
|
||||
|
||||
protected:
|
||||
App(int gl_major, int gl_minor);
|
||||
|
||||
@@ -43,6 +45,8 @@ protected:
|
||||
|
||||
virtual void onCursorPos(double x, double y) {}
|
||||
|
||||
virtual void onMouseButton(int button, int action, int mods) {}
|
||||
|
||||
virtual void init() {}
|
||||
|
||||
virtual void display() {}
|
||||
|
||||
@@ -124,6 +124,11 @@ void App::onCursorPos(GLFWwindow *window, double x, double y) {
|
||||
if (app) app->onCursorPos(x, y);
|
||||
}
|
||||
|
||||
void App::onMouseButton(GLFWwindow *window, int button, int action, int mods) {
|
||||
auto *app = get(window);
|
||||
if (app) app->onMouseButton(button, action, mods);
|
||||
}
|
||||
|
||||
int App::run() {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, _gl_major);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, _gl_minor);
|
||||
@@ -137,6 +142,7 @@ int App::run() {
|
||||
glfwSetWindowSizeCallback(getWindow(), App::onSize);
|
||||
glfwSetKeyCallback(getWindow(), App::onKey);
|
||||
glfwSetCursorPosCallback(getWindow(), App::onCursorPos);
|
||||
glfwSetMouseButtonCallback(getWindow(), App::onMouseButton);
|
||||
|
||||
glfwMakeContextCurrent(_window);
|
||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||
|
||||
Reference in New Issue
Block a user