Direct Draw weird stuff

This is a discussion on Direct Draw weird stuff within the C++ Programming forums, part of the General Programming Boards category; I'm working on a Direct Draw program. I'm having a weird problem though. Whenever I alt-tab out of it and ...

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Direct Draw weird stuff

    I'm working on a Direct Draw program. I'm having a weird problem though. Whenever I alt-tab out of it and then return everything goes black. It's still working, but the graphics disappear.
    Is this caused by so called "lost surfaces"? How do I restore them?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Rebooted Inquirer's Avatar
    Join Date
    Apr 2002
    Posts
    281
    I have no idea what you are talking about with diectdraw, because i am new to C++ or maybe some completely different reason, but i have been programming java for a long time, and it has been a problem that when a window is covered, certain things on it will not come back. THere is a handle in java called Iconized() and DeIconized() that deal with a minimize and unminimize, and another one, unfocused or something to that extent, i havent used these often so i don't know the details, but conventially they are used to call repaint() on certain objects. May this be in order? i have no idea hw to do this in C++ though. I may also be way off the mark too. If i am, just ignore me.

    ~Inquirer

    P.S. What is DirectDraw?
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Magos, what you need to do is:

    1 - declare a global bool variable to represent a paused state.
    2 - Check for a WM_ACTIVATEAPP message, if the wParam = 0
    then your app is being deactivated, set paused to true. If the
    wParam is non-zero then your app is being activated, set paused
    to false, restore all surfaces (don't forget to re-blit your *.bmps
    back into your surfs after restoring them).
    3 - In your main loop if paused == true then don't do any blitting.

  4. #4
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Originally posted by Inquirer
    P.S. What is DirectDraw?
    Inquirer,
    Microsoft's DirectX 2d graphic library.

    *****

    Losing your surfaces in DirectDraw can't be fixed like that. The
    LPDIRECTDRAW7 object has a function to restore surfaces.

    HRESULT IDirectDraw7::RestoreAllSurfaces();

    This won't reload your graphics into the surfs (as I mentioned
    above, so you have to reblit your *.bmp's onto the surfs after a
    call to it).

    Not the same as getting a WM_PAINT message.

  5. #5
    Rebooted Inquirer's Avatar
    Join Date
    Apr 2002
    Posts
    281
    Thanks
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by jdinger
    Magos, what you need to do is:

    1 - declare a global bool variable to represent a paused state.
    2 - Check for a WM_ACTIVATEAPP message, if the wParam = 0
    then your app is being deactivated, set paused to true. If the
    wParam is non-zero then your app is being activated, set paused
    to false, restore all surfaces (don't forget to re-blit your *.bmps
    back into your surfs after restoring them).
    3 - In your main loop if paused == true then don't do any blitting.
    How do I restore them? In a D3D tutorial I read you used something like this:

    if(Surface->IsLost()==DDR_SURFACELOST) Surface->Restore();

    However, that constant is undeclared in DirectDraw...

    [EDIT]
    Oh, never mind. I didn't read your last post... .
    [/EDIT]
    Last edited by Magos; 04-23-2002 at 01:02 AM.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  7. #7
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    YES! It works now, when I do:

    if(Surface->IsLost()) Surface->Restore();

    No need for that constant
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Direct Music Illegal Static Member Call error
    By FwyWice in forum Game Programming
    Replies: 4
    Last Post: 11-30-2002, 05:14 PM
  2. Direct Music Trouble
    By FwyWice in forum Game Programming
    Replies: 5
    Last Post: 11-29-2002, 04:01 PM
  3. Direct Draw 7 color keying?
    By cozman in forum Game Programming
    Replies: 5
    Last Post: 04-06-2002, 08:07 AM
  4. Messed up direct draw surface fliping.
    By bobish in forum Game Programming
    Replies: 5
    Last Post: 10-31-2001, 02:24 PM
  5. need help with some DX stuff
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 09-22-2001, 06:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21