Board index » delphi » Capturing screen refreshing - can be done??

Capturing screen refreshing - can be done??

Hello
I have a pretty difficult question.
I need to make a small application that have a small rectangle that switch
colors from black to white in a special order I supply.This rectangle must
be able to switch the colors very fast (something like 20 or more times a
second) without flickering.
I thought of synchronizing the switches with the screen refreshing, meaning
that if my screen has a refresh rate of 75 Hz, I want that the switches will
happen with every 4 refreshes or so.
Can it be done?
Can I use some sort of signal or message from the Video adapter?
Is there a better way to prevent flickering of my rectangle?

Thanks

Ran kornfeld
rank...@internet-zahav.net

 

Re:Capturing screen refreshing - can be done??


Quote
"Ran Kornfeld" <rank...@internet-zahav.net> wrote in message news:8h14cv$l8m4@bornews.borland.com...
> I need to make a small application that have a small rectangle that switch
> colors from black to white in a special order I supply.This rectangle must
> be able to switch the colors very fast (something like 20 or more times a
> second) without flickering.

I've never been able to get more than about 7-10 frames per
second using "normal" Windows API calls and doing anything
with a bitmap between frames.

You might investigate DirectX, which should be much faster.

With DirectX (using Hori's components), you might investigate a
TDXDraw.Flip, where you draw on one surface and then very
quickly change to another (double buffering).

Find some DirectX links on this page:
http://www.efg2.com/Lab/Library/Delphi/Graphics/Resources.htm

--
efg

Earl F. Glynn     E-mail:  EarlGl...@att.net
Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

Re:Capturing screen refreshing - can be done??


"Earl F. Glynn" <EarlGl...@att.net> wrote in message news:8h15tf$lb84@bornews.borland.com...

Quote
> "Ran Kornfeld" <rank...@internet-zahav.net> wrote in message

news:8h14cv$l8m4@bornews.borland.com...

Quote
> > I need to make a small application that have a small rectangle that switch
> > colors from black to white in a special order I supply.This rectangle must
> > be able to switch the colors very fast (something like 20 or more times a
> > second) without flickering.

> I've never been able to get more than about 7-10 frames per
> second using "normal" Windows API calls and doing anything
> with a bitmap between frames.

I forgot to say in the earlier post that the normal Delph TTimer can be
a problem at some point if you update the display of an image based
on a timer.  You'll need a TThreadedTimer to get faster updates.

--
efg

Earl F. Glynn     E-mail:  EarlGl...@att.net
Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

Re:Capturing screen refreshing - can be done??


Quote
>I thought of synchronizing the switches with the screen refreshing, meaning
>that if my screen has a refresh rate of 75 Hz, I want that the switches
will
>happen with every 4 refreshes or so.
>Can it be done?

MS DirectDraw provides an easy way to find out where the raster scan is.
You can use Erik Ungers DirectX header translation:

http://www.delphi-jedi.org/DelphiGraphics/DirectX/Download.htm
One way of getting a DirectDraw interface is like this:
var
  DirectDraw: IDirectDraw;

OleCheck(DirectDrawCreate(nil, DirectDraw, nil));
DirectDraw.SetCooperativeLevel(GetDesktopWindow(), DDSCL_NORMAL);

You can wait until the raster has scanned past a Rect like this:

    BottomOfRect := ClientToScreen(Rect.BottomRight).Y;
    repeat
      DirectDraw.GetScanLine(ScanLine);
      Sleep(0);
    until ScanLine > BottomOfRect;

or wait until vertical blanking interval like this:

  DirectDraw.WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);

Regards,

Wayne

Other Threads