| 1080 | } |
| 1081 | |
| 1082 | void MiniGL::mainLoop() |
| 1083 | { |
| 1084 | while (!glfwWindowShouldClose(m_glfw_window)) |
| 1085 | { |
| 1086 | if (idlefunc != nullptr) |
| 1087 | idlefunc(); |
| 1088 | |
| 1089 | double currentTime = glfwGetTime(); |
| 1090 | if (currentTime - m_lastTime >= 1.0 / 60.0) // render at maximum at 60 fps |
| 1091 | { |
| 1092 | glfwPollEvents(); |
| 1093 | |
| 1094 | glPolygonMode(GL_FRONT_AND_BACK, drawMode); |
| 1095 | viewport(); |
| 1096 | |
| 1097 | if (scenefunc != nullptr) |
| 1098 | scenefunc(); |
| 1099 | |
| 1100 | if (selectionMode) |
| 1101 | drawSelectionRect(); |
| 1102 | |
| 1103 | if (m_vsync) |
| 1104 | glfwSwapBuffers(m_glfw_window); |
| 1105 | else |
| 1106 | glFlush(); |
| 1107 | |
| 1108 | m_lastTime = currentTime; |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | if (destroyfunc != nullptr) |
| 1113 | destroyfunc(); |
| 1114 | |
| 1115 | destroy(); |
| 1116 | |
| 1117 | glfwDestroyWindow(m_glfw_window); |
| 1118 | |
| 1119 | glfwTerminate(); |
| 1120 | } |
| 1121 | |
| 1122 | void MiniGL::leaveMainLoop() |
| 1123 | { |
nothing calls this directly
no test coverage detected