← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1397500 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1397500 into lp:widelands.

Commit message:
Moved GL shaders into external files. Fragment shaders now live in "data/shaders/<program_name>.fp" and vertex shaders in "data/shaders/<program_name>.vp".

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1397500 in widelands: ""warning: unterminated string literal" in utils/buildcat.py. + Discussion on directory structure"
  https://bugs.launchpad.net/widelands/+bug/1397500

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1397500/+merge/284574

Now to the original purpose of this bug: moved the GL shaders into text files.

The warning message in utils/buildcat.py is now gone.

-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1397500 into lp:widelands.
=== added directory 'data/shaders'
=== added file 'data/shaders/blit.fp'
--- data/shaders/blit.fp	1970-01-01 00:00:00 +0000
+++ data/shaders/blit.fp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,28 @@
+#version 120
+
+uniform sampler2D u_texture;
+uniform sampler2D u_mask;
+
+varying vec2 out_mask_texture_coordinate;
+varying vec2 out_texture_coordinate;
+varying vec4 out_blend;
+varying float out_program_flavor;
+
+void main() {
+	vec4 texture_color = texture2D(u_texture, out_texture_coordinate);
+
+	// See http://en.wikipedia.org/wiki/YUV.
+	float luminance = dot(vec3(0.299, 0.587, 0.114), texture_color.rgb);
+
+	if (out_program_flavor == 0.) {
+		gl_FragColor = vec4(texture_color.rgb, out_blend.a * texture_color.a);
+	} else if (out_program_flavor == 1.) {
+		gl_FragColor = vec4(vec3(luminance) * out_blend.rgb, out_blend.a * texture_color.a);
+	} else {
+		vec4 mask_color = texture2D(u_mask, out_mask_texture_coordinate);
+		float blend_influence = mask_color.r * mask_color.a;
+		gl_FragColor = vec4(
+			mix(texture_color.rgb, out_blend.rgb * luminance, blend_influence),
+				out_blend.a * texture_color.a);
+	}
+}

=== added file 'data/shaders/blit.vp'
--- data/shaders/blit.vp	1970-01-01 00:00:00 +0000
+++ data/shaders/blit.vp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,21 @@
+#version 120
+
+// Attributes.
+attribute vec2 attr_mask_texture_position;
+attribute vec2 attr_texture_position;
+attribute vec3 attr_position;
+attribute vec4 attr_blend;
+attribute float attr_program_flavor;
+
+varying vec2 out_mask_texture_coordinate;
+varying vec2 out_texture_coordinate;
+varying vec4 out_blend;
+varying float out_program_flavor;
+
+void main() {
+	out_mask_texture_coordinate = attr_mask_texture_position;
+	out_texture_coordinate = attr_texture_position;
+	out_blend = attr_blend;
+	out_program_flavor = attr_program_flavor;
+	gl_Position = vec4(attr_position, 1.);
+}

=== added file 'data/shaders/dither.fp'
--- data/shaders/dither.fp	1970-01-01 00:00:00 +0000
+++ data/shaders/dither.fp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,24 @@
+#version 120
+
+uniform sampler2D u_dither_texture;
+uniform sampler2D u_terrain_texture;
+uniform vec2 u_texture_dimensions;
+
+varying float var_brightness;
+varying vec2 var_dither_texture_position;
+varying vec2 var_texture_position;
+varying vec2 var_texture_offset;
+
+// TODO(sirver): This is a hack to make sure we are sampling inside of the
+// terrain texture. This is a common problem with OpenGL and texture atlases.
+#define MARGIN 1e-2
+
+void main() {
+	vec2 texture_fract = clamp(
+			fract(var_texture_position),
+			vec2(MARGIN, MARGIN),
+			vec2(1. - MARGIN, 1. - MARGIN));
+	vec4 clr = texture2D(u_terrain_texture, var_texture_offset + u_texture_dimensions * texture_fract);
+	gl_FragColor = vec4(clr.rgb * var_brightness,
+			1. - texture2D(u_dither_texture, var_dither_texture_position).a);
+}

