Thread: Usage of IDirectDrawSurface7::Flip()

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

    Usage of IDirectDrawSurface7::Flip()

    Hey everyone, I have a quick question. In my book (yes, this is becoming familiar to all of you! ), this is the code it has for flipping a complex surface:
    Code:
    while(surface->Flip(NULL, DDFLIP_WAIT) != DD_OK);
    I have two problems with this code (it works fine, my problems are just due to my excessively picky nature).

    #1: In the DirectX 7 docs, it says that DDFLIP_WAIT is set by default; thus, theoretically I could replace it with 0 and it would work just as well, and I would cut down the size of my source file by 10 bytes. Am I correct?

    #2: In the docs, it says that if DDFLIP_WAIT is set, "The method does not return until the flipping operation has been successfully set up or another error, such as DDERR_SURFACEBUSY, is returned." Under DDERR_SURFACEBUSY, it says "Access to the surface is refused because the surface is locked by another thread." Is this why there is a while loop? To keep trying until the other thread unlocks the surface?

    **EDIT**

    #3: On MSDN, it said somewhere (I think in the FAQ) that the proper method to check whether or not a call failed was to use the macro FAILED(). Does it matter in this case?
    Code:
    while(FAILED(surface->Flip(NULL, DDFLIP_WAIT)));
    Last edited by Hunter2; 01-02-2003 at 08:20 PM.
    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. Reduce CPU usage
    By patrick22 in forum Windows Programming
    Replies: 9
    Last Post: 07-10-2009, 02:13 PM
  2. Net cpu usage of pthreads?!
    By mynickmynick in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2008, 07:59 AM
  3. Memory usage and memory leaks
    By vsanandan in forum C Programming
    Replies: 1
    Last Post: 05-03-2008, 05:45 AM
  4. Calculating CPU Usage
    By vitaliy in forum Linux Programming
    Replies: 3
    Last Post: 08-21-2005, 09:38 AM
  5. Win2K Limiting CPU Usage?
    By drdroid in forum Tech Board
    Replies: 4
    Last Post: 03-31-2004, 02:08 PM