hello,
i’ve got the my reflection work in fixed-function, but i met some trouble when using shader.
the reflection texture is already stored in ref_tex and set to texture0.
[Vertex]
void main(void)
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_Vertex;
}
[Fragment]
uniform sampler2D tex;
void main (void)
{
gl_FragColor= texture2DProj(tex, gl_TexCoord[0]);
}
glMatrixMode(GL_TEXTURE);
glLoadMatrixf(Mr);
glMultMatrixf(projection);
glMultMatrixf(modelview);
// here i got the texture matrix i’ve setup, right?
shader.begin();
// get location and set uniform
shader.setUniform1i(“tex”, 0);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, ref_tex);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 0);
glVertex3f(-size, 0, -size);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 0);
glVertex3f(-size, 0,?size);?
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 1);
glVertex3f( size, 0,?size);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 1);
glVertex3f( size, 0, -size);
glEnd();
shader.end();
fixed-function(use automatically generated texcoord):
http://www.cnblogs.com/images/cnblogs_com/chaz/15942/o_shot0.JPG
use shader:
http://www.cnblogs.com/images/cnblogs_com/chaz/15942/o_shot1.JPG
i dunno how this could happen.
any help would be appreciated.