Archived

This topic is now archived and is closed to further replies.

who can explain in detail DDRAW's drawing process?

This topic is 4982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Assume there''s only a primary surface. I dont quite understand why under this circumstance there tend to be artifacts during animatinon. first, when the graphics card is drawing a frame scan line by scan line, can I aquire a lock to the surface? if no, then when can I aquire it? second, when I have the lock to the surface and am writing to it, can the graphics card do the drawing? if no, does it mean it can only start drawing a frame after I release the lock?

Share this post


Link to post
Share on other sites
You can lock the surface at any moment. The graphics card just continuously keeps reading the frame buffer and displays it. So you''ll inevitably get ''tearing'' effects when locking while it''s drawing. However, the graphics card takes a little pause after every frame. This is to allow CRT screens to aim their electron gun to the start of the screen again. It''s called a vertical retrace (horizontal retraces are done at every line, and take less time).

So to avoid tearing there are two options: Only make changes to the frame buffer during a (vertical) retrace, or make the graphics card draw another buffer while we''re changing the current one. The first method implies that it has to be done quickly. There''s only enough time to do a copy operation (a blit) actually. But this method is used a lot when in windowed mode. The second method requires to set up a front and a back buffer. The front buffer is the one currently visible, the back buffer you can draw into. When the driver is instructed to perform a ''flip'', the graphics card will display what''s on the back buffer (which has now actually become the front buffer).

In DirectDraw, to blit during a retrace, you have to lock the front buffer (primary surface) using the VSYNC (vertical syncronisation) flag. Flipping during a retrace can be done using such a flag as well. Check the DirectX 7 SDK documentation for details.

Share this post


Link to post
Share on other sites