Archived

This topic is now archived and is closed to further replies.

Making ingame "movie" ?

This topic is 5308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I make a movie of all the things I do in my 3D engine? Or just, saving a picture every frame? Guess I can do this by saving the Z-buffer everytime before showing it or something? But is there a way to do this? A "save BMP" function or so Thnx

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

void CDirect3D::SaveScreenShot(LPCTSTR pDestFile)
{
// Pointer to the memory location containing a copy of the front buffer

IDirect3DSurface9* pd3dsFront = NULL;

// Get the current viewport

D3DVIEWPORT9 d3dViewport;
m_pd3dDevice->GetViewport(&d3dViewport);

// Create the surface that the screen shot will be copied into

m_pd3dDevice->CreateOffscreenPlainSurface(d3dViewport.Width, d3dViewport.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pd3dsFront, NULL);

// Copy the front buffer to the image surface

if( FAILED( m_pd3dDevice->GetFrontBufferData(0, pd3dsFront) ) )
{
pd3dsFront->Release();
return;
}

// Save screen shot to a bitmap file

D3DXSaveSurfaceToFile(pDestFile, D3DXIFF_BMP, pd3dsFront, NULL, NULL);

// Release the surface so there is no memory leak

pd3dsFront->Release();
}

Share this post


Link to post
Share on other sites
He doesn''t work here... I''m using DirectX 8, so I changed some variables etc...

But I think DirectX 8 doesn''t know the commands:

m_pD3DDevice->CreateOffscreenPlainSurface
and
m_pD3DDevice->GetFrontBufferData

Any idea about solving this?

Thnx

Share this post


Link to post
Share on other sites
You can try:

GetBackBuffer

When saving use a counter in the filename and then.

D3DXSaveSurfaceToFile

And clean up anything you create before exiting.

When you are done, you use a program like After effects or any other program that can put images together and make a movie.
This would be silent though. To make a movie with sound, you would need to save sound as it happens in the game as well. If you have cpu time you could even go so far as to use a coding scheme using divx or something to capture a movie in realtime. Maybe in a lower resolution or at 30fps you decide. There are also programs (can''t remember the names) that can do this for you ingame.

Hope this helps, they are just ideas.



____________________________________________________________
Try RealityRift at www.planetrift.com
Feel free to comment, object, laugh at or agree to this. I won''t engage in flaming because of what I have said.
I could be wrong or right but the ideas are mine.

Share this post


Link to post
Share on other sites
FRAPS is an option indeed... but I would like to be able to do this in game... in code.

So maybe anyone knows how to alter the code above to make it work under DX8?

Thnx

Share this post


Link to post
Share on other sites
It''s working! Thnx for all the help!

Final code was:

void CGame::SaveScreenShot()
{
IDirect3DSurface8* ppBackBuffer = NULL;
D3DVIEWPORT8 d3dViewport;
m_pD3DDevice->GetViewport(&d3dViewport);
m_pD3DDevice->GetBackBuffer (0, D3DBACKBUFFER_TYPE_MONO,
&ppBackBuffer);
D3DXSaveSurfaceToFile("test.bmp", D3DXIFF_BMP, ppBackBuffer,
NULL, NULL);
ppBackBuffer->Release();
}

Thnx again!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You could always generate some sort of movie script, and have the engine run it. The engine will use the script to place characters and the camera, and also to control movement. This way your movies will be rendered in realtime and if the movie is in the middle of a level, and uses all the same resources, you won''t have to switch to an mpeg/avi which might require you to unload the current game state and reload it when the cutscene is over.

Share this post


Link to post
Share on other sites
Here my Screenshot function for directX8:
lpDevice is a pointer to your LPDIRECT3DDEVICE8

void Graphics::CreateScreenshot(char bitmapname[15], int screenwidth, int screenheight)
{
LPDIRECT3DSURFACE8 lpFront;

(*lpDevice)->CreateImageSurface(screenwidth, screenheight, D3DFMT_A8R8G8B8, &lpFront);

(*lpDevice)->GetFrontBuffer(lpFront);

D3DXSaveSurfaceToFile(bitmapname, D3DXIFF_BMP, lpFront, NULL, NULL);

lpFront->Release();
}

Share this post


Link to post
Share on other sites
And what is the best way to make a "movie" of your actions, in code...? Just make a lot of screenshots and place these behind each other... or are there posibilies to save it al in a .avi or .mpg movie directly?

Thnx

Share this post


Link to post
Share on other sites