I know I have done something wrong, obviously. Anyway I have wrote some code to try and get my textures to animate and not really sure what's gone wrong or what I have done wrong.
here is the code that loads in my textures:
if(PVRTTextureLoadFromPVR(c_szTextureFile, &m_uiTexture[0]) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot load the texture\n");
return false;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//This loads in the second texture
if(PVRTTextureLoadFromPVR(c_szTextureFile2, &m_uiTexture[1]) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot load the texture2\n");
return false;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
and here is my timer function that attempts to update the texture coordinates
int time_Loc = glGetUniformLocation(m_ShaderProgram.uiId, "Time"); //This stores the location of the uniform
float updateTexture;
float timeElapsed = difftime(time(NULL), Timer) * 1000;
if(timeElapsed > 16.0f)
{
glUniform1f(time_Loc, updateTexture++); // passes the updated value to shader
}
and here is my shader that I am passing the data to
uniform sampler2D sTexture;
uniform sampler2D sTexture2;
varying mediump vec2 TexCoord; varying mediump vec2 TexCoord2;
//This gets updated within the main code
uniform highp float Time;
void main()
{
mediump vec4 tex1 = texture2D(sTexture, TexCoord + Time);
mediump vec4 tex2 = texture2D(sTexture2, TexCoord2 + Time);
gl_FragColor = tex2 * tex1;
}
gl_FragColor = tex2 * tex1;
and why not this?gl_FragColor = 0.5*tex2 + 0.5*tex1;
– DanPuniform int u_mode;
thenif(u_mode==0) gl_FragColor = tex1; else gl_FragColor = tex2;
? – DanP