Thread: Take screenshot with directX?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    18

    Question Take screenshot with directX?

    Hi, I am trying to take a screenshot using directX.
    I have tried to compile some samples and read some articles but I can´t get it to work.

    The problem is the 2 functions that saves the surface to a file, SurfaceLoader.Save() and D3DXSaveSurfaceToFile().

    When I try to use surfaceloader.save I get the error: “error: `SurfaceLoader' undeclared (first use this function)”.

    And then the function D3DXSaveSurfaceToFile that almost all uses in there examples and articles, when I try to use it I get the error: “main.cpp: undefined reference to `D3DXSaveSurfaceToFileA@20'”

    I hope that someone can tell me how to get one of the functions to work, or how to work around the problem. like saving the surface to a GDI's BITMAP and then save it.

    Code:
    #include <windows.h>
    #include <iostream.h>
    #include <dx9/d3d9.h>
    #include <dx9/d3dx9.h>
    #include <dx9/D3dx9tex.h>
    
    IDirect3DDevice9*	g_pd3dDevice=NULL;
    IDirect3DSurface9*	g_pSurface=NULL;
    
    using namespace std;
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    
    {
        g_pd3dDevice->CreateOffscreenPlainSurface(200, 300, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &g_pSurface, NULL);
        g_pd3dDevice->GetFrontBufferData(0, g_pSurface);
        //this
        SurfaceLoader.Save("Screenshot.bmp", 0, g_pSurface);
        //or???
        D3DXSaveSurfaceToFile("Screenshot.bmp",D3DXIFF_BMP,g_pSurface,NULL,NULL);
        
        g_pSurface->Release();
        return 0;
    }
    EDIT:
    I use: DEV-C++, C++, dxsdk_aug2005
    Last edited by Dampy; 05-25-2008 at 06:59 AM. Reason: Forgot

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX screenshot via C (app crashes)
    By Delusionz in forum C Programming
    Replies: 6
    Last Post: 01-11-2009, 09:55 AM
  2. Isometric Tile Engine using DirectX
    By Wraithan in forum Game Programming
    Replies: 3
    Last Post: 07-17-2006, 12:16 PM
  3. DirectSound header issues
    By dxfoo in forum C++ Programming
    Replies: 0
    Last Post: 03-19-2006, 07:16 PM
  4. DirectX - Starting Guide?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-25-2004, 12:49 AM
  5. Directx SDK Documentation
    By Zoalord in forum Game Programming
    Replies: 4
    Last Post: 05-08-2003, 06:07 AM