=== modified file 'src/scene-build.cpp'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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();