=== modified file 'data/shaders/light-advanced.vert'
@@ -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'
@@ -1,4 +1,5 @@
varying vec4 Color;
+varying vec2 TextureCoord;
void main(void)
{
=== modified file 'data/shaders/light-basic.vert'
@@ -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'
@@ -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'
@@ -31,6 +31,7 @@
GLint MaterialDiffuse;
GLint MaterialSpecular;
GLint MaterialColor;
+ GLint MaterialTexture0;
} mLocations;
enum {