Well, I'm trying to create water. I want to simulate a wave by moving the texture coordinates of a quad by some amount. Thus the lookup to the noise texture will be displace for which I will use that displacement in my projected texture lookup. I have everything working except the noise texture lookup.
The Main Function
// ....
// Reflection stuff above
SHADERS.SetCurrentShader( GRAPHICS::GLSLShaderManager::ST_WATER );
SHADERS.SetUniformSampler( GRAPHICS::GLSLShaderManager::ST_WATER, "noise", 1);
SHADERS.SetUniformSampler( GRAPHICS::GLSLShaderManager::ST_WATER, "reflection", 0);
Enable2DTexture( 1, GetTexture("noise.bmp") );
Enable2DTexture( 0, BlankTexID );
// Using these 2 calls below slow the framerate down to 1 Frame / 5 secs
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
SetupWaterTextureMatrix( 1 );
DrawTexturedFloorQuad2();
All Helper Functions below
void SetupWaterTextureMatrix( unsigned active_texture )
{
glMatrixMode( GL_TEXTURE );
glActiveTexture(GL_TEXTURE0 + active_texture );
glEnable(GL_TEXTURE_2D);
glLoadIdentity();
glTranslatef (0.5, 0.5, 0.5);
glScalef (0.5, 0.5, 0.5);
glMultMatrixf(current_camera->GetProjection());
glMultMatrixf(current_camera->GetCameraMatrix());
}
I think the problem may have to either do with the Texture Coordinates, but I am not sure
void DrawTexturedFloorQuad2(void)
{
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glLoadMatrixf( current_camera->GetCameraMatrix() );
static float time = 0.0f;
time += 0.001f;
glBegin( GL_QUADS );
glTexCoord2f(0.0f + time, 0.0f);
glVertex3f( -100.0f,0.0f, 100.0f );
glTexCoord2f(0.0f+ time, 1.0f);
glVertex3f( -100.0f, 0.0f, -100.0f );
glTexCoord2f(1.0f+ time, 1.0f);
glVertex3f( 100.0f, 0.0f, -100.0f );
glTexCoord2f(1.0f+ time, 0.0f);
glVertex3f( 100.0f, 0.0f, 100.0f );
glEnd();
}
void Enable2DTexture( unsigned active_texture, unsigned oGL_id)
{
glActiveTexture( GL_TEXTURE0 + active_texture );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, oGL_id );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // far from camera
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // close to camera
}