Scrolling textures? (glMatrixMode)


#1

In a recent project, I wanted to have a scrollable background with a seamless texture. I did this using OpenGL using the below:

glMatrixMode(GL_TEXTURE);

glPushMatrix();
{
glTranslatef(x, y, 0);
}
glPopMatrix();

glMatrixMode(GL_MODELVIEW);

(the above switches to the OpenGL texture mode, shifts the texture, and then switches back to Model View).

Is something like this possible in SDL2? I couldn’t find anything obvious and it seemed to me that the only way to achieve the same effect would be to either draw multiple textures, aligned side by side, or to do some maths and work out all the clipping.


#2

Okay, my solution was to simply use two for loops to handle the drawing and then clip the result (done elsewhere). It does the job and won’t add much (if any) overhead.