Board index » delphi » Flicker-free graphics

Flicker-free graphics

I'm writing a program where I am trying to display a three dimensional
graph of two variables versus time. As the program is run, data is
collected and stored into an array. The computer then draws the most
recent ten arrays, and then collects another array, replaces the
oldest array and redraws. The effect is movement.

The problem is that the method I am using involves drawing 10 jagged
lines, replacing the oldest jagged line in memory and then redrawing.
Between redraws, the only way in which I know to clear the screen is
ClearViewPort. The result is a flash between redraws.

Can anyone suggest a more intelligent way to do this?

 

Re:Flicker-free graphics


Quote
sn...@jhu.edu (Amer Mallah) wrote:
>I'm writing a program where I am trying to display a three dimensional
>graph of two variables versus time. As the program is run, data is
>collected and stored into an array. The computer then draws the most
>recent ten arrays, and then collects another array, replaces the
>oldest array and redraws. The effect is movement.
>The problem is that the method I am using involves drawing 10 jagged
>lines, replacing the oldest jagged line in memory and then redrawing.
>Between redraws, the only way in which I know to clear the screen is
>ClearViewPort. The result is a flash between redraws.
>Can anyone suggest a more intelligent way to do this?

Instead of clearing the whole screen, only clear the parts that need
it.  Setup another array which can be used to locate the positions of
the previous lines and simply draw the lines in black.  There are
other ways you could do this such as a virtual screen, but this should
be the easiest.  Also try synchronizing with the vertical retrace
<email if you need the code>

Scott

Re:Flicker-free graphics


Quote
>The problem is that the method I am using involves drawing 10 jagged
>lines, replacing the oldest jagged line in memory and then redrawing.
>Between redraws, the only way in which I know to clear the screen is
>ClearViewPort. The result is a flash between redraws.

The usual way to do avoid flickery graphics is to create your graph in a
different part of memory to the video addresses and once you've finished,
wait for the vertical retrace on your monitor. The vertical retrace is
when the CRT beam goes from the bottom of the screen back to the top
again, which takes a little time. During this time, nothing happens on
the screen, so you can copy the picture you have built up in memory into
the video memory location, giving you a new frame and flicker-free
animation.

If you want to find out more about this, with code and examples, look for
the Asphyxia VGA trainer series by Denthor (TUT 1 to TUT 19 (?)). It is
also included in the PC Games Programmer Encylopedia (PCGPE.ZIP). I can't
remember the FTP sites offhand, but I'm sure Garbo has them.

There might be a problem for you in that you have to _wait_ for the
retrace. It sounds like you want to be doing other things rather than
wait around wasting time. However, there might be a vertical retrace
interrupt you could use. I don't know for sure, though, you'd have to
find out for yourself. Again, the PCGPE has something I think.

Hope this helps. Unfortunately I'm no expert, I've just fooled around a
little ...

Cheers,
Richard

_______________________________________________________________________
Richard C A Cullen                  |  Postgraduate Student
EMail : I...@SIRIUS.TN.RL.AC.UK      |  Imperial College,
at Rutherford Appleton Laboratory   |  Dept of Electrical Engineering,
____________________________________|__________________________________

Re:Flicker-free graphics


Quote
sn...@jhu.edu (Amer Mallah) writes:
>I'm writing a program where I am trying to display a three dimensional
>graph of two variables versus time. As the program is run, data is
>collected and stored into an array. The computer then draws the most
>recent ten arrays, and then collects another array, replaces the
>oldest array and redraws. The effect is movement.
>The problem is that the method I am using involves drawing 10 jagged
>lines, replacing the oldest jagged line in memory and then redrawing.
>Between redraws, the only way in which I know to clear the screen is
>ClearViewPort. The result is a flash between redraws.
>Can anyone suggest a more intelligent way to do this?

If you are using a graphics mode with more than one screen page, you could
redraw on another page, and then switch to the other page, then redraw on
the first page, and so on.
Look up SetVisualPage and SetActivePage in your manual.

Hope this helps.

Ch. Eltschka
If you are missing information, just remember, that this article was moving
through the net with high relativistic speed, so any shortening comes from lorentz
contraction...

Re:Flicker-free graphics


Depending on want your image looks like, how about using XOR to
draw the lines.

SetWriteMode(XORput);

To erase the line, simply draw the line twice.

Alternatively, but I don't know about speed, instead of ClearViewPort,
save the background area before the lines are drawn, using GetImage,
draw your lines, then clear using PutImage. May not flicker as bad ?!?

HTH

Ray Cramer
R...@Pol.ac.uk

Re:Flicker-free graphics


I would me most interested to know how you obtain the vertical retrace
in software, as suggested at the end of this document.

Many thanks

Re:Flicker-free graphics


From some code I have, but not written by me :

Procedure Wait_For_Vertical_Retrace;
Var
   Status : Byte;
Begin
  Repeat
    Status:=Port[$3DA]
  Until (Status and 8) <> 0
End;

Further knowledge about it I do not have !!

HTH

Ray Cramer
R...@Pol.ac.uk

Other Threads