Sign in to follow this  
Breathless

DirectX8 and screenshots

Recommended Posts

Breathless    100
I like to say hello its my first post in this forum:)

I have a need to take screenshot from my game window. Its in DirectX8. To take screenshot i find this function:

Quote:

Public Function SaveScreenShot3D(dev As Direct3DDevice8, d3dx As D3DX8, strFileName As String) As Boolean

Dim Surf As Direct3DSurface8
Dim Palette As PALETTEENTRY
Dim r As RECT
Dim DispMode As D3DDISPLAYMODE

On Error GoTo errOut

dev.GetDisplayMode DispMode

Set Surf = dev.CreateImageSurface(DispMode.Width, DispMode.Height, D3DFMT_A8R8G8B8)
dev.GetFrontBuffer Surf
With r
.Left = 0
.Top = 0
.Right = DispMode.Width
.bottom = DispMode.Height
End With

d3dx.SaveSurfaceToFile strFileName, D3DXIFF_BMP, Surf, Palette, r

SaveScreenShot3D = True
Exit Function

errOut:
SaveScreenShot3D = False
End Function


Its working ok, but it takes screen from all Windows + window of my game (its windowed game). How can i make it to save screen only game window device?
Its Visual Basic 6.

Share this post


Link to post
Share on other sites
Jon Hellebuyck    100
I'm not familiar with DX8 for VB, but from the looks of it "r" is the rectangle structure that specifies how much of the front buffer (screen) surface information is saved to the file. Currently the rectangle you've specified starts at the upper left-hand corner of the screen:

With r
.Left = 0
.Top = 0

and captures the entire width and height of the screen:

.Right = DispMode.Width
.bottom = DispMode.Height

If you change your Left and Top values to match the upper left-most pixel of the canvas of the window you want to capture, and change Right and Bottom to be the width and height of that canvas, I would think it should work.

Share this post


Link to post
Share on other sites
Breathless    100
Hi thank you for reply.

I was trying to change that and only change values DispMode.Width and DispMode.Height have no effects.
But i see this function its not realy like i want because its taking screens also if any window its up to my game window.
So i wondering how to make screen only directly game window device.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this