Changed the OpenGL part and the GLSL shaders to use UBO and
[demo] / gl_shaders / default.v.glsl
index 76aae8a..b550308 100644 (file)
@@ -1,15 +1,12 @@
 #version 450
-//#extension GL_ARB_separate_shader_objects : enable
 
-uniform mat4 mview;
-uniform mat4 mmviewproj;
-uniform mat4 mmod;
+#define        MATRIX_UNIFORMS 0
 
-varying vec3 pos;
-// varying vec3 normal;
-// varying vec3 ldir;
-varying vec2 tex_coord;
-varying vec3 world_normal;
+layout(std140, binding = MATRIX_UNIFORMS) uniform vu {
+       mat4 mview;
+       uniform mat4 mmviewproj;
+       uniform mat4 mmod;
+} m;
 
 const vec3 lpos = vec3(-10.0, 100.0, 10.0);
 
@@ -18,16 +15,17 @@ layout(location = 1) in vec3 attr_pos;
 layout(location = 2) in vec3 attr_normal;
 layout(location = 3) in vec2 attr_tex;
 
+/* varyings */
+layout(location = 4) out vec3 pos;
+layout(location = 5) out vec2 tex_coord;
+layout(location = 6) out vec3 world_normal;
+
 void main()
 {
-       gl_Position = mmviewproj * vec4(attr_pos, 1.0);
-
-       pos = (mview * vec4(attr_pos, 1.0)).xyz;
-       // ldir = (mview * vec4(lpos, 1.0)).xyz;
+       gl_Position = m.mmviewproj * vec4(attr_pos, 1.0);
 
-       // mat3 normal_matrix = mat3(mview);
-       // normal = normal_matrix * attr_normal;
+       pos = (m.mview * vec4(attr_pos, 1.0)).xyz;
        tex_coord = attr_tex;
 
-       world_normal = (mmod * vec4(attr_normal, 1.0)).xyz;
-}
\ No newline at end of file
+       world_normal = (m.mmod * vec4(attr_normal, 1.0)).xyz;
+}