| 409 | double old_time; |
| 410 | |
| 411 | void Iteration() { |
| 412 | // calculate time elapsed, and the amount by which stuff rotates |
| 413 | double current_time = glfwGetTime(), |
| 414 | delta_rotate = (current_time - old_time) * rotations_per_tick * 360; |
| 415 | old_time = current_time; |
| 416 | if (glfwGetKey(GLFW_KEY_LEFT) == GLFW_PRESS) |
| 417 | rotate_y += delta_rotate; |
| 418 | if (glfwGetKey(GLFW_KEY_RIGHT) == GLFW_PRESS) |
| 419 | rotate_y -= delta_rotate; |
| 420 | // z axis always rotates |
| 421 | rotate_z += delta_rotate; |
| 422 | |
| 423 | // clear the buffer |
| 424 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 425 | // draw the figure |
| 426 | Draw(); |
| 427 | |
| 428 | // Test that glfwSwapInterval doesn't crash (although we don't test actual timings) |
| 429 | static int i = 0; |
| 430 | glfwSwapInterval(i); |
| 431 | if (i < 2) ++i; |
| 432 | |
| 433 | // swap back and front buffers |
| 434 | glfwSwapBuffers(); |
| 435 | } |
| 436 | |
| 437 | int main() { |
| 438 | Init(); |