TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ OnUpdate()

virtual void MyApp::OnUpdate ( float  deltatime)
inlineoverridevirtual

Reimplemented from Application.

Definition at line 690 of file Main.cpp.

691 {
692 if (!appState->states.ruinning)
693 {
694 return;
695 }
696
697 if (!appState->states.exploreMode)
698 {
699 // CTRL Shortcuts
700 if ((glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_LEFT_CONTROL) || glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_RIGHT_CONTROL)))
701 {
702 // Open Shortcut
703 if (glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_O))
704 {
705 OpenSaveFile();
706 }
707
708 // Exit Shortcut
709 if (glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_Q))
710 {
711 exit(0);
712 }
713
714 // Save Shortcut
715 if (glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_S))
716 {
717 if (appState->globals.currentOpenFilePath.size() > 3)
718 {
719 Log("Saved to " + appState->globals.currentOpenFilePath);
720 SaveFile(appState->globals.currentOpenFilePath);
721 }
722
723 else
724 {
725 SaveFile();
726 }
727 }
728
729 // Close Shortcut
730 if (glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_W))
731 {
732 if (appState->globals.currentOpenFilePath.size() > 3)
733 {
734 Log("CLosed file " + appState->globals.currentOpenFilePath);
735 appState->globals.currentOpenFilePath = "";
736 }
737
738 else
739 {
740 Log("Shutting Down");
741 exit(0);
742 }
743 }
744
745 // CTRL + SHIFT Shortcuts
746 if ((glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_LEFT_SHIFT) || glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_RIGHT_SHIFT))) // Save Shortcut
747 {
748 // Save As Shortcuts
749 if (glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_S))
750 {
751 appState->globals.currentOpenFilePath = "";
752 SaveFile();
753 }
754
755 // Explorer Mode Shortcut
756 if (glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_X))
757 {
758 Log("Toggle Explorer Mode");
759 appState->states.exploreMode = true;
760 }
761 }
762 }
763
764 appState->stats.deltatime = deltatime;
765
766 {
767 appState->frameBuffers.reflection->Begin();
768 glViewport(0, 0, appState->frameBuffers.reflection->GetWidth(), appState->frameBuffers.reflection->GetHeight());
769 GetWindow()->Clear();
770 DoTheRederThing(deltatime);
771 glBindFramebuffer(GL_FRAMEBUFFER, appState->frameBuffers.main->GetRendererID());
772 glViewport(0, 0, appState->frameBuffers.main->GetWidth(), appState->frameBuffers.main->GetHeight());
773 GetWindow()->Clear();
774 DoTheRederThing(deltatime, true);
775
776 if (appState->states.postProcess)
777 {
778 appState->frameBuffers.postProcess->Begin();
779 GetWindow()->Clear();
780 PostProcess(deltatime);
781 }
782 }
783
784 glBindFramebuffer(GL_FRAMEBUFFER, 0);
785 RenderImGui();
786 }
787
788 else
789 {
790 static bool expH = false;
791
792 if (!expH)
793 {
794 GetWindow()->SetFullScreen(true);
795 glfwSetInputMode(GetWindow()->GetNativeWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
796 ExPSaveCamera(appState->cameras.main.position, appState->cameras.main.rotation);
797 }
798
799 expH = appState->states.exploreMode;
800 appState->stats.deltatime = deltatime;
801 appState->frameBuffers.reflection->Begin();
802 glViewport(0, 0, appState->frameBuffers.reflection->GetWidth(), appState->frameBuffers.reflection->GetHeight());
803 GetWindow()->Clear();
804 DoTheRederThing(deltatime);
805 appState->frameBuffers.reflection->End();
806 glBindFramebuffer(GL_FRAMEBUFFER, 0);
807 int w, h;
808 glfwGetWindowSize(GetWindow()->GetNativeWindow(), &w, &h);
809 glViewport(0, 0, w, h);
810 GetWindow()->Clear();
811 UpdateExplorerControls(appState->cameras.main.position, appState->cameras.main.rotation, appState->states.iExploreMode, &appState->globals.offset[0], &appState->globals.offset[1]);
812 DoTheRederThing(deltatime, true);
813
814 if (appState->states.postProcess)
815 {
816 appState->frameBuffers.postProcess->Begin();
817 PostProcess(deltatime);
818 }
819
820 if ((glfwGetKey(GetWindow()->GetNativeWindow(), GLFW_KEY_ESCAPE)))
821 {
822 appState->states.exploreMode = false;
823 expH = false;
824 glfwSetInputMode(GetWindow()->GetNativeWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
825 GetWindow()->SetFullScreen(false);
826 ExPRestoreCamera(appState->cameras.main.position, appState->cameras.main.rotation);
827 }
828 }
829
830 if (appState->states.autoUpdate)
831 {
832 RegenerateMesh();
833 }
834
835 appState->modules.manager->UpdateModules();
836 }