Search code examples
c++openglanimationtexture-mapping

Texture to repeat and loop OpenGL


I have a simple scene I am creating, it is set on a planet and I want the appearance that the planet is spinning.

Currently I have texture mapped a quad with a star texture, then in DrawScene I translate the quad by X amount which translates the quad slowly to one side. The effect looks quite good for the level of detail I am looking for. The problem is that I cannot have an infinitely long quad with the repeated texture to give this effect, there comes a point when I will reach the end of my quad and then I will just have the background colour.

Is there a way to animate the Quad so that the repeated texture moves on the stationary quad perhaps? Or a simple way to achieve the effect I am looking for.


Solution

  • You could generate a textured cube or sphere for your star-scape and have the planet move around inside that, which would give the same effect but be able to continue infinitely.

    There is an excellent tutorial at spieleprogrammierung.net for OpenGL 3.3 and above, however you will need to translate the page (use chrome and it will do it for you) so you can read it in your own language.

    Let me know if you need more information:)