Thread: Screenshots in DX9

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    288

    Screenshots in DX9

    well, im wondering how i could take a screenshot of the DirectX window and save it to a bmp (for simplicity). At the moment, heres the code i use:

    Code:
    bool TakeScreenShot(IDirect3DDevice9 *Device, char *FileName, int ScreenX, int ScreenY)
    {
      IDirect3DSurface9 *FrontBuffer; 
      bFailed = false;
      HRESULT Result;
    
      Result = Device->CreateOffscreenPlainSurface(ScreenX, ScreenY, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &FrontBuffer, NULL);
    
      if (Result != D3D_OK)
      {
        //FrontBuffer->Release(); Thanks Magos
        return false;
      }
    
      Result = Device->GetFrontBufferData(0, FrontBuffer);
    
      if (Result != D3D_OK)
      {
        FrontBuffer->Release();
        return false;
      }
    
      Result = D3DXSaveSurfaceToFile(FileName, D3DXIFF_BMP, FrontBuffer, NULL, NULL);
    
      if (Result != D3D_OK)
      {
        FrontBuffer->Release();
        return false;
      }
    
      FrontBuffer->Release();
      return true;
    }
    it works fine, but its EXTREMELY slow, i tried putting it in a thread, and i get a deformed image.

    so, i was wondering, would it be faster/better to do this using GDI? ie. bitblt into a memory hdc and go from there? or is this the only way?

    Thanks in advance.
    Last edited by X PaYnE X; 04-14-2005 at 05:26 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screenshots
    By Dae in forum Windows Programming
    Replies: 4
    Last Post: 07-08-2009, 01:21 AM
  2. Lights and .X files in c# using dx9
    By poopy_pants2 in forum Game Programming
    Replies: 2
    Last Post: 04-26-2004, 10:30 AM
  3. DX9 and Dev-C++
    By Ashes999 in forum Windows Programming
    Replies: 5
    Last Post: 06-10-2003, 12:19 AM
  4. screenshots of your games
    By stallion in forum Game Programming
    Replies: 94
    Last Post: 03-26-2003, 08:56 PM
  5. Screenshots of Upcoming "Mists of Avalon"
    By harry_p in forum C++ Programming
    Replies: 62
    Last Post: 08-02-2002, 11:37 AM