PDA

View Full Version : moving Pattern



01-18-2006, 11:52 PM
Hi guys, I'am programming an animation in which an oblique lines pattern, scroll on the screen left to right. The pattern should just be visible in a window in the centre of the screen like it was scrolling behind a layer with an aperture in the middle.
The program must have two chracteristic:
1) the animation has to be extremely fluid
2) I need to change some parameters of the patter (like number of line, color etc..) directly from the keyboard while the program is running (even if not necessarly while the animation is running).
I basically see two major way of programming such an animation:
!) create a static pattern and translate it left to right
!!) create at every frame a brand new pattern that just exists in the visible part of the screen (that is within the window)
Unfortunately the first solution would require a very large pattern because the pattern is not going to be omogeneous. On the other hand the second one is computationally more expensive and more difficult to program.
I would like to know what is the best thing to do in your opinion.
Thanks a lot!

dmy
01-20-2006, 06:32 AM
if the pattern repeats, then i would use a texture, then render a quad with this texture.
then, before scrolling the texture (using the texture matrix makes it easy) i draw only those pixels wich are entering the view space of the quad.

this saves zillions of calculations... unless you change your "pattern parameters" too often.