//------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 motion(GLFWwindow *, double dx, double dy) { int x=(int)dx, y=(int)dy; #else motion(int x, int y) { #endif if (g_mbutton[0] && !g_mbutton[1] && !g_mbutton[2]) { // orbit g_rotate[0] += x - g_prev_x; g_rotate[1] += y - g_prev_y; } else if (!g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) { // pan g_pan[0] -= g_dolly*(x - g_prev_x)/g_width; g_pan[1] += g_dolly*(y - g_prev_y)/g_height; } else if ((g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) or (!g_mbutton[0] && g_mbutton[1] && !g_mbutton[2])) { // dolly g_dolly -= g_dolly*0.01f*(x - g_prev_x); if(g_dolly <= 0.01) g_dolly = 0.01f; } g_prev_x = x; g_prev_y = y; } //------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 mouse(GLFWwindow *, int button, int state, int mods) { #else mouse(int button, int state) { #endif if (button == 0 && state == GLFW_PRESS && g_hud.MouseClick(g_prev_x, g_prev_y)) return; if (button < 3) { g_mbutton[button] = (state == GLFW_PRESS); } } //------------------------------------------------------------------------------ static void uninitGL() { glDeleteQueries(2, g_queries); delete g_batch; g_batch = NULL; #ifdef OPENSUBDIV_HAS_CUDA cudaDeviceReset(); #endif #ifdef OPENSUBDIV_HAS_OPENCL uninitCL(g_clContext, g_clQueue); #endif }
//------------------------------------------------------------------------------ static void mouse(GLFWwindow *, int button, int state, int /* mods */) { if (button == 0 && state == GLFW_PRESS && g_hud.MouseClick(g_prev_x, g_prev_y)) return; if (button < 3) { g_mbutton[button] = (state == GLFW_PRESS); } }
//------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 motion(GLFWwindow *, double dx, double dy) { int x=(int)dx, y=(int)dy; #else motion(int x, int y) { #endif if (g_mbutton[0] && !g_mbutton[1] && !g_mbutton[2]) { // orbit g_rotate[0] += x - g_prev_x; g_rotate[1] += y - g_prev_y; } else if (!g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) { // pan g_pan[0] -= g_dolly*(x - g_prev_x)/g_width; g_pan[1] += g_dolly*(y - g_prev_y)/g_height; } else if ((g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) or (!g_mbutton[0] && g_mbutton[1] && !g_mbutton[2])) { // dolly g_dolly -= g_dolly*0.01f*(x - g_prev_x); if(g_dolly <= 0.01) g_dolly = 0.01f; } g_prev_x = x; g_prev_y = y; } //------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 mouse(GLFWwindow *, int button, int state, int mods) { #else mouse(int button, int state) { #endif if (button == 0 && state == GLFW_PRESS && g_hud.MouseClick(g_prev_x, g_prev_y)) return; if (button < 3) { g_mbutton[button] = (state == GLFW_PRESS); } } //------------------------------------------------------------------------------ static void #if GLFW_VERSION_MAJOR>=3 reshape(GLFWwindow *, int width, int height) { #else reshape(int width, int height) { #endif g_width = width; g_height = height; int windowWidth = g_width, windowHeight = g_height; #if GLFW_VERSION_MAJOR>=3 // window size might not match framebuffer size on a high DPI display glfwGetWindowSize(g_window, &windowWidth, &windowHeight); #endif g_hud.Rebuild(windowWidth, windowHeight); }