=== added file 'data/shaders/dither.vp'
--- data/shaders/dither.vp	1970-01-01 00:00:00 +0000
+++ data/shaders/dither.vp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,24 @@
+#version 120
+
+// Attributes.
+attribute float attr_brightness;
+attribute vec2 attr_dither_texture_position;
+attribute vec2 attr_position;
+attribute vec2 attr_texture_offset;
+attribute vec2 attr_texture_position;
+
+uniform float u_z_value;
+
+// Output of vertex shader.
+varying float var_brightness;
+varying vec2 var_dither_texture_position;
+varying vec2 var_texture_offset;
+varying vec2 var_texture_position;
+
+void main() {
+	var_brightness = attr_brightness;
+	var_dither_texture_position = attr_dither_texture_position;
+	var_texture_offset = attr_texture_offset;
+	var_texture_position = attr_texture_position;
+	gl_Position = vec4(attr_position, u_z_value, 1.);
+}

=== added file 'data/shaders/draw_line.fp'
--- data/shaders/draw_line.fp	1970-01-01 00:00:00 +0000
+++ data/shaders/draw_line.fp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,7 @@
+#version 120
+
+varying vec3 var_color;
+
+void main() {
+	gl_FragColor = vec4(var_color.rgb, 1.);
+}

=== added file 'data/shaders/draw_line.vp'
--- data/shaders/draw_line.vp	1970-01-01 00:00:00 +0000
+++ data/shaders/draw_line.vp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,12 @@
+#version 120
+
+// Attributes.
+attribute vec3 attr_position;
+attribute vec3 attr_color;
+
+varying vec3 var_color;
+
+void main() {
+	var_color = attr_color;
+	gl_Position = vec4(attr_position, 1.);
+}

=== added file 'data/shaders/fill_rect.fp'
--- data/shaders/fill_rect.fp	1970-01-01 00:00:00 +0000
+++ data/shaders/fill_rect.fp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,7 @@
+#version 120
+
+varying vec4 var_color;
+
+void main() {
+	gl_FragColor = var_color;
+}

=== added file 'data/shaders/fill_rect.vp'
--- data/shaders/fill_rect.vp	1970-01-01 00:00:00 +0000
+++ data/shaders/fill_rect.vp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,12 @@
+#version 120
+
+// Attributes.
+attribute vec3 attr_position;
+attribute vec4 attr_color;
+
+varying vec4 var_color;
+
+void main() {
+	var_color = attr_color;
+	gl_Position = vec4(attr_position, 1.);
+}

=== added file 'data/shaders/road.fp'
--- data/shaders/road.fp	1970-01-01 00:00:00 +0000
+++ data/shaders/road.fp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,13 @@
+#version 120
+
+// Inputs.
+varying vec2 out_texture_position;
+varying float out_brightness;
+
+uniform sampler2D u_texture;
+
+void main() {
+	vec4 color = texture2D(u_texture, out_texture_position);
+	color.rgb *= out_brightness;
+	gl_FragColor = color;
+}

=== added file 'data/shaders/road.vp'
--- data/shaders/road.vp	1970-01-01 00:00:00 +0000
+++ data/shaders/road.vp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,18 @@
+#version 120
+
+// Attributes.
+attribute vec2 attr_position;
+attribute vec2 attr_texture_position;
+attribute float attr_brightness;
+
+uniform float u_z_value;
+
+// Outputs.
+varying vec2 out_texture_position;
+varying float out_brightness;
+
+void main() {
+	out_texture_position = attr_texture_position;
+	out_brightness = attr_brightness;
+	gl_Position = vec4(attr_position, u_z_value, 1.);
+}

=== added file 'data/shaders/terrain.fp'
--- data/shaders/terrain.fp	1970-01-01 00:00:00 +0000
+++ data/shaders/terrain.fp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,26 @@
+#version 120
+
+uniform sampler2D u_terrain_texture;
+uniform vec2 u_texture_dimensions;
+
+varying float var_brightness;
+varying vec2 var_texture_position;
+varying vec2 var_texture_offset;
+
+// TODO(sirver): This is a hack to make sure we are sampling inside of the
+// terrain texture. This is a common problem with OpenGL and texture atlases.
+#define MARGIN 1e-2
+
+void main() {
+	// The arbitrary multiplication by 0.99 makes sure that we never sample
+	// outside of the texture in the texture atlas - this means non-perfect
+	// pixel mapping of textures to the screen, but we are pretty meh about that
+	// here.
+	vec2 texture_fract = clamp(
+			fract(var_texture_position),
+			vec2(MARGIN, MARGIN),
+			vec2(1. - MARGIN, 1. - MARGIN));
+	vec4 clr = texture2D(u_terrain_texture, var_texture_offset + u_texture_dimensions * texture_fract);
+	clr.rgb *= var_brightness;
+	gl_FragColor = clr;
+}

