Thread: Flickering image (with *double buffering*)

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    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(NULLNULLNULLDDBLT_WAIT DDBLT_COLORFILL, &blackBltFx);
    surfaceSecondary->Blt(&rectsurfaceBitmapNULLDDBLT_WAITNULL);

    surfacePrimary->Blt(&rectsurfaceSecondaryNULLDDBLT_WAITNULL);
    while(
    surfacePrimary->Flip(NULLDDFLIP_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?
    Last edited by Hunter2; 12-08-2002 at 10:16 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Flip( ) always is in synchronization with the vertical blank interval (vbi). This way you can ensure no "tearing" or visual artifacts. If you just use Blt you might be drawing when electron gun isn't on its way back up to the top and you will get artifacts. Hope this helps.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Oh, (I think) I get it. Thanks!
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Replies: 1
    Last Post: 05-27-2009, 12:46 PM
  3. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 12:10 PM
  4. Image flickering in form
    By c9dw2rm8 in forum C# Programming
    Replies: 4
    Last Post: 04-06-2008, 04:00 PM
  5. Replies: 4
    Last Post: 03-02-2003, 09:12 AM