diff mbox

[Branch,~glcompbench-dev/glcompbench/trunk] Rev 22: Merge branch that splits different tests into separate files.

Message ID 20110622083047.22352.91669.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org June 22, 2011, 8:30 a.m. UTC
Merge authors:
  Jesse Barker (jesse-barker)
Related merge proposals:
  https://code.launchpad.net/~jesse-barker/glcompbench/split/+merge/59682
  proposed by: Jesse Barker (jesse-barker)
  review: Approve - Alexandros Frantzis (afrantzis)
------------------------------------------------------------
revno: 22 [merge]
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Wed 2011-06-22 11:28:05 +0300
message:
  Merge branch that splits different tests into separate files.
added:
  src/composite-test-brick.cc
modified:
  src/composite-test.cc
  src/composite-test.h


--
lp:glcompbench
https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk

You are subscribed to branch lp:glcompbench.
To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription
diff mbox

Patch

=== added file 'src/composite-test-brick.cc'
--- src/composite-test-brick.cc	1970-01-01 00:00:00 +0000
+++ src/composite-test-brick.cc	2011-05-02 17:37:00 +0000
@@ -0,0 +1,190 @@ 
+/*
+ * Copyright © 2011 Linaro Limited
+ *
+ * This file is part of glcompbench.
+ *
+ * glcompbench is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * glcompbench is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with glcompbench.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
+ *  Jesse Barker <jesse.barker@linaro.org>
+ */
+
+#include "composite-test.h"
+#include "options.h"
+#include "log.h"
+
+using std::string;
+using LibMatrix::vec2;
+using LibMatrix::vec3;
+
+const string CompositeTestBrick::lightPosName_("LightPosition");
+const string CompositeTestBrick::brickSizeName_("BrickSize");
+const string CompositeTestBrick::brickPctName_("BrickPct");
+const vec2 CompositeTestBrick::brickSize_(0.30, 0.15);
+const vec2 CompositeTestBrick::brickPct_(0.90, 0.85);
+
+void
+CompositeTestBrick::init()
+{
+    // Initialize shader sources from input files
+    string vsFilename(GLCOMPBENCH_DATA_PATH"/brick-vertex-shader");
+    if (!gotSource(vsFilename, vertex_shader_))
+    {
+        Log::error("Failed to get vertex shader source for test\n");
+        return;
+    }
+    string fsFilename(GLCOMPBENCH_DATA_PATH"/brick-fragment-shader");
+    if (!gotSource(fsFilename, fragment_shader_))
+    {
+        Log::error("Failed to get fragment shader source for test\n");
+        return;
+    }
+
+    program_.init();
+    if (!program_.valid())
+    {
+        Log::error("No valid program for compositing (reason: %s)\n",
+                   program_.errorMessage().c_str());
+        return;
+    }
+    program_.addShader(GL_VERTEX_SHADER, vertex_shader_);
+    if (!program_.valid())
+    {
+        Log::error("Failed to add vertex shader to compositing program (reason: %s)\n",
+                   program_.errorMessage().c_str());
+        return;
+    }
+    program_.addShader(GL_FRAGMENT_SHADER, fragment_shader_);
+    if (!program_.valid())
+    {
+        Log::error("Failed to add fragment shader to compositing program (reason: %s)\n",
+                   program_.errorMessage().c_str());
+        return;
+    }
+    program_.build();
+    if (!program_.ready())
+    {
+        Log::error("Failed to build compositing program (reason: %s)\n",
+                   program_.errorMessage().c_str());
+        return;
+    }
+    vertexIndex_ = program_.getAttribIndex(position_name_);
+    texcoordIndex_ = program_.getAttribIndex(texcoord_name_);
+
+    // Initialize our vertex buffer object
+    vboData_.addVertex(vec3(-1, -1, 0));
+    vboData_.addVertex(vec3( 1, -1, 0));
+    vboData_.addVertex(vec3( 1,  1, 0));
+    vboData_.addVertex(vec3(-1,  1, 0));
+
+    vboData_.addIndex(0);
+    vboData_.addIndex(1);
+    vboData_.addIndex(2);
+    vboData_.addIndex(2);
+    vboData_.addIndex(3);
+    vboData_.addIndex(0);
+
+    vboData_.addTexCoord(vec2(0, 1));
+    vboData_.addTexCoord(vec2(1, 1));
+    vboData_.addTexCoord(vec2(1, 0));
+    vboData_.addTexCoord(vec2(0, 0));
+
+    vboData_.genBufferObject();
+    vboData_.useBufferObject(Options::use_vbo);
+}
+
+void
+CompositeTestBrick::prepare_for_run()
+{
+    lightPos_ = LibMatrix::vec4(0.0, 1.0, 1.0, 0.0);
+
+    program_.start();
+    int texUnit(0);
+    program_.loadUniformScalar(texUnit, texture0_name_);
+    program_.loadUniformVector(brickSize_, brickSizeName_);
+    program_.loadUniformVector(brickPct_, brickPctName_);
+    program_.loadUniformVector(lightPos_, lightPosName_);
+
+    glClearColor(0.1, 0.1, 0.3, 1.0);
+
+    glEnable(GL_BLEND);
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+}
+
+void
+CompositeTestBrick::draw(std::list<CompositeWindow *> &window_list)
+{
+    vboData_.bind();
+    glActiveTexture(GL_TEXTURE0);
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+    /* Set up the position of the attributes in the vertex array */
+    glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0, vboData_.vertexOffset());
+    glVertexAttribPointer(texcoordIndex_, 2, GL_FLOAT, GL_FALSE, 0, vboData_.texcoordOffset());
+
+    /* Enable the attributes */
+    glEnableVertexAttribArray(vertexIndex_);
+    glEnableVertexAttribArray(texcoordIndex_);
+
+    program_.loadUniformMatrix(projection_matrix.getCurrent(),
+                               projection_matrix_name_);
+
+    /* Find out how many windows are visible and calculate the angular step */
+    GLuint visible_windows(num_visible_windows(window_list));
+    GLfloat angular_step(2 * M_PI / visible_windows);
+
+    /* Draw the windows in a circle using the calculated angular step */
+    GLint i(0);
+    for(std::list<CompositeWindow*>::iterator iter = window_list.begin();
+        iter != window_list.end(); ++iter)
+    {
+        CompositeWindow *comp_win = *iter;
+        GLuint tex = comp_win->get_texture();
+        if (tex) {
+            model_view_matrix.push();
+            model_view_matrix.translate(cos(angular_step * i),
+                                        sin(angular_step * i), 0);
+
+            /* Load shader ModelView uniform */
+            program_.loadUniformMatrix(model_view_matrix.getCurrent(),
+                                       model_view_matrix_name_);
+
+            Log::debug("Drawing Win: 0x%x Tex: 0x%x\n",
+                       comp_win->get_xwindow(), comp_win->get_texture());
+
+            glBindTexture(GL_TEXTURE_2D, tex);
+            vboData_.draw();
+            model_view_matrix.pop();
+            ++i;
+        }
+    }
+
+    /* Disable the attributes */
+    glDisableVertexAttribArray(vertexIndex_);
+    glDisableVertexAttribArray(texcoordIndex_);
+
+    vboData_.unbind();
+
+    // Pan the light around the scene.
+    float x(lightPos_.x());
+    float y(lightPos_.y());
+    if (x >= 1.0) { x = 1.0; y -= 0.1; }
+    if (y >= 1.0) { y = 1.0; x += 0.1; }
+    if (y <= 0.0) { y = 0.0; x -= 0.1; }
+    if (x <= 0.0) { x = 0.0; y += 0.1; }
+    lightPos_.x(x);
+    lightPos_.y(y);
+    program_.loadUniformVector(lightPos_, lightPosName_);
+}

