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: 2941 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 DC24B23F4D for ; Thu, 21 Jul 2011 12:42:16 +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 AACE6A1822A for ; Thu, 21 Jul 2011 12:42:16 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so853237qwb.11 for ; Thu, 21 Jul 2011 05:42:16 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr190345qci.114.1311252136286; Thu, 21 Jul 2011 05:42:16 -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 hl14cs139484qcb; Thu, 21 Jul 2011 05:42:16 -0700 (PDT) Received: by 10.213.7.76 with SMTP id c12mr290841ebc.79.1311251798105; 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 v79si2374251weq.122.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-0000Cf-9B 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 42E5D2E84FB 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: 98 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 98: Add Scene::load_shaders_from_strings() helper method. Message-Id: <20110721123637.17019.10744.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: e3a0919e5e281fe1efd21bfb716d2f4c75c35e77 ------------------------------------------------------------ revno: 98 committer: Alexandros Frantzis timestamp: Mon 2011-07-04 13:46:22 +0300 message: Add Scene::load_shaders_from_strings() helper method. modified: src/scene-build.cpp src/scene-shading.cpp src/scene-texture.cpp src/scene.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-build.cpp' --- src/scene-build.cpp 2011-07-01 16:56:27 +0000 +++ src/scene-build.cpp 2011-07-04 10:46:22 +0000 @@ -58,8 +58,11 @@ model.convert_to_mesh(mMesh, attribs); - if (!Scene::load_shaders(mProgram, vtx_shader_filename, frg_shader_filename)) + if (!Scene::load_shaders_from_files(mProgram, vtx_shader_filename, + frg_shader_filename)) + { return 0; + } std::vector attrib_locations; attrib_locations.push_back(mProgram.getAttribIndex("position")); === modified file 'src/scene-shading.cpp' --- src/scene-shading.cpp 2011-07-01 15:31:27 +0000 +++ src/scene-shading.cpp 2011-07-04 10:46:22 +0000 @@ -97,8 +97,11 @@ frg_shader_filename = GLMARK_DATA_PATH"/shaders/light-advanced.frag"; } - if (!Scene::load_shaders(mProgram, vtx_shader_filename, frg_shader_filename)) + if (!Scene::load_shaders_from_files(mProgram, vtx_shader_filename, + frg_shader_filename)) + { return; + } mProgram.start(); === modified file 'src/scene-texture.cpp' --- src/scene-texture.cpp 2011-07-01 14:25:12 +0000 +++ src/scene-texture.cpp 2011-07-04 10:46:22 +0000 @@ -54,8 +54,11 @@ model.convert_to_mesh(mCubeMesh); mCubeMesh.build_vbo(); - if (!Scene::load_shaders(mProgram, vtx_shader_filename, frg_shader_filename)) + if (!Scene::load_shaders_from_files(mProgram, vtx_shader_filename, + frg_shader_filename)) + { return 0; + } std::vector attrib_locations; attrib_locations.push_back(mProgram.getAttribIndex("position")); === modified file 'src/scene.cpp' --- src/scene.cpp 2011-06-30 12:39:37 +0000 +++ src/scene.cpp 2011-07-04 10:46:22 +0000 @@ -171,19 +171,12 @@ } bool -Scene::load_shaders(Program &program, - const std::string &vtx_shader_filename, - const std::string &frg_shader_filename) +Scene::load_shaders_from_strings(Program &program, + const std::string &vtx_shader, + const std::string &frg_shader, + const std::string &vtx_shader_filename, + const std::string &frg_shader_filename) { - std::string vtx_shader; - std::string frg_shader; - - if (!gotSource(vtx_shader_filename, vtx_shader)) - return false; - - if (!gotSource(frg_shader_filename, frg_shader)) - return false; - program.init(); program.addShader(GL_VERTEX_SHADER, vtx_shader); @@ -217,6 +210,26 @@ return true; } +bool +Scene::load_shaders_from_files(Program &program, + const std::string &vtx_shader_filename, + const std::string &frg_shader_filename) +{ + std::string vtx_shader; + std::string frg_shader; + + if (!gotSource(vtx_shader_filename, vtx_shader)) + return false; + + if (!gotSource(frg_shader_filename, frg_shader)) + return false; + + return Scene::load_shaders_from_strings(program, vtx_shader, frg_shader, + vtx_shader_filename, + frg_shader_filename); + +} + uint64_t Scene::get_timestamp_us() { === modified file 'src/scene.h' --- src/scene.h 2011-07-01 14:23:43 +0000 +++ src/scene.h 2011-07-04 10:46:22 +0000 @@ -93,9 +93,14 @@ virtual ValidationResult validate() { return ValidationUnknown; } - static bool load_shaders(Program &program, - const std::string &vtx_shader_filename, - const std::string &frg_shader_filename); + static bool load_shaders_from_strings(Program &program, + const std::string &vtx_shader, + const std::string &frg_shader, + const std::string &vtx_shader_filename = "None", + const std::string &frg_shader_filename = "None"); + static bool load_shaders_from_files(Program &program, + const std::string &vtx_shader_filename, + const std::string &frg_shader_filename); static uint64_t get_timestamp_us();