=== added file 'data/shaders/terrain.vp'
--- data/shaders/terrain.vp	1970-01-01 00:00:00 +0000
+++ data/shaders/terrain.vp	2016-02-01 10:27:59 +0000
@@ -0,0 +1,21 @@
+#version 120
+
+// Attributes.
+attribute float attr_brightness;
+attribute vec2 attr_position;
+attribute vec2 attr_texture_offset;
+attribute vec2 attr_texture_position;
+
+uniform float u_z_value;
+
+// Output of vertex shader.
+varying float var_brightness;
+varying vec2 var_texture_offset;
+varying vec2 var_texture_position;
+
+void main() {
+	var_texture_position = attr_texture_position;
+	var_brightness = attr_brightness;
+	var_texture_offset = attr_texture_offset;
+	gl_Position = vec4(attr_position, u_z_value, 1.);
+}

=== modified file 'src/graphic/gl/blit_program.cc'
--- src/graphic/gl/blit_program.cc	2016-01-10 11:48:47 +0000
+++ src/graphic/gl/blit_program.cc	2016-02-01 10:27:59 +0000
@@ -29,61 +29,6 @@
 
 namespace  {
 
-const char kBlitVertexShader[] = R"(
-#version 120
-
-// Attributes.
-attribute vec2 attr_mask_texture_position;
-attribute vec2 attr_texture_position;
-attribute vec3 attr_position;
-attribute vec4 attr_blend;
-attribute float attr_program_flavor;
-
-varying vec2 out_mask_texture_coordinate;
-varying vec2 out_texture_coordinate;
-varying vec4 out_blend;
-varying float out_program_flavor;
-
-void main() {
-	out_mask_texture_coordinate = attr_mask_texture_position;
-	out_texture_coordinate = attr_texture_position;
-	out_blend = attr_blend;
-	out_program_flavor = attr_program_flavor;
-	gl_Position = vec4(attr_position, 1.);
-}
-)";
-
-const char kBlitFragmentShader[] = R"(
-#version 120
-
-uniform sampler2D u_texture;
-uniform sampler2D u_mask;
-
-varying vec2 out_mask_texture_coordinate;
-varying vec2 out_texture_coordinate;
-varying vec4 out_blend;
-varying float out_program_flavor;
-
-void main() {
-	vec4 texture_color = texture2D(u_texture, out_texture_coordinate);
-
-	// See http://en.wikipedia.org/wiki/YUV.
-	float luminance = dot(vec3(0.299, 0.587, 0.114), texture_color.rgb);
-
-	if (out_program_flavor == 0.) {
-		gl_FragColor = vec4(texture_color.rgb, out_blend.a * texture_color.a);
-	} else if (out_program_flavor == 1.) {
-		gl_FragColor = vec4(vec3(luminance) * out_blend.rgb, out_blend.a * texture_color.a);
-	} else {
-		vec4 mask_color = texture2D(u_mask, out_mask_texture_coordinate);
-		float blend_influence = mask_color.r * mask_color.a;
-		gl_FragColor = vec4(
-			mix(texture_color.rgb, out_blend.rgb * luminance, blend_influence),
-				out_blend.a * texture_color.a);
-	}
-}
-)";
-
 // While drawing we put all draw calls into a buffer, so that we have to
 // transfer the buffer to the GPU only once, even though we might need to do
 // many glDraw* calls. This structure represents the parameters for one glDraw*
