DrawFlags - When to wait?

snarfblam

Ultimate Contributor
Joined
Jun 10, 2003
Messages
2,097
Location
USA
I am learning directx, and im making a sidescroller as my first game. My program draws my level. I am just not exactly sure as to the difference between the DrawFastFlags.Wait and DrawFastFlags.DoNotWait flags. When should i use which? Also, any tips for making a side scroller for a directx newbie would be great.
 
Always use the Wait flag, Wait means the program will wait until nothing else is using the surface (or at least that particular part of it) before using it. If you use DoNotWait and another thread is drawing to the surface and it overlaps where you're drawing then the program will crash, it may improve performance slightly but isn't really worth the risk
 
I'd suggestion making it a user option. If you don't want that trouble, use Wait. I've never heard of DoNotWait crashing a program but it might cause "tearing". In a 2D game that will look especially bad. It means drawing may occur during a screen retrace, which means the top half of the screen (or some portion, maybe not exactly half) will be slightly ahead of or behind the bottom half. Sometimes it's only a few pixels, sometimes 8, 16, 32 or more! Even a few pixels in 3D games can look quite noticable especially during laggy portions (where the time between frames is greater, the tearing will be worse).

-Ner
 
The "tearing" happens when your program doesn't wait for the VSync of the monitor before drawing. That is actually a different flag (WaitFlags.NoVSync or something) and nothing to do with DoNotWait, if memory serves.
 
To wait or not to wait; that's a good question. :confused:

While making my tetris, I asked myself the same question. I didn't see any difference between the two. I used both. My code was greatly based on tutorials from DirectX9 SDK. From what I've seen in those tutorials, they often use the DoNotWait flag. I had no crash, no tearing or any other problems using DoNotWait.

I'll be looking into it.
 
Tetris is also windowed, not that that necessarily matters, i dont know; I've never made a windowed program in directx.

But a question about those tutorials: where are they? The only directx tutorials that came with the sdk that i can find are for direct3d. Worse yet, the only documentation I can find is the C++ documentation. Microsoft.com is very lacking in Directx9 documentation, as well as the rest of the internet.
 
DirectDraw tutorials or samples are located in %DXSDK%\Samples\VB.Net\DirectDraw\ where %DXSDK% is the directory in which you installed DirectX 9 SDK (In my case, C:\DXSKD).

As for documentation, you can read on msdn that it is still a preliminary documentation.

I'm not sure but you might not have downloaded the complete sdk if you lack some samples.
 
I've been told not to use DoNotWait because drawing functions lock surface memory while drawing, and locked memory can't be locked a second time. Sorry if I was wrong
 
Back
Top