Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3778)

Unified Diff: client/deps/glbench/src/trianglesetuptest.cc

Issue 2965008: Converted triangle setup test to GLES2. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: renamed shader variables Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/deps/glbench/src/main.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/trianglesetuptest.cc
diff --git a/client/deps/glbench/src/trianglesetuptest.cc b/client/deps/glbench/src/trianglesetuptest.cc
index e905b98b4217bbeeae1d0d0a26a925ff687e9e90..e4a46d835d27cac5fdc439b66ab027d5f7a7a8a1 100644
--- a/client/deps/glbench/src/trianglesetuptest.cc
+++ b/client/deps/glbench/src/trianglesetuptest.cc
@@ -23,6 +23,17 @@ class TriangleSetupTest : public DrawElementsTestFunc {
DISALLOW_COPY_AND_ASSIGN(TriangleSetupTest);
};
+const char* kVertexShader =
+ "attribute vec4 c;"
+ "void main() {"
+ " gl_Position = c;"
+ "}";
+
+const char* kFragmentShader =
+ "uniform vec4 color;"
+ "void main() {"
+ " gl_FragColor = color;"
+ "}";
bool TriangleSetupTest::Run() {
glViewport(-g_width, -g_height, g_width*2, g_height*2);
@@ -37,14 +48,22 @@ bool TriangleSetupTest::Run() {
width, height);
GLuint vertex_buffer = SetupVBO(GL_ARRAY_BUFFER,
vertex_buffer_size, vertices);
- glVertexPointer(2, GL_FLOAT, 0, 0);
- glEnableClientState(GL_VERTEX_ARRAY);
+
+ GLuint program =
+ InitShaderProgram(kVertexShader, kFragmentShader);
+ GLint attribute_index = glGetAttribLocation(program, "c");
+ glVertexAttribPointer(attribute_index, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+ glEnableVertexAttribArray(attribute_index);
+
+ GLint color_uniform = glGetUniformLocation(program, "color");
GLuint *indices = NULL;
GLuint index_buffer = 0;
GLsizeiptr index_buffer_size = 0;
{
+ const GLfloat white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ glUniform4fv(color_uniform, 1, white);
count_ = CreateMesh(&indices, &index_buffer_size, width, height, 0);
index_buffer = SetupVBO(GL_ELEMENT_ARRAY_BUFFER,
@@ -59,7 +78,8 @@ bool TriangleSetupTest::Run() {
}
{
- glColor4f(0.f, 1.f, 1.f, 1.f);
+ const GLfloat cyan[4] = {0.0f, 1.0f, 1.0f, 1.0f};
+ glUniform4fv(color_uniform, 1, cyan);
count_ = CreateMesh(&indices, &index_buffer_size, width, height,
RAND_MAX / 2);
@@ -72,6 +92,7 @@ bool TriangleSetupTest::Run() {
delete[] indices;
}
+ glDeleteProgram(program);
glDeleteBuffers(1, &vertex_buffer);
delete[] vertices;
return true;
« no previous file with comments | « client/deps/glbench/src/main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698