I am following "Interactive Computer Graphics" by Ed Angel, specifically the code for rotating cube with texture. The vertex shader for this (as in the book) is as follows:
#version 150
in vec4 vPosition;
in vec4 vColor;
in vec2 vTexCoord;
out vec4 color;
out vec2 texCoord;
uniform vec3 theta;
void main()
{
........
........
// code for rotation
........
color = vColor;
texCoord = vTexCoord;
gl_Position = rz * ry * rx * vPosition;
}
And the fragment shader code is:
#version 150
in vec4 color;
in vec2 texCoord;
out vec4 fColor;
uniform sampler2D texture;
void main()
{
fColor = color * texture2D( texture, texCoord );
}
[The link for the complete code is here. Just look at the code for example 8
.
I am trying to implement this using #version 440 core
. When I run this, I get only a black cube. The texture is not shown.
What change to the above code should I make to display the texture correctly?