Get the left-most quad appear to the right when dissappearing to the left

Hello!

The method called from the display list draws some quads in a horizontal line. You can make the quads going left or right by pressing the arrow keys, then the X_POS variable is changing. When you press left or right many times, the quads will finally disappear from the view.

gl.glTranslatef(X_POS, 0.0f, -6.0f);
gl.glCallList(quad);        

I would like to make the left-most quad appear on the right side when it dissappears to the left, and the right-most quad appear to the left when it dissappears to the right, so that the quads never disappear from the view even if I press the left left key for a month. :slight_smile:

How can I achieve this?

Basically you’re interested in the range on the x-axis that is valid.

if x is left of this range, remove the quad from the left, add it to the right
if x is right of this range, remove the quad from the right, add it to the left

add some margin, so that [the quad that just went out of view on one side, gets relocated, and is out of view on the other side], it not moved around again.

For samplecode in javascript (… I know …) look at the sourcecode:
http://www.kewloxfotokasten.nl/
It renders those 4 images at the bottom in this infinite ‘slider’.

Ok, now I am moving all the quads with glTranslatef(), that means every quad is moving. Do I have to use one glTranslatef() for each quad?

Yes, since they all will have independent translations.

No need. You know that the space between the quads is constant, so you can use 1 glTranslate call, you just have to be very sure which value you pass, and what vertex data you pass to the GPU.

My goal is to make the space between the quads constant. The only place where it is not constant is between the left-most and the right-most quads. And that is what I am wondering of how to do. I cannot see how I can solve it with only one glTransate (well, I still don´t see how I can solve it with multiple glTranslates either)?