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