Skip to main content
GameDev.net gamedev.net
🔒 Locked

Print Screen from software

Started by Saiz Feb 25, 2003 at 2:21 AM 2 replies 400+ views
Original Post
Saiz
Saiz
Hi, How can print the screen from Direct3D? PrintScreen key works, but you need to leave the program to save it. I was lookig for an option that would allow me to save picture of my 3D scenes while keeping a counter of them. Thank you very much.
Drazgal
Drazgal
You can get get access to a surface with the contents of the front buffer with a method from your Direct3DDevice, cant remember the exact name though, you can then use a DirectX helper function to save the surface as a bitmap.
Yann L
Yann L
Moved to DirectX.
NeonGE
NeonGE
This is a function to save screenshots, it works with DirectX 8.1.

  
VOID CGraficos::GrabaScreenShot(LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* NombreArchivo)
{//Graba un screen shot de la superficie primaria del dispositivo indicado en el archivo especificado (SOLO COMO BMP)

//Creamos un puntero al front buffer

IDirect3DSurface8* FrontBuffer;

//Extraemos las medidas del dispositivo

D3DVIEWPORT8 vp;
pd3dDevice->GetViewport(&vp);

//Ahora creamos la superficie en la que se copiara nuestra imagen

//La superfice del front buffer es D3DFMT_A8R8G8B8 cuando es regresada

pd3dDevice->CreateImageSurface(vp.Width, vp.Height, D3DFMT_A8R8G8B8, &FrontBuffer);

//Ahora copiamos el front buffer a nuestra superficie

HRESULT hr = pd3dDevice->GetFrontBuffer(FrontBuffer);

if(hr != D3D_OK)
{//Si fallo al obtener el front buffer

FrontBuffer->Release(); //Liberamos la superficie para evitar memory leaks

return;//Salimos de la funcion

}

//Ahora escribimos la informacion en un bitmap

D3DXSaveSurfaceToFile(NombreArchivo, D3DXIFF_BMP, FrontBuffer, NULL, NULL);

FrontBuffer->Release();
}


If God with me, Who against me?
--------------------------------------------- If God with me, Who against me?Personal Web Samuel Prince Blog...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.