OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "main.h" | 10 #include "main.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 glEnableVertexAttribArray(attribute_index); | 105 glEnableVertexAttribArray(attribute_index); |
106 | 106 |
107 int texture_sampler = glGetUniformLocation(program, "tex"); | 107 int texture_sampler = glGetUniformLocation(program, "tex"); |
108 glUniform1f(texture_sampler, 0); | 108 glUniform1f(texture_sampler, 0); |
109 | 109 |
110 int shift_uniform = glGetUniformLocation(program, "shift"); | 110 int shift_uniform = glGetUniformLocation(program, "shift"); |
111 int i = 0; | 111 int i = 0; |
112 SwapInterval(g_sleep_duration ? 0 : 1); | 112 SwapInterval(g_sleep_duration ? 0 : 1); |
113 for (;;) { | 113 for (;;) { |
114 XEvent event; | 114 XEvent event; |
115 Bool got_event = XCheckWindowEvent(xlib_display, xlib_window, | 115 Bool got_event = XCheckWindowEvent(g_xlib_display, g_xlib_window, |
116 KeyPressMask, &event); | 116 KeyPressMask, &event); |
117 if (got_event) | 117 if (got_event) |
118 break; | 118 break; |
119 glClear(GL_COLOR_BUFFER_BIT); | 119 glClear(GL_COLOR_BUFFER_BIT); |
120 glUniform1f(shift_uniform, 1.f / g_width * | 120 glUniform1f(shift_uniform, 1.f / g_width * |
121 (i < g_width ? i : 2 * g_width - i)); | 121 (i < g_width ? i : 2 * g_width - i)); |
122 i = (i + 4) % (2 * g_width); | 122 i = (i + 4) % (2 * g_width); |
123 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 123 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
124 glFlush(); | 124 glFlush(); |
125 | 125 |
126 if (g_sleep_duration) | 126 if (g_sleep_duration) |
127 nanosleep(g_sleep_duration, NULL); | 127 nanosleep(g_sleep_duration, NULL); |
128 | 128 |
129 SwapBuffers(); | 129 SwapBuffers(); |
130 } | 130 } |
131 | 131 |
132 glDeleteTextures(1, &texture); | 132 glDeleteTextures(1, &texture); |
133 DestroyContext(); | 133 DestroyContext(); |
134 return 0; | 134 return 0; |
135 } | 135 } |
OLD | NEW |