....
>
> If someone has a hint - thanks very much for helping!
First lets make a few measurements. I placed a sequence around your
picture control terminal, added a frame before and another after the
terminal. In each of these, add a Tick Count function. Outside the
sequence, you can subtract and display the time spent redrawing the
picture control. On my computer I see about 50ms being spent drawing
the picture and around 1ms being spent computing the points and calling
the drawing functions.
This means that each loop iteration takes about 50ms, which makes 20Hz
while my monitor updates at more like 80 Hz. That means that while the
picture control is updating one time, the screen updates about four
times. With smooth updates turned on, the new image is prepared in a
bitmap and the bitmap is drawn in one command straight to the screen.
Unfortunately, this one update command is what is taking the 50ms. This
means that the monitor will show four partial updates and the human
eye sees it as the jagged edge on the rectangles.
With the Smooth updates turned off, the screen only takes about 5ms to
update. This means that the picture control updates about 2.5 times
each time the monitor redraws. This allows the boxes to jump around
more than you probably intended, not moving very smoothly.
Additionally, you still get aliasing because now the picture is all
drawn to the screen. That means it is erased, then one rectangle is
drawn, then the other. If some of the monitor updates catch the picture
control when it is erased without rectangles drawn, then this will cause
lots of flashing between the background and the rectangle color. You
can slow the updates down by placing a delay in the loop. Putting about
a 12ms delay really smooths it out, but you will see the flashing moving
more slowly with the edges looking really smooth. If we could
completely synchronize the picture draw with the monitor draw, it would
get rid of the rest of the flicker and look great, but I'm afraid that I
don't know of a way to do this without resorting to gaming
APIs like DirectDraw. It might be worth your time to look at DirectDraw
and see if this is possible.
Another approach is to use the Smooth Updates, but try to improve the
speed to get closer to 12ms or the time for a monitor update. This will
still allow the edge to be a bit jagged, but much less than when it is
as far out of synch as when it started. One thing that you might try is
to change your monitor depth. Moving from True color to thousands of
colors will likely speed up the picture control. It all depends on the
video driver and the video card. On my computer it sped up to 25ms.
Getting pretty close.
To speed it up a bit more, I turned off the Erase First option, then
erase the rectangles myself by redrawing them with the background color.
To do this, I drop two additional Draw Multiple Lines VIs, wire up the
color to match the background of the picture control. To copy the color
more accurately, you can use the eye dropper tool to copy the color from
the picture control and paste it into a color numeric. Next, wire the
computed points into the VIs, send the picture into the right side of a
shift register. Wire the left shift register into the existing Draw
Multi VIs. This will take the rectangle from the previous iteration and
redraw with the background color, then draw the new rectangles in the
new location. This sped my updates up to about 18ms. It looks pretty
good on the screen.
I could probably speed it up a bit more by recognizing that we are
drawing most of the rectangle area twice and erasing just the trailing
edge and drawing the leading edge. Unfortunately this will not gain me
more than about 1ms. This is easy to test by shrinking the rectangle
size using the slider at the bottom of the page.
It probably isn't hard to find a computer video card faster than mine.
Add the timing code and see if you can get the update speed pretty close
to the monitor refresh rate. There may still be a little aliasing, but
it will be much less noticable.
One final way to affect the update rate is to adjust the size of the
picture control. The update speed is directly proportional to the
number of pixels to redraw. When using Smooth Updates, this is the size
of the control. I know that you want this to be large, but you might be
able to change the monitor resolution and make the picture control
smaller and gain lots of speed that way as well.
Long winded, but I hope this will help. If you have further questions,
fire away.
Greg McKaskle