Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

pauljg

Moving Textures in Realtime

This topic is 6111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''ve currently loaded a texture of water onto a flat surface, but I''d like to wrapscroll the texture - giving the impression of moving water. Any ideas how I should go about it ?. I''m using SDL if it makes a difference. Thanks for your time - Paul.

Share this post


Link to post
Share on other sites
Advertisement
set the clamping mode to GL_REPEAT and translate the texture matrix so that you get something like that:

glMatrixMode(GL_TEXTURE);

glTranslatef(x_offset, y_offset, 0);
glMatrixMode(GL_MODELVIEW);

Regards,
-Lev

Share this post


Link to post
Share on other sites
Thanks for your advice, but I''m alittle confused where I put those lines. Here''s the display section of my program..

glPushMatrix ( );
glBindTexture ( GL_TEXTURE_2D, spriteinfo[spriteid].textureidinfo );
glTranslatef(xp,yp,0);
glRotatef( rx, 1.0, 0.0, 0.0 );
glRotatef( ry, 0.0, 1.0, 0.0 );
glRotatef( rz, 0.0, 0.0, 1.0 );
float sax=spriteinfo[spriteid].spritex*sx;
float say=spriteinfo[spriteid].spritey*sy;
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f( -sax, say);
glTexCoord2f(0,1);
glVertex2f(-sax, -say);
glTexCoord2f(1,1);
glVertex2f(sax,-say);
glTexCoord2f(1,0);
glVertex2f( sax,say);
glEnd();
glPopMatrix ( );
}

Share this post


Link to post
Share on other sites
You must put this calls somewhere before rendering the object with the texture which you want to move. escacially before glTexCoord* calls, because the texture matrix is applied to the coordinates you specify.

Regards,
-Lev

Share this post


Link to post
Share on other sites
Do I need to push the main modelview matrix on the stack BEFORE I start playing with the TEXTURE stack ? - or doesnt it affect it.

Share this post


Link to post
Share on other sites
quote:
Original post by pauljg
Do I need to push the main modelview matrix on the stack BEFORE I start playing with the TEXTURE stack ? - or doesnt it affect it.


No. The MODELVIEW, PROJECTION and TEXTURE stack are all independant. You do not ned to save the MODELVIEW to modify the TEXTURE stack.

However you might need to use glLoadIdentity() after glMatrixMode(GL_TEXTURE); to stop any adverse matrix multiplication effects from the translate from the previous frame.. ( i think? )

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!