Platform SDK: DirectX |
When the IDirectDrawSurface7::Flip method is called, the primary surface and back buffer are exchanged. However, the exchange may not occur immediately. For example, if a previous flip has not finished, or if it did not succeed, this method returns DDERR_WASSTILLDRAWING. In the samples included with the SDK, the IDirectDrawSurface7::Flip call continues to loop until it returns DD_OK. Also, a IDirectDrawSurface7::Flip call does not complete immediately. It schedules a flip for the next time a vertical blank occurs on the system.
An application that waits until the DDERR_WASSTILLDRAWING value is not returned is very inefficient. Instead, you could create a function in your application that calls the IDirectDrawSurface7::GetFlipStatus method on the back buffer to determine if the previous flip has finished.
If the previous flip has not finished and the call returns DDERR_WASSTILLDRAWING, your application can use the time to perform another task before it checks the status again. Otherwise, you can perform the next flip. The following example demonstrates this concept.
while(lpDDSBack->GetFlipStatus(DDGFS_ISFLIPDONE) == DDERR_WASSTILLDRAWING); // Waiting for the previous flip to finish. The application can // perform another task here. ddrval = lpDDSPrimary->Flip(NULL, 0);
You can use the IDirectDrawSurface7::GetBltStatus method in much the same way to determine whether a blit has finished. Because IDirectDrawSurface7::GetFlipStatus and IDirectDrawSurface7::GetBltStatus return immediately, you can use them periodically in your application with little loss in speed.
When the DirectDrawSurface7.Flip method is called, the primary surface and back buffer are exchanged. However, the exchange may not occur immediately. For example, if a previous flip has not finished, or if it did not succeed, this method raises a DDERR_WASSTILLDRAWING error.
An application that waits until the DDERR_WASSTILLDRAWING error value is not raised is very inefficient. Instead, you could create a function in your application that calls the DirectDrawSurface7.GetFlipStatus method on the back buffer to determine if the previous flip has finished.
If the previous flip has not finished and the call returns DDERR_WASSTILLDRAWING, your application can use the time to perform another task before it checks the status again. Otherwise, you can perform the next flip. The following example demonstrates this concept.
while(DDSBack.GetFlipStatus(DDGFS_ISFLIPDONE) = DDERR_WASSTILLDRAWING) ' Waiting for the previous flip to finish. The application can ' perform another task here. DDSPrimary->Flip(NOTHING, 0)
You can use the DirectDrawSurface7.GetBltStatus method in much the same way to determine whether a blit has finished. Because DirectDrawSurface7.GetFlipStatus and DirectDrawSurface7.GetBltStatus return immediately, you can use them periodically in your application with little loss in speed.