DrawFlags - When to wait?

snarfblam

Mega-Ultra Chicken
Joined
Jun 10, 2003
Messages
1,832
Location
USA
User Rank
*Expert*
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 youre drawing then the program will crash, it may improve performance slightly but isnt really worth the risk
 
Id suggestion making it a user option. If you dont want that trouble, use Wait. Ive 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 its 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 doesnt 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; thats a good question. :confused:

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

Ill be looking into it.
 
Tetris is also windowed, not that that necessarily matters, i dont know; Ive 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.

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