Flickering image (with *double buffering*)
Ok, this is my code. It is supposed to black out surfaceSecondary, then blit the image from surfaceBitmap onto surfaceSecondary, then display the result on the screen:
PHP Code:
surfaceSecondary->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &blackBltFx);
surfaceSecondary->Blt(&rect, surfaceBitmap, NULL, DDBLT_WAIT, NULL);
surfacePrimary->Blt(&rect, surfaceSecondary, NULL, DDBLT_WAIT, NULL);
while(surfacePrimary->Flip(NULL, DDFLIP_WAIT) != DD_OK);
blackBltFx is a DDBLTFX that is memsetted to 0 (then its dwSize is reset to sizeof(DDBLTFX)), and rect is a RECT filled in with the image's dimensions.
The problem isn't that it flickers from black to image to black to image, but that only part of the image gets drawn, except for occasional glimpses. Putting a Sleep(1) after the two surfaceSecondary blits gets the whole image to display except occasional partial-blits, and a Sleep(2) gets the thing to blit very nicely. Why is it that I need the Sleep()'s to make it blit properly?
**EDIT**
n/m, think I figured it out... the surfacePrimary blt() is the culprit. BUT, just a question, but what is the point of using Flip() instead of Blt() when surfaceSecondary is an attached surface?