diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 32: Add "MaterialTexture0" uniform.

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

Commit Message

Alexandros Frantzis July 21, 2011, 12:36 p.m. UTC
------------------------------------------------------------
revno: 32
committer: Alexandros Frantzis <alf82@freemail.gr>
timestamp: Fri 2010-07-09 16:34:12 +0300
message:
  Add "MaterialTexture0" uniform.
  Rename "texture" vertex attribute to "texcoord".
modified:
  data/shaders/light-advanced.vert
  data/shaders/light-basic.frag
  data/shaders/light-basic.vert
  shader.cpp
  shader.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 'data/shaders/light-advanced.vert'
--- data/shaders/light-advanced.vert	2010-07-09 09:48:40 +0000
+++ data/shaders/light-advanced.vert	2010-07-09 13:34:12 +0000
@@ -1,6 +1,5 @@ 
 attribute vec3 position;
 attribute vec3 normal;
-attribute vec2 texture;
 
 uniform mat4 ModelViewProjectionMatrix;
 uniform mat4 NormalMatrix;

=== modified file 'data/shaders/light-basic.frag'
--- data/shaders/light-basic.frag	2010-07-08 15:48:22 +0000
+++ data/shaders/light-basic.frag	2010-07-09 13:34:12 +0000
@@ -1,4 +1,5 @@ 
 varying vec4 Color;
+varying vec2 TextureCoord;
 
 void main(void)
 {

=== modified file 'data/shaders/light-basic.vert'
--- data/shaders/light-basic.vert	2010-07-09 10:28:57 +0000
+++ data/shaders/light-basic.vert	2010-07-09 13:34:12 +0000
@@ -1,6 +1,6 @@ 
 attribute vec3 position;
 attribute vec3 normal;
-attribute vec2 texture;
+attribute vec2 texcoord;
 
 uniform mat4 ModelViewProjectionMatrix;
 uniform mat4 NormalMatrix;
@@ -8,6 +8,7 @@ 
 uniform vec3 MaterialColor;
 
 varying vec4 Color;
+varying vec2 TextureCoord;
 
 void main(void)
 {
@@ -22,6 +23,9 @@ 
     float diffuse = max(dot(N, L), 0.0);
     Color = diffuse * vec4(MaterialColor, 1.0);
 
+    // Set the texture coordinates as a varying
+    TextureCoord = texcoord;
+
     // Transform the position to clip coordinates
     gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
 }

=== modified file 'shader.cpp'
--- shader.cpp	2010-07-09 11:16:34 +0000
+++ shader.cpp	2010-07-09 13:34:12 +0000
@@ -66,7 +66,7 @@ 
     glAttachObjectARB(mShaderProgram, mVertexShader);
     glBindAttribLocation(mShaderProgram, VertexAttribLocation, "position");
     glBindAttribLocation(mShaderProgram, NormalAttribLocation, "normal");
-    glBindAttribLocation(mShaderProgram, TexCoordAttribLocation, "texture");
+    glBindAttribLocation(mShaderProgram, TexCoordAttribLocation, "texcoord");
 
     glLinkProgram(mShaderProgram);
     glGetShaderInfoLog(mShaderProgram, sizeof msg, NULL, msg);
@@ -97,9 +97,12 @@ 
             "MaterialSpecular");
     mLocations.MaterialColor = glGetUniformLocation(mShaderProgram,
             "MaterialColor");
+    mLocations.MaterialTexture0 = glGetUniformLocation(mShaderProgram,
+            "MaterialTexture0");
+    glUniform1i(mLocations.MaterialTexture0, 0);
 
 #ifdef _DEBUG
-    printf("Uniform Locations: %d %d %d %d %d %d %d %d %d %d %d\n",
+    printf("Uniform Locations: %d %d %d %d %d %d %d %d %d %d %d %d\n",
             mLocations.ModelViewProjectionMatrix,
             mLocations.NormalMatrix,
             mLocations.LightSourcePosition,
@@ -110,7 +113,8 @@ 
             mLocations.MaterialAmbient,
             mLocations.MaterialDiffuse,
             mLocations.MaterialSpecular,
-            mLocations.MaterialColor);
+            mLocations.MaterialColor,
+            mLocations.MaterialTexture);
 #endif
 
 }

=== modified file 'shader.h'
--- shader.h	2010-07-09 11:16:34 +0000
+++ shader.h	2010-07-09 13:34:12 +0000
@@ -31,6 +31,7 @@ 
         GLint MaterialDiffuse;
         GLint MaterialSpecular;
         GLint MaterialColor;
+        GLint MaterialTexture0;
     } mLocations;
 
     enum {