void mouseButton(GLFWwindow * window, int button, int action, int mods) { if(!TwEventMouseButtonGLFW(button, action)) { if(button != GLFW_MOUSE_BUTTON_LEFT) return; switch(action) { case GLFW_PRESS: double x, y; glfwGetCursorPos(window, &x, &y); scene->mousePress(x, y); break; case GLFW_RELEASE: scene->mouseRelease(); break; default: break; } } }
void GLFW_App::s_mouseButton(GLFWwindow* window,int button, int action, int modifier_mask) { GLFW_App* app = static_cast<GLFW_App*>(glfwGetWindowUserPointer(window)); if(app->displayTweakBar()) TwEventMouseButtonGLFW(button, action); uint32_t initiator, keyModifiers, bothMods; s_getModifiers(window, initiator, keyModifiers); bothMods = initiator | keyModifiers; double posX, posY; glfwGetCursorPos(window, &posX, &posY); MouseEvent e(initiator, (int)posX, (int)posY, bothMods, glm::ivec2(0)); switch(action) { case GLFW_PRESS: app->mousePress(e); break; case GLFW_RELEASE: app->mouseRelease(e); break; } }
// Callback function called by GLFW when a mouse button is clicked void GLFWCALL OnMouseButton(int glfwButton, int glfwAction) { if( !TwEventMouseButtonGLFW(glfwButton, glfwAction) ) // Send event to AntTweakBar { // Event has not been handled by AntTweakBar // Do something if needed. } }
void mouseDown_Aux(GLFWwindow* pWindow, int button, int action, int mods) { (void)pWindow; (void)mods; #ifdef USE_ANTTWEAKBAR int ant = TwEventMouseButtonGLFW(button, action); if (ant != 0) return; #endif mouseDown(pWindow, button, action, mods); }
void mouseButtonCallback(GLFWwindow* window, int button, int action, int mods) { double x, y; glfwGetCursorPos(window, &x, &y); if(!TwEventMouseButtonGLFW(button, action)){ if (action == GLFW_PRESS) { mouseButtonPressed(button, x, y); } else { mouseButtonReleased(button, x, y); } } }
void GLFWCALL OnMouseButton(int glfwButton, int glfwAction) { //if(!prevrMouseDown) { if( !TwEventMouseButtonGLFW(glfwButton, glfwAction) ) // Send event to AntTweakBar { GUIactive = false; // Event has not been handled by AntTweakBar // Do something if needed. } else GUIactive = true; } }
void mouseButton(GLFWwindow* window, int button, int action, int mods){ if (TwEventMouseButtonGLFW(button, action)) return; double x, y; glfwGetCursorPos(gpWindow, &x, &y); float ax = x; float ay = gHeight - y; if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS){ gpCamera->setLeftButtonPress(true, x,y); processSelection(x, y); } if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE){ gpCamera->setLeftButtonPress(false, x, y); } }
static void onMouseDown(GLFWwindow* window, int button, int action, int mods) { // AntTweakBar event if (TwEventMouseButtonGLFW(button, action)) return; // Scroll wheel press if (button == GLFW_MOUSE_BUTTON_1){ if (action == GLFW_PRESS){ s_camera.setMode(glfwGetKey(window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS ? CameraMode::ARC : CameraMode::PAN); } else if (action == GLFW_RELEASE){ s_camera.setMode(CameraMode::NONE); } } // Generate selection ray if (button == GLFW_MOUSE_BUTTON_2){ if (action == GLFW_PRESS){ // Get mouse pos double mouse_x, mouse_y; glfwGetCursorPos(window, &mouse_x, &mouse_y); // Calc selection ray int screenWidth, screenHeight; glfwGetWindowSize(window, &screenWidth, &screenHeight); double x = (2.0f * mouse_x) / double(screenWidth) - 1.0f; double y = 1.0f - (2.0f * mouse_y) / double(screenHeight); glm::vec4 ray_clip = glm::vec4(x, y, -1.0, 1.0); glm::vec4 ray_eye = glm::inverse(s_proj) * ray_clip; ray_eye = glm::vec4(ray_eye.x, ray_eye.y, -1.0, 0.0); glm::vec3 ray_wor = glm::normalize(glm::vec3(inverse(s_camera.getView()) * ray_eye)); // Ray cast event rayCast(ray_wor); } else if (action == GLFW_RELEASE) { delete g_drag; g_drag = NULL; } } }
// Wrapper functions for tweak bar - tweak bar expects GLFW(<3) format callbacks void myTwEventMouseButtonGLFW(GLFWwindow* window, int button, int action, int mods) { TwEventMouseButtonGLFW(button, action); }
void DebugUIMousePress(int button, int state) { TwEventMouseButtonGLFW(button, state); }
void App::glfw_mouseButton(GLFWwindow *window, int x, int y, int z) { TwEventMouseButtonGLFW(x, y); }
bool Sample::mouse_button(int button, int action) { return !!TwEventMouseButtonGLFW(button, action); }
void gui_mouse_up( i32 key ) { TwEventMouseButtonGLFW( key, 0 ); }
void gui_mouse_down( i32 key ) { TwEventMouseButtonGLFW( key, 1 ); }
// functions with __cdecl calling convension TW_API int TW_CDECL_CALL TwEventMouseButtonGLFWcdecl(int glfwButton, int glfwAction) { return TwEventMouseButtonGLFW(glfwButton, glfwAction); }
void GLFWCALL mouseButtonListener(int a, int b) { TwEventMouseButtonGLFW(a,b); }
void OGLApp::glfw_mouseButton(GLFWwindow *window, int x, int y, int z) { //OGLSphereCamera::getInstance()->mouseButton_callback(window, x, y, z); TwEventMouseButtonGLFW(x, y); }
void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods) { int tweak = TwEventMouseButtonGLFW(button, action); }