gl.c (753B)
1 #include <GLFW/glfw3.h> 2 #include <assert.h> 3 #include <math.h> 4 5 char const* __asan_default_options() { return "detect_leaks=0"; } 6 7 static void fb_resize_cb(GLFWwindow*, int w, int h) 8 { 9 glViewport(0, 0, w, h); 10 } 11 12 int main(int, char* argv[]) 13 { 14 assert(glfwInit()); 15 GLFWwindow* window = glfwCreateWindow(640, 480, argv[0], NULL, NULL); 16 assert(window); 17 glfwSetFramebufferSizeCallback(window, fb_resize_cb); 18 glfwMakeContextCurrent(window); 19 glfwSwapInterval(1); 20 glClearColor(0, 0, 0, 1); 21 22 while (!glfwWindowShouldClose(window)) 23 { 24 glfwPollEvents(); 25 double t = glfwGetTime() / 2; 26 t = t - floor(t); 27 t *= 3; 28 glClear(GL_COLOR_BUFFER_BIT); 29 glRectd(t-2,-1, t-1, 1); 30 glfwSwapBuffers(window); 31 } 32 glfwTerminate(); /* Implicit window destroy */ 33 }