=== modified file 'src/composite-test.cc'
--- src/composite-test.cc	2011-04-27 18:10:23 +0000
+++ src/composite-test.cc	2011-05-03 16:41:28 +0000
@@ -26,20 +26,12 @@ 
 #include "log.h"
 
 using std::string;
-using std::endl;
-using LibMatrix::vec2;
-using LibMatrix::vec3;
 
 const string CompositeTest::model_view_matrix_name_("modelview");
 const string CompositeTest::projection_matrix_name_("projection");
 const string CompositeTest::texture0_name_("Texture0");
 const string CompositeTest::texcoord_name_("texcoord");
 const string CompositeTest::position_name_("position");
-const string CompositeTestBrick::lightPosName_("LightPosition");
-const string CompositeTestBrick::brickSizeName_("BrickSize");
-const string CompositeTestBrick::brickPctName_("BrickPct");
-const vec2 CompositeTestBrick::brickSize_(0.30, 0.15);
-const vec2 CompositeTestBrick::brickPct_(0.90, 0.85);
 
 /**
  * Gets the number of window that are visible.
@@ -48,8 +40,8 @@ 
  *
  * @return the number of visible windows
  */
-static int
-num_visible_windows(std::list<CompositeWindow *> &window_list)
+int
+CompositeTest::num_visible_windows(std::list<CompositeWindow *> &window_list)
 {
     int count = 0;
 
@@ -112,6 +104,8 @@ 
     texcoordIndex_ = program_.getAttribIndex(texcoord_name_);
 
     // Initialize our vertex buffer object
+    using LibMatrix::vec2;
+    using LibMatrix::vec3;
     vboData_.addVertex(vec3(-1, -1, 0));
     vboData_.addVertex(vec3( 1, -1, 0));
     vboData_.addVertex(vec3( 1,  1, 0));
@@ -225,157 +219,3 @@ 
 {
     program_.stop();
 }
-
-void
-CompositeTestBrick::init()
-{
-    // Initialize shader sources from input files
-    string vsFilename(GLCOMPBENCH_DATA_PATH"/brick-vertex-shader");
-    if (!gotSource(vsFilename, vertex_shader_))
-    {
-        Log::error("Failed to get vertex shader source for test\n");
-        return;
-    }
-    string fsFilename(GLCOMPBENCH_DATA_PATH"/brick-fragment-shader");
-    if (!gotSource(fsFilename, fragment_shader_))
-    {
-        Log::error("Failed to get fragment shader source for test\n");
-        return;
-    }
-
-    program_.init();
-    if (!program_.valid())
-    {
-        Log::error("No valid program for compositing (reason: %s)\n",
-                   program_.errorMessage().c_str());
-        return;
-    }
-    program_.addShader(GL_VERTEX_SHADER, vertex_shader_);
-    if (!program_.valid())
-    {
-        Log::error("Failed to add vertex shader to compositing program (reason: %s)\n",
-                   program_.errorMessage().c_str());
-        return;
-    }
-    program_.addShader(GL_FRAGMENT_SHADER, fragment_shader_);
-    if (!program_.valid())
-    {
-        Log::error("Failed to add fragment shader to compositing program (reason: %s)\n",
-                   program_.errorMessage().c_str());
-        return;
-    }
-    program_.build();
-    if (!program_.ready())
-    {
-        Log::error("Failed to build compositing program (reason: %s)\n",
-                   program_.errorMessage().c_str());
-        return;
-    }
-    vertexIndex_ = program_.getAttribIndex(position_name_);
-    texcoordIndex_ = program_.getAttribIndex(texcoord_name_);
-
-    // Initialize our vertex buffer object
-    vboData_.addVertex(vec3(-1, -1, 0));
-    vboData_.addVertex(vec3( 1, -1, 0));
-    vboData_.addVertex(vec3( 1,  1, 0));
-    vboData_.addVertex(vec3(-1,  1, 0));
-
-    vboData_.addIndex(0);
-    vboData_.addIndex(1);
-    vboData_.addIndex(2);
-    vboData_.addIndex(2);
-    vboData_.addIndex(3);
-    vboData_.addIndex(0);
-
-    vboData_.addTexCoord(vec2(0, 1));
-    vboData_.addTexCoord(vec2(1, 1));
-    vboData_.addTexCoord(vec2(1, 0));
-    vboData_.addTexCoord(vec2(0, 0));
-
-    vboData_.genBufferObject();
-    vboData_.useBufferObject(Options::use_vbo);
-}
-
-void
-CompositeTestBrick::prepare_for_run()
-{
-    lightPos_ = LibMatrix::vec4(0.0, 1.0, 1.0, 0.0);
-
-    program_.start();
-    int texUnit(0);
-    program_.loadUniformScalar(texUnit, texture0_name_);
-    program_.loadUniformVector(brickSize_, brickSizeName_);
-    program_.loadUniformVector(brickPct_, brickPctName_);
-    program_.loadUniformVector(lightPos_, lightPosName_);
-
-    glClearColor(0.1, 0.1, 0.3, 1.0);
-
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-}
-
-void
-CompositeTestBrick::draw(std::list<CompositeWindow *> &window_list)
-{
-    vboData_.bind();
-    glActiveTexture(GL_TEXTURE0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-    /* Set up the position of the attributes in the vertex array */
-    glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0, vboData_.vertexOffset());
-    glVertexAttribPointer(texcoordIndex_, 2, GL_FLOAT, GL_FALSE, 0, vboData_.texcoordOffset());
-
-    /* Enable the attributes */
-    glEnableVertexAttribArray(vertexIndex_);
-    glEnableVertexAttribArray(texcoordIndex_);
-
-    program_.loadUniformMatrix(projection_matrix.getCurrent(),
-                               projection_matrix_name_);
-
-    /* Find out how many windows are visible and calculate the angular step */
-    GLuint visible_windows(num_visible_windows(window_list));
-    GLfloat angular_step(2 * M_PI / visible_windows);
-
-    /* Draw the windows in a circle using the calculated angular step */
-    GLint i(0);
-    for(std::list<CompositeWindow*>::iterator iter = window_list.begin();
-        iter != window_list.end(); ++iter)
-    {
-        CompositeWindow *comp_win = *iter;
-        GLuint tex = comp_win->get_texture();
-        if (tex) {
-            model_view_matrix.push();
-            model_view_matrix.translate(cos(angular_step * i),
-                                        sin(angular_step * i), 0);
-
-            /* Load shader ModelView uniform */
-            program_.loadUniformMatrix(model_view_matrix.getCurrent(),
-                                       model_view_matrix_name_);
-
-            Log::debug("Drawing Win: 0x%x Tex: 0x%x\n",
-                       comp_win->get_xwindow(), comp_win->get_texture());
-
-            glBindTexture(GL_TEXTURE_2D, tex);
-            vboData_.draw();
-            model_view_matrix.pop();
-            ++i;
-        }
-    }
-
-    /* Disable the attributes */
-    glDisableVertexAttribArray(vertexIndex_);
-    glDisableVertexAttribArray(texcoordIndex_);
-
-    vboData_.unbind();
-
-    // Pan the light around the scene.
-    float x(lightPos_.x());
-    float y(lightPos_.y());
-    if (x >= 1.0) { x = 1.0; y -= 0.1; }
-    if (y >= 1.0) { y = 1.0; x += 0.1; }
-    if (y <= 0.0) { y = 0.0; x -= 0.1; }
-    if (x <= 0.0) { x = 0.0; y += 0.1; }
-    lightPos_.x(x);
-    lightPos_.y(y);
-    program_.loadUniformVector(lightPos_, lightPosName_);
-}

=== modified file 'src/composite-test.h'
--- src/composite-test.h	2011-04-27 17:49:30 +0000
+++ src/composite-test.h	2011-05-03 16:41:28 +0000
@@ -46,6 +46,14 @@ 
     const std::string& name() const { return name_; }
 protected:
     CompositeTest();
+    //
+    // Gets the number of windows that are visible.
+    //
+    // @param window_list the window list to search in
+    //
+    // @return the number of visible windows
+    //
+    int num_visible_windows(std::list<CompositeWindow *> &window_list);
     std::string name_;
     Program program_;
     std::string vertex_shader_;