MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / mainLoop

Method mainLoop

Demos/Visualization/MiniGL.cpp:947–983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945}
946
947void MiniGL::mainLoop()
948{
949 while (!glfwWindowShouldClose(m_glfw_window))
950 {
951 if (idlefunc != nullptr)
952 idlefunc();
953
954 double currentTime = glfwGetTime();
955 if (currentTime - m_lastTime >= 1.0 / 60.0) // render at maximum at 60 fps
956 {
957 glfwPollEvents();
958
959 glPolygonMode(GL_FRONT_AND_BACK, drawMode);
960 viewport();
961
962 drawElements();
963
964 if (scenefunc != nullptr)
965 scenefunc();
966
967 if (m_vsync)
968 glfwSwapBuffers(m_glfw_window);
969 else
970 glFlush();
971 m_lastTime = currentTime;
972 }
973 }
974
975 if (destroyfunc != nullptr)
976 destroyfunc();
977
978 glfwDestroyWindow(m_glfw_window);
979
980 glfwTerminate();
981
982 destroy();
983}
984
985void MiniGL::leaveMainLoop()
986{

Callers

nothing calls this directly

Calls 6

glfwWindowShouldCloseFunction · 0.85
glfwGetTimeFunction · 0.85
glfwPollEventsFunction · 0.85
glfwSwapBuffersFunction · 0.85
glfwDestroyWindowFunction · 0.85
glfwTerminateFunction · 0.85

Tested by

no test coverage detected