| 81 | } |
| 82 | |
| 83 | void draw() |
| 84 | { |
| 85 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 86 | |
| 87 | const auto t_elapsed = std::chrono::high_resolution_clock::now() - g_starttime; |
| 88 | const auto t = static_cast<float>(t_elapsed.count()) * 4e-10f; |
| 89 | glm::mat4 R = glm::rotate(t * 1.f, glm::vec3(sin(t * 0.321f), cos(t * 0.234f), sin(t * 0.123f))); |
| 90 | |
| 91 | g_sphere->setUniform("transform", g_viewProjection); |
| 92 | g_sphere->setUniform("rotation", R); |
| 93 | |
| 94 | const auto level = static_cast<int>((sin(t) * 0.5f + 0.5f) * 16) + 1; |
| 95 | g_sphere->setUniform("level", level); |
| 96 | g_sphere->use(); |
| 97 | |
| 98 | glViewport(0, 0, g_size.x, g_size.y); |
| 99 | |
| 100 | glPatchParameteri(GL_PATCH_VERTICES, 3); |
| 101 | g_icosahedron->draw(GL_PATCHES); |
| 102 | |
| 103 | g_sphere->release(); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | void error(int errnum, const char * errmsg) |