Herewith message from Gordon Fody which might be interesting to some of
you...........


Hey Alistair, its nice to hear from you..  its summer, so I haven't been
able to spend much time on my project.  I read the conversation, and I
see a few things to note on..

When you draw to an offscreen bitmap you must keep in mind that windows
has two types of bitmaps. A device independant bitmap (DIB) and a device
dependant bitmap (DDB).

A DDB will always have the same bit depth as the screen.. and its bits
are stored in a device dependant manner (rgb bgr grb etc - depends on
the device).  When you call a gdi routine to say.. draw a line, it is
implemented by the driver.  And when you call bitblt to display it, the
bits are simply copied over to the frame buffer and viola you can see it
-- of coarse you could speed it up a tiny bit by drawing your line
directly to the frame buffer and skipping the bitblt step, but then
you'll often get a tearing effect as the drawing operations don't wait
for a vertical retrace.  The DDB is completely implemented by the
driver/hardware.. so yes, its as fast as your gunna get for windowed
graphics.

One thing that sucks about a DDB is that you can't access its bits
directly. (even if you could, you couldn't assume how the bits were
stored because that varies from device to device).  So thats why we have
the DIB.  When you call a gdi routine to draw a line on a DIB its
implemented by the driver as well, and you can also access the bits
directly (and you know its bgr ;-).. but when you call bitblt to display
it, the bits aren't just copied over.. a conversion has to be made.  The
bits have to be shifted around so that they are compatible with the
device (bgr => rbg or whatever).. and if your dib isn't the same bit
depth as the screen it must be converted to match that as well (24bpp =>
16 or 8 or 32 etc).  Sounds like it would slow things down pretty bad..
it use to.  But since win95, if you have a descent video card then these
conversions are done in hardware and very quickly.

I noticed somebody said that they changed the lights demo to 1024x768..
(btw: its not a 3rd party demo, the code is from me). I'll just say that
bitmaps, be it DDB or DIB are painted to the screen by copying their
bits to the frame buffer.  If you have a 1024x768x24 bitmap, thats about
2.4megs that must be copied to the frame buffer 30 times a second.. of
coarse it will be slow.  When you want full screen graphics you can't be
jerking 2.4 megs back and forth.. you'll have to use a technique called
page flipping.  Thats when you simply change the address of the frame
buffer to point to your bitmap.  Theres methods for this in the windows
games api (direct draw)
-Gordy



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to