MCPcopy Create free account
hub / github.com/RenderKit/embree / keyboardFunc

Method keyboardFunc

tutorials/common/tutorial/tutorial.cpp:744–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742 }
743
744 void TutorialApplication::keyboardFunc(GLFWwindow* window_in, int key, int scancode, int action, int mods)
745 {
746 ImGui_ImplGlfw_KeyCallback(window_in,key,scancode,action,mods);
747 if (ImGui::GetIO().WantCaptureKeyboard) return;
748
749 if (action == GLFW_PRESS)
750 {
751 /* call tutorial keyboard handler */
752 keypressed(key);
753
754 if (mods & GLFW_MOD_CONTROL)
755 {
756 switch (key) {
757 case GLFW_KEY_UP : debug_int0++; set_parameter(1000000,debug_int0); PRINT(debug_int0); break;
758 case GLFW_KEY_DOWN : debug_int0--; set_parameter(1000000,debug_int0); PRINT(debug_int0); break;
759 case GLFW_KEY_LEFT : debug_int1--; set_parameter(1000001,debug_int1); PRINT(debug_int1); break;
760 case GLFW_KEY_RIGHT : debug_int1++; set_parameter(1000001,debug_int1); PRINT(debug_int1); break;
761 }
762 }
763 else
764 {
765 switch (key) {
766 case GLFW_KEY_LEFT : camera.rotate(-0.02f,0.0f); break;
767 case GLFW_KEY_RIGHT : camera.rotate(+0.02f,0.0f); break;
768 case GLFW_KEY_UP : camera.move(0.0f,0.0f,+speed); break;
769 case GLFW_KEY_DOWN : camera.move(0.0f,0.0f,-speed); break;
770 case GLFW_KEY_PAGE_UP : speed *= 1.2f; break;
771 case GLFW_KEY_PAGE_DOWN : speed /= 1.2f; break;
772
773 case GLFW_KEY_W : moveDelta.z = +1.0f; break;
774 case GLFW_KEY_S : moveDelta.z = -1.0f; break;
775 case GLFW_KEY_A : moveDelta.x = -1.0f; break;
776 case GLFW_KEY_D : moveDelta.x = +1.0f; break;
777
778 case GLFW_KEY_F :
779 glfwDestroyWindow(window);
780 if (fullscreen) {
781 width = window_width;
782 height = window_height;
783 window = createStandardWindow(width,height);
784 setCallbackFunctions(window);
785 }
786 else {
787 window_width = width;
788 window_height = height;
789 window = createFullScreenWindow();
790 setCallbackFunctions(window);
791 }
792 glfwMakeContextCurrent(window);
793 fullscreen = !fullscreen;
794 break;
795
796 case GLFW_KEY_C : std::cout << camera.str() << std::endl; break;
797 case GLFW_KEY_HOME: g_debug=clamp(g_debug+0.01f); PRINT(g_debug); break;
798 case GLFW_KEY_END : g_debug=clamp(g_debug-0.01f); PRINT(g_debug); break;
799
800 case GLFW_KEY_SPACE: {
801 Ref<Image> image = new Image4uc(width, height, (Col4uc*)pixels, true, "", true);

Callers 1

keyboardFuncFunction · 0.80

Calls 6

storeImageFunction · 0.85
moveMethod · 0.80
clampFunction · 0.50
rotateMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected