| 945 | } |
| 946 | |
| 947 | void 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 | |
| 985 | void MiniGL::leaveMainLoop() |
| 986 | { |
nothing calls this directly
no test coverage detected