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 // Application that displays graphics using OpenGL [ES] with the intent | 5 // Application that displays graphics using OpenGL [ES] with the intent |
6 // of being used in functional tests. | 6 // of being used in functional tests. |
7 | 7 |
8 #include <gflags/gflags.h> | 8 #include <gflags/gflags.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, g_height, g_width, 0, | 91 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, g_height, g_width, 0, |
92 GL_LUMINANCE, GL_UNSIGNED_BYTE, bitmap); | 92 GL_LUMINANCE, GL_UNSIGNED_BYTE, bitmap); |
93 | 93 |
94 GLfloat vertices[8] = { | 94 GLfloat vertices[8] = { |
95 0.f, 0.f, | 95 0.f, 0.f, |
96 1.f, 0.f, | 96 1.f, 0.f, |
97 0.f, 1.f, | 97 0.f, 1.f, |
98 1.f, 1.f, | 98 1.f, 1.f, |
99 }; | 99 }; |
100 | 100 |
101 GLuint program = InitShaderProgram(kVertexShader, kFragmentShader); | 101 GLuint program = glbench::InitShaderProgram(kVertexShader, kFragmentShader); |
102 int attribute_index = glGetAttribLocation(program, "vertices"); | 102 int attribute_index = glGetAttribLocation(program, "vertices"); |
103 glVertexAttribPointer(attribute_index, 2, GL_FLOAT, GL_FALSE, 0, vertices); | 103 glVertexAttribPointer(attribute_index, 2, GL_FLOAT, GL_FALSE, 0, vertices); |
104 glEnableVertexAttribArray(attribute_index); | 104 glEnableVertexAttribArray(attribute_index); |
105 | 105 |
106 int texture_sampler = glGetUniformLocation(program, "tex"); | 106 int texture_sampler = glGetUniformLocation(program, "tex"); |
107 glUniform1i(texture_sampler, 0); | 107 glUniform1i(texture_sampler, 0); |
108 | 108 |
109 int display_color = glGetUniformLocation(program, "color"); | 109 int display_color = glGetUniformLocation(program, "color"); |
110 float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | 110 float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; |
111 float blue[4] = {0.5f, 0.5f, 1.0f, 1.0f}; | 111 float blue[4] = {0.5f, 0.5f, 1.0f, 1.0f}; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Advance to next state | 155 // Advance to next state |
156 last_event_time = GetUTime(); | 156 last_event_time = GetUTime(); |
157 state = static_cast<State>(state + 1); | 157 state = static_cast<State>(state + 1); |
158 | 158 |
159 } while (state != kStateExit); | 159 } while (state != kStateExit); |
160 | 160 |
161 glDeleteTextures(1, &texture); | 161 glDeleteTextures(1, &texture); |
162 DestroyContext(); | 162 DestroyContext(); |
163 return 0; | 163 return 0; |
164 } | 164 } |
OLD | NEW |