I'm completely new to OpenGL and am having trouble sorting out how binding textures and shaders to VBOs works.
I'm using Cinder's texture and shader classes. Here's part of my draw method:
mShader.bind();
myImage.bind();
glPushMatrix();
glTranslated( scaledX, scaledY, scaledZ);
gl::draw(sphere.getVBO());
glPopMatrix();
glPushMatrix();
glTranslated( 0, 0, zshift - 200);
mDisc.draw();
glPopMatrix();
In the above code if I comment out the call to mShader.bind(), my sphere VBO will display the texture (myImage). My shader works fine for plain (untextured) shapes, but when I bind the shader before drawing any shapes with wrapped textures it blocks the textures from being displayed.
Is this a problem with the shader I'm using, or is it something else that I'm not understanding? (...there is still a lot I'm not understanding)
Thanks
edit:
here are the shaders I'm using:
(frag):
uniform sampler2DShadow depthTexture;
varying vec3 N, V, L;
varying vec4 q;
void main(void)
{
vec3 normal = normalize( N );
vec3 R = -normalize( reflect( L, normal ) );
vec4 ambient = gl_FrontLightProduct[0].ambient;
vec4 diffuse = gl_FrontLightProduct[0].diffuse * max(dot( normal, L), 0.0);
vec4 specular = gl_FrontLightProduct[0].specular * pow(max(dot(R, V), 0.0), gl_FrontMaterial.shininess);
vec3 coord = 0.5 * (q.xyz / q.w + 1.0);
float shadow = shadow2D( depthTexture, coord ).r;
gl_FragColor = ((ambient + (0.2 + 0.8 * shadow) * diffuse) + specular * shadow);
}
(vert):
varying vec3 N, V, L;
varying vec4 q;
uniform mat4 shadowTransMatrix;
void main(void)
{
vec4 eyeCoord = gl_ModelViewMatrix * gl_Vertex;
V = normalize( -eyeCoord.xyz );
L = normalize( gl_LightSource[0].position.xyz - eyeCoord.xyz );
N = gl_NormalMatrix * gl_Normal;
q = shadowTransMatrix * eyeCoord;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}