Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want be able to move my texture in GLSL I have set my texture to wrap S and wrap T but not sure why it wont move

my fragment shader looks like this at the moment

uniform sampler2D  n_mapTex;
uniform sampler2D  n_mapTex2;

varying mediump vec2  TexCoord;
varying mediump vec2  TexCoord2;

//This gets updated within the main code
uniform mediump float vTime;

void main()
{   

    gl_FragColor =  texture2D(n_mapTex, vec2(TexCoord.x + vTime, TexCoord.y + vTime));
}

within my code I have a made a function to calculate FPS and I use the delta time of that function to pass into the fragment shader

void OGLESIntroducingPVRTools::timer(){
/*This method records to the time to start rendering a frame and hold that value
in another variable we then start to count again.  To get delta time we subtact
the current time from the previous time this will give us in milliseconds how
long it took for a frame to render.  We then divide this by 1000 this converts
it from ms per frame to FPS*/

FrameCount++;

p_Time = c_Time;
c_Time = PVRShellGetTime();

elapsed = c_Time / 1000.0f;
DT = ((float)(c_Time - p_Time)) / 1000.0f;

fCount += DT;

if(fCount >= 1.0f) //if time is over 1 second reset counters and recount
{
    FPS = FrameCount;
    FrameCount = 0;
    fCount = 0;
}

}

and in my renderscene method which updates I have this code to pass the value to the uniform within the fragment shader

glUniform1i(glGetUniformLocation(m_ShaderProgram.uiId, "vTime"), DT);
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

vTime is a float, but you're passing it as an int, since you're using glUniform1i(). Adding integer values to your texcoords has no effect.

Use glUniform1f() instead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.