@@ -99,7 +44,7 @@
 }  // namespace
 
 BlitProgram::BlitProgram() {
-	gl_program_.build(kBlitVertexShader, kBlitFragmentShader);
+	gl_program_.build("blit");
 
 	attr_blend_ = glGetAttribLocation(gl_program_.object(), "attr_blend");
 	attr_mask_texture_position_ = glGetAttribLocation(gl_program_.object(), "attr_mask_texture_position");

=== modified file 'src/graphic/gl/dither_program.cc'
--- src/graphic/gl/dither_program.cc	2016-01-29 08:37:22 +0000
+++ src/graphic/gl/dither_program.cc	2016-02-01 10:27:59 +0000
@@ -27,66 +27,8 @@
 #include "graphic/texture.h"
 #include "io/filesystem/layered_filesystem.h"
 
-namespace  {
-
-const char kDitherVertexShader[] = R"(
-#version 120
-
-// Attributes.
-attribute float attr_brightness;
-attribute vec2 attr_dither_texture_position;
-attribute vec2 attr_position;
-attribute vec2 attr_texture_offset;
-attribute vec2 attr_texture_position;
-
-uniform float u_z_value;
-
-// Output of vertex shader.
-varying float var_brightness;
-varying vec2 var_dither_texture_position;
-varying vec2 var_texture_offset;
-varying vec2 var_texture_position;
-
-void main() {
-	var_brightness = attr_brightness;
-	var_dither_texture_position = attr_dither_texture_position;
-	var_texture_offset = attr_texture_offset;
-	var_texture_position = attr_texture_position;
-	gl_Position = vec4(attr_position, u_z_value, 1.);
-}
-)";
-
-const char kDitherFragmentShader[] = R"(
-#version 120
-
-uniform sampler2D u_dither_texture;
-uniform sampler2D u_terrain_texture;
-uniform vec2 u_texture_dimensions;
-
-varying float var_brightness;
-varying vec2 var_dither_texture_position;
-varying vec2 var_texture_position;
-varying vec2 var_texture_offset;
-
-// TODO(sirver): This is a hack to make sure we are sampling inside of the
-// terrain texture. This is a common problem with OpenGL and texture atlases.
-#define MARGIN 1e-2
-
-void main() {
-	vec2 texture_fract = clamp(
-			fract(var_texture_position),
-			vec2(MARGIN, MARGIN),
-			vec2(1. - MARGIN, 1. - MARGIN));
-	vec4 clr = texture2D(u_terrain_texture, var_texture_offset + u_texture_dimensions * texture_fract);
-	gl_FragColor = vec4(clr.rgb * var_brightness,
-			1. - texture2D(u_dither_texture, var_dither_texture_position).a);
-}
-)";
-
-}  // namespace
-
 DitherProgram::DitherProgram() {
-	gl_program_.build(kDitherVertexShader, kDitherFragmentShader);
+	gl_program_.build("dither");
 
 	attr_brightness_ = glGetAttribLocation(gl_program_.object(), "attr_brightness");
 	attr_dither_texture_position_ = glGetAttribLocation(gl_program_.object(), "attr_dither_texture_position");

=== modified file 'src/graphic/gl/draw_line_program.cc'
--- src/graphic/gl/draw_line_program.cc	2016-01-09 15:27:05 +0000
+++ src/graphic/gl/draw_line_program.cc	2016-02-01 10:27:59 +0000
@@ -27,31 +27,6 @@
 
 namespace  {
 
-const char kDrawLineVertexShader[] = R"(
-#version 120
-
-// Attributes.
-attribute vec3 attr_position;
-attribute vec3 attr_color;
-
-varying vec3 var_color;
-
-void main() {
-	var_color = attr_color;
-	gl_Position = vec4(attr_position, 1.);
-}
-)";
-
-const char kDrawLineFragmentShader[] = R"(
-#version 120
-
-varying vec3 var_color;
-
-void main() {
-	gl_FragColor = vec4(var_color.rgb, 1.);
-}
-)";
-
 struct DrawBatch {
 	int offset;
 	int count;
@@ -67,7 +42,7 @@
 }
 
 DrawLineProgram::DrawLineProgram() {
-	gl_program_.build(kDrawLineVertexShader, kDrawLineFragmentShader);
+	gl_program_.build("draw_line");
 
 	attr_position_ = glGetAttribLocation(gl_program_.object(), "attr_position");
 	attr_color_ = glGetAttribLocation(gl_program_.object(), "attr_color");

=== modified file 'src/graphic/gl/fill_rect_program.cc'
--- src/graphic/gl/fill_rect_program.cc	2016-01-17 09:55:27 +0000
+++ src/graphic/gl/fill_rect_program.cc	2016-02-01 10:27:59 +0000
@@ -24,35 +24,6 @@
 #include "base/log.h"
 #include "base/wexception.h"
 
-namespace  {
-
-const char kFillRectVertexShader[] = R"(
-#version 120
-
-// Attributes.
-attribute vec3 attr_position;
-attribute vec4 attr_color;
-
-varying vec4 var_color;
-
-void main() {
-	var_color = attr_color;
-	gl_Position = vec4(attr_position, 1.);
-}
-)";
-
-const char kFillRectFragmentShader[] = R"(
-#version 120
-
-varying vec4 var_color;
-
-void main() {
-	gl_FragColor = var_color;
-}
-)";
-
-}  // namespace
-
 // static
 FillRectProgram& FillRectProgram::instance() {
 	static FillRectProgram fill_rect_program;
@@ -60,7 +31,7 @@
 }
 
 FillRectProgram::FillRectProgram() {
-	gl_program_.build(kFillRectVertexShader, kFillRectFragmentShader);
+	gl_program_.build("fill_rect");
 
 	attr_position_ = glGetAttribLocation(gl_program_.object(), "attr_position");
 	attr_color_ = glGetAttribLocation(gl_program_.object(), "attr_color");

=== modified file 'src/graphic/gl/road_program.cc'
--- src/graphic/gl/road_program.cc	2016-01-28 05:24:34 +0000
+++ src/graphic/gl/road_program.cc	2016-02-01 10:27:59 +0000
@@ -31,50 +31,9 @@
 #include "graphic/texture.h"
 #include "logic/roadtype.h"
 
-namespace  {
-
 // We target OpenGL 2.1 for the desktop here.
-const char kRoadVertexShader[] = R"(
-#version 120
-
-// Attributes.
-attribute vec2 attr_position;
-attribute vec2 attr_texture_position;
-attribute float attr_brightness;
-
-uniform float u_z_value;
-
-// Outputs.
-varying vec2 out_texture_position;
-varying float out_brightness;
-
-void main() {
-	out_texture_position = attr_texture_position;
-	out_brightness = attr_brightness;
-	gl_Position = vec4(attr_position, u_z_value, 1.);
-}
-)";
-
-const char kRoadFragmentShader[] = R"(
-#version 120
-
-// Inputs.
-varying vec2 out_texture_position;
-varying float out_brightness;
-
-uniform sampler2D u_texture;
-
-void main() {
-	vec4 color = texture2D(u_texture, out_texture_position);
-	color.rgb *= out_brightness;
-	gl_FragColor = color;
-}
-)";
-
-}  // namespace
-
 RoadProgram::RoadProgram() {
-	gl_program_.build(kRoadVertexShader, kRoadFragmentShader);
+	gl_program_.build("road");
 
 	attr_position_ = glGetAttribLocation(gl_program_.object(), "attr_position");
 	attr_texture_position_ = glGetAttribLocation(gl_program_.object(), "attr_texture_position");

=== modified file 'src/graphic/gl/terrain_program.cc'
--- src/graphic/gl/terrain_program.cc	2016-01-16 15:22:32 +0000
+++ src/graphic/gl/terrain_program.cc	2016-02-01 10:27:59 +0000
@@ -24,72 +24,13 @@
 #include "graphic/gl/utils.h"
 #include "graphic/texture.h"
 
-namespace  {
-
-using namespace Widelands;
-
 // QuickRef:
 // http://www.cs.unh.edu/~cs770/docs/glsl-1.20-quickref.pdf
 // Full specification:
 // http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf
 // We target OpenGL 2.1 for the desktop here.
-const char kTerrainVertexShader[] = R"(
-#version 120
-
-// Attributes.
-attribute float attr_brightness;
-attribute vec2 attr_position;
-attribute vec2 attr_texture_offset;
-attribute vec2 attr_texture_position;
-
-uniform float u_z_value;
-
-// Output of vertex shader.
-varying float var_brightness;
-varying vec2 var_texture_offset;
-varying vec2 var_texture_position;
-
-void main() {
-	var_texture_position = attr_texture_position;
-	var_brightness = attr_brightness;
-	var_texture_offset = attr_texture_offset;
-	gl_Position = vec4(attr_position, u_z_value, 1.);
-}
-)";
-
-const char kTerrainFragmentShader[] = R"(
-#version 120
-
-uniform sampler2D u_terrain_texture;
-uniform vec2 u_texture_dimensions;
-
-varying float var_brightness;
-varying vec2 var_texture_position;
-varying vec2 var_texture_offset;
-
-// TODO(sirver): This is a hack to make sure we are sampling inside of the
-// terrain texture. This is a common problem with OpenGL and texture atlases.
-#define MARGIN 1e-2
-
-void main() {
-	// The arbitrary multiplication by 0.99 makes sure that we never sample
-	// outside of the texture in the texture atlas - this means non-perfect
-	// pixel mapping of textures to the screen, but we are pretty meh about that
-	// here.
-	vec2 texture_fract = clamp(
-			fract(var_texture_position),
-			vec2(MARGIN, MARGIN),
-			vec2(1. - MARGIN, 1. - MARGIN));
-	vec4 clr = texture2D(u_terrain_texture, var_texture_offset + u_texture_dimensions * texture_fract);
-	clr.rgb *= var_brightness;
-	gl_FragColor = clr;
-}
-)";
-
-}  // namespace
-
 TerrainProgram::TerrainProgram() {
-	gl_program_.build(kTerrainVertexShader, kTerrainFragmentShader);
+	gl_program_.build("terrain");
 
 	attr_brightness_ = glGetAttribLocation(gl_program_.object(), "attr_brightness");
 	attr_position_ = glGetAttribLocation(gl_program_.object(), "attr_position");
@@ -143,7 +84,7 @@
 }
 
 void TerrainProgram::draw(uint32_t gametime,
-                          const DescriptionMaintainer<TerrainDescription>& terrains,
+								  const DescriptionMaintainer<Widelands::TerrainDescription>& terrains,
                           const FieldsToDraw& fields_to_draw,
                           float z_value) {
 	// This method expects that all terrains have the same dimensions and that

=== modified file 'src/graphic/gl/utils.cc'
--- src/graphic/gl/utils.cc	2016-01-24 12:43:26 +0000
+++ src/graphic/gl/utils.cc	2016-02-01 10:27:59 +0000
@@ -24,6 +24,8 @@
 
 #include "base/log.h"
 #include "base/wexception.h"
+#include "io/fileread.h"
+#include "io/filesystem/layered_filesystem.h"
 
 namespace Gl {
 
@@ -126,13 +128,31 @@
 	}
 }
 
-void Program::build(const char* vertex_shader_source, const char* fragment_shader_source) {
+void Program::build(const std::string& program_name) {
+
+	std::string fragment_shader_source;
+	FileRead fr;
+	fr.open(*g_fs, "shaders/" + program_name + ".fp");
+	while (char* line = fr.read_line()) {
+		fragment_shader_source += line;
+		fragment_shader_source += "\n";
+	}
+	fr.close();
+
+	std::string vertex_shader_source;
+	fr.open(*g_fs, "shaders/" + program_name + ".vp");
+	while (char* line = fr.read_line()) {
+		vertex_shader_source += line;
+		vertex_shader_source += "\n";
+	}
+	fr.close();
+
 	vertex_shader_.reset(new Shader(GL_VERTEX_SHADER));
-	vertex_shader_->compile(vertex_shader_source);
+	vertex_shader_->compile(vertex_shader_source.c_str());
 	glAttachShader(program_object_, vertex_shader_->object());
 
 	fragment_shader_.reset(new Shader(GL_FRAGMENT_SHADER));
-	fragment_shader_->compile(fragment_shader_source);
+	fragment_shader_->compile(fragment_shader_source.c_str());
 	glAttachShader(program_object_, fragment_shader_->object());
 
 	glLinkProgram(program_object_);

=== modified file 'src/graphic/gl/utils.h'
--- src/graphic/gl/utils.h	2016-01-24 12:43:26 +0000
+++ src/graphic/gl/utils.h	2016-02-01 10:27:59 +0000
@@ -50,9 +50,9 @@
 		return program_object_;
 	}
 
-	// Creates and compiles 'vertex_shader_source' and 'fragment_shader_source'
-	// into shader objects. Then links them into the program.
-	void build(const char* vertex_shader_source, const char* fragment_shader_source);
+	// Creates and compiles shader objects based on the corresponding files in data/shaders,
+	// Then links them into the program.
+	void build(const std::string& program_name);
 
 private:
 	const GLuint program_object_;


Follow ups