Thread: Trouble getting snapshot of screen :(

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

    Unhappy Trouble getting snapshot of screen :(

    Hey guys, I have a problem with my DirectDraw code. I'm trying to make a function that gets a snapshot of the screen, which can be later used to redraw the screen. I'm having troubles though, not sure exactly what. My function code is below (slightly modified, but not significantly).
    Code:
    //sfcFront and sfcBack are the front and back buffers of the screen.
    IDirectDrawSurface7* GFX::getSnapshot(bool frontBuffer)
    {
    	IDirectDrawSurface7* surface;
    
    	DDSURFACEDESC2 ddsd; //originally was class variable
    	memset(&ddsd, 0, sizeof(ddsd));
    	ddsd.dwSize = sizeof(ddsd);
    	ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    	ddsd.dwWidth = scrnRect.right;
    	ddsd.dwHeight = scrnRect.bottom;
    
    	//ddBltFx is a class variable of GFX.
    	ddBltFx.dwSize = sizeof(ddBltFx);
    
    	//lpdd is the DirectDraw interface/object thinger
    	if(FAILED(lpdd->CreateSurface(&ddsd, &surface, NULL)))
    		return NULL;
    
    	if(frontBuffer)
    	{
    		if(FAILED(surface->Blt(NULL, sfcFront, NULL, DDBLT_WAIT, &ddBltFx)))
    			return NULL;
    	}
    	else
    	{
    		if(FAILED(surface->Blt(NULL, sfcBack, NULL, DDBLT_WAIT, &ddBltFx)))
    			return NULL;
    	}
    
    	return surface;
    }
    I have tested the return values, and it was never NULL. It's just that whenever I try blitting the returned surface, it doesn't blit the original screen. Can anybody see any errors in the code that I missed?
    Just Google It. √

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

  2. #2
    Normal vector Carlos's Avatar
    Join Date
    Sep 2001
    Location
    Budapest
    Posts
    463
    Why are you using DDSCAPS_OFFSCREENPLAIN in the DDCAPS structure?

    Try DDSCAPS_PRIMARYSURFACE.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Hmm, I thought DDSCAPS_PRIMARYSURFACE meant that it was the actual screen (i.e. what gets blitted to that gets shown on the screen)? I used offscreenplain because it's supposed to be... off of the screen Am I wrong about this?
    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. How does this user get screen to run under root?
    By Overworked_PhD in forum Tech Board
    Replies: 2
    Last Post: 06-28-2009, 09:31 AM
  2. Replies: 3
    Last Post: 05-09-2009, 08:37 PM
  3. Largest screen buffer size?
    By Ash1981 in forum C Programming
    Replies: 2
    Last Post: 01-30-2006, 04:31 AM
  4. Console Screen Buffer
    By GaPe in forum Windows Programming
    Replies: 0
    Last Post: 02-06-2003, 05:15 AM
  5. Green Pixel On My Screen???
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 01-21-2002, 08:09 AM