From patchwork Thu Jul 21 12:36:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 2930 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A8CC323F4D for ; Thu, 21 Jul 2011 12:41:54 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 77523A1822A for ; Thu, 21 Jul 2011 12:41:54 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so853237qwb.11 for ; Thu, 21 Jul 2011 05:41:54 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr189980qci.114.1311252113312; Thu, 21 Jul 2011 05:41:53 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs139465qcb; Thu, 21 Jul 2011 05:41:53 -0700 (PDT) Received: by 10.216.81.5 with SMTP id l5mr780958wee.102.1311251798376; Thu, 21 Jul 2011 05:36:38 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id k62si2373445weq.120.2011.07.21.05.36.37; Thu, 21 Jul 2011 05:36:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QjsUX-0000sC-Jd for ; Thu, 21 Jul 2011 12:36:37 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 8CF6C2E84FB for ; Thu, 21 Jul 2011 12:36:37 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 102 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 102: Refactor SceneConditionals to derive from SceneGrid base class. Message-Id: <20110721123637.17019.84891.launchpad@loganberry.canonical.com> Date: Thu, 21 Jul 2011 12:36:37 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13475"; Instance="initZopeless config overlay" X-Launchpad-Hash: d2bd54d6e9448f043052e4f0b02a04a1b12b13ec ------------------------------------------------------------ revno: 102 committer: Alexandros Frantzis timestamp: Thu 2011-07-07 16:45:19 +0300 message: Refactor SceneConditionals to derive from SceneGrid base class. modified: src/scene-conditionals.cpp src/scene.h --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/scene-conditionals.cpp' --- src/scene-conditionals.cpp 2011-07-05 16:18:56 +0000 +++ src/scene-conditionals.cpp 2011-07-07 13:45:19 +0000 @@ -41,7 +41,7 @@ static const std::string frg_file_epilogue(shader_file_base + "epilogue.frag"); SceneConditionals::SceneConditionals(Canvas &pCanvas) : - Scene(pCanvas, "conditionals") + SceneGrid(pCanvas, "conditionals") { mOptions["fragment-steps"] = Scene::Option("fragment-steps", "1", "The number of computational steps in the fragment shader"); @@ -51,10 +51,6 @@ "The number of computational steps in the vertex shader"); mOptions["vertex-conditionals"] = Scene::Option("vertex-conditionals", "true", "Whether each computational step includes an if-else clause"); - mOptions["grid-size"] = Scene::Option("grid-size", "32", - "The number of squares per side of the grid (controls the number of vertices)"); - mOptions["grid-length"] = Scene::Option("grid-length", "5.0", - "The length of each side of the grid (normalized) (controls the area drawn to)"); } SceneConditionals::~SceneConditionals() @@ -115,29 +111,15 @@ return ss.str(); } -int SceneConditionals::load() -{ - mRotationSpeed = 36.0f; - mRunning = false; - - return 1; -} - -void SceneConditionals::unload() -{ -} - void SceneConditionals::setup() { - Scene::setup(); + SceneGrid::setup(); /* Parse options */ bool vtx_conditionals = mOptions["vertex-conditionals"].value == "true"; bool frg_conditionals = mOptions["fragment-conditionals"].value == "true"; int vtx_steps = 0; int frg_steps = 0; - int grid_size = 0; - double grid_length = 0; std::stringstream ss; @@ -146,12 +128,6 @@ ss.clear(); ss << mOptions["fragment-steps"].value; ss >> frg_steps; - ss.clear(); - ss << mOptions["grid-size"].value; - ss >> grid_size; - ss.clear(); - ss << mOptions["grid-length"].value; - ss >> grid_length; /* Load shaders */ std::string vtx_shader(get_vertex_shader_source(vtx_steps, vtx_conditionals)); @@ -162,76 +138,11 @@ mProgram.start(); - /* Create and configure the grid mesh */ - std::vector vertex_format; - vertex_format.push_back(3); - mMesh.set_vertex_format(vertex_format); - - /* - * The spacing needed in order for the area of the requested grid - * to be the same as the area of a grid with size 32 and spacing 0.02. - */ - double spacing = grid_length * (1 - 4.38 / 5.0) / (grid_size - 1.0); - - mMesh.make_grid(grid_size, grid_size, grid_length, grid_length, - grid_size > 1 ? spacing : 0); - mMesh.build_vbo(); - std::vector attrib_locations; attrib_locations.push_back(mProgram.getAttribIndex("position")); mMesh.set_attrib_locations(attrib_locations); - mCurrentFrame = 0; - mRotation = 0.0f; mRunning = true; mStartTime = Scene::get_timestamp_us() / 1000000.0; mLastUpdateTime = mStartTime; } - -void SceneConditionals::teardown() -{ - mProgram.stop(); - mProgram.release(); - mMesh.reset(); - - Scene::teardown(); -} - -void SceneConditionals::update() -{ - double current_time = Scene::get_timestamp_us() / 1000000.0; - double dt = current_time - mLastUpdateTime; - double elapsed_time = current_time - mStartTime; - - mLastUpdateTime = current_time; - - if (elapsed_time >= mDuration) { - mAverageFPS = mCurrentFrame / elapsed_time; - mRunning = false; - } - - mRotation += mRotationSpeed * dt; - - mCurrentFrame++; -} - -void SceneConditionals::draw() -{ - // Load the ModelViewProjectionMatrix uniform in the shader - LibMatrix::Stack4 model_view; - LibMatrix::mat4 model_view_proj(mCanvas.projection()); - - model_view.translate(0.0f, 0.0f, -5.0f); - model_view.rotate(mRotation, 0.0f, 0.0f, 1.0f); - model_view_proj *= model_view.getCurrent(); - - mProgram.loadUniformMatrix(model_view_proj, "ModelViewProjectionMatrix"); - - mMesh.render_vbo(); -} - -Scene::ValidationResult -SceneConditionals::validate() -{ - return Scene::ValidationUnknown; -} === modified file 'src/scene.h' --- src/scene.h 2011-07-07 13:35:24 +0000 +++ src/scene.h 2011-07-07 13:45:19 +0000 @@ -227,26 +227,13 @@ float mRotationSpeed; }; -class SceneConditionals : public Scene +class SceneConditionals : public SceneGrid { public: SceneConditionals(Canvas &pCanvas); - int load(); - void unload(); void setup(); - void teardown(); - void update(); - void draw(); - ValidationResult validate(); ~SceneConditionals(); - -protected: - Program mProgram; - - Mesh mMesh; - float mRotation; - float mRotationSpeed; }; class SceneFunction : public SceneGrid