//------------------------------------------------------------------------------ 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; g_hud.Rebuild(width, height); }
//------------------------------------------------------------------------------ static void reshape(GLFWwindow *, int width, int height) { g_width = width; g_height = height; int windowWidth = g_width, windowHeight = g_height; // window size might not match framebuffer size on a high DPI display glfwGetWindowSize(g_window, &windowWidth, &windowHeight); g_hud.Rebuild(windowWidth, windowHeight, width, height); }
//------------------------------------------------------------------------------ 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); }
//------------------------------------------------------------------------------ static void initHUD() { int windowWidth = g_width, windowHeight = g_height, frameBufferWidth = g_width, frameBufferHeight = g_height; // window size might not match framebuffer size on a high DPI display glfwGetWindowSize(g_window, &windowWidth, &windowHeight); glfwGetFramebufferSize(g_window, &frameBufferWidth, &frameBufferHeight); g_hud.Init(windowWidth, windowHeight, frameBufferWidth, frameBufferHeight); g_hud.AddCheckBox("Control edges (H)", g_controlMeshDisplay.GetEdgesDisplay(), 10, 10, callbackCheckBox, kHUD_CB_DISPLAY_CONTROL_MESH_EDGES, 'h'); g_hud.AddCheckBox("Control vertices (J)", g_controlMeshDisplay.GetVerticesDisplay(), 10, 30, callbackCheckBox, kHUD_CB_DISPLAY_CONTROL_MESH_VERTS, 'j'); g_hud.AddCheckBox("Animate vertices (M)", g_moveScale != 0, 10, 50, callbackCheckBox, kHUD_CB_ANIMATE_VERTICES, 'm'); g_hud.AddCheckBox("Animate particles (P)", g_animParticles != 0, 10, 70, callbackCheckBox, kHUD_CB_ANIMATE_PARTICLES, 'p'); g_hud.AddCheckBox("Freeze (spc)", g_freeze != 0, 10, 90, callbackCheckBox, kHUD_CB_FREEZE, ' '); g_hud.AddCheckBox("Random Start", g_randomStart, 10, 110, callbackCheckBox, kHUD_CB_RANDOM_START); int compute_pulldown = g_hud.AddPullDown("Compute (K)", 475, 10, 300, callbackKernel, 'k'); g_hud.AddPullDownButton(compute_pulldown, "CPU", kCPU); #ifdef OPENSUBDIV_HAS_OPENMP g_hud.AddPullDownButton(compute_pulldown, "OPENMP", kOPENMP); #endif #ifdef OPENSUBDIV_HAS_TBB g_hud.AddPullDownButton(compute_pulldown, "TBB", kTBB); #endif #ifdef OPENSUBDIV_HAS_CUDA g_hud.AddPullDownButton(compute_pulldown, "CUDA", kCUDA); #endif #ifdef OPENSUBDIV_HAS_OPENCL if (CLDeviceContext::HAS_CL_VERSION_1_1()) { g_hud.AddPullDownButton(compute_pulldown, "OpenCL", kCL); } #endif #ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK g_hud.AddPullDownButton(compute_pulldown, "GL XFB", kGLXFB); #endif #ifdef OPENSUBDIV_HAS_GLSL_COMPUTE if (GLUtils::GL_ARBComputeShaderOrGL_VERSION_4_3()) { g_hud.AddPullDownButton(compute_pulldown, "GL Compute", kGLCompute); } #endif int endcap_pulldown = g_hud.AddPullDown("End cap (E)", 10, 140, 200, callbackEndCap, 'e'); g_hud.AddPullDownButton(endcap_pulldown, "BSpline", kEndCapBSplineBasis, g_endCap == kEndCapBSplineBasis); g_hud.AddPullDownButton(endcap_pulldown, "GregoryBasis", kEndCapGregoryBasis, g_endCap == kEndCapGregoryBasis); int shading_pulldown = g_hud.AddPullDown("Shading (W)", 250, 10, 250, callbackDisplayVaryingColors, 'w'); g_hud.AddPullDownButton(shading_pulldown, "(u,v)", kUV, g_drawMode==kUV); g_hud.AddPullDownButton(shading_pulldown, "Varying", kVARYING, g_drawMode==kVARYING); g_hud.AddPullDownButton(shading_pulldown, "Normal", kNORMAL, g_drawMode==kNORMAL); g_hud.AddPullDownButton(shading_pulldown, "Shade", kSHADE, g_drawMode==kSHADE); g_hud.AddPullDownButton(shading_pulldown, "FaceVarying", kFACEVARYING, g_drawMode==kFACEVARYING); for (int i = 1; i < 11; ++i) { char level[16]; sprintf(level, "Lv. %d", i); g_hud.AddRadioButton(3, level, i==g_level, 10, 170+i*20, callbackLevel, i, '0'+(i%10)); } int pulldown_handle = g_hud.AddPullDown("Shape (N)", -300, 10, 300, callbackModel, 'n'); for (int i = 0; i < (int)g_defaultShapes.size(); ++i) { g_hud.AddPullDownButton(pulldown_handle, g_defaultShapes[i].name.c_str(),i); } g_hud.Rebuild(windowWidth, windowHeight, frameBufferWidth, frameBufferHeight); }