diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 98: Add Scene::load_shaders_from_strings() helper method.

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

Commit Message

alexandros.frantzis@linaro.org July 21, 2011, 12:36 p.m. UTC
------------------------------------------------------------
revno: 98
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
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
diff mbox

Patch

=== 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<GLint> 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<GLint> 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();