Sign in to follow this  
2dcoder

Copy Backbuffer To Texture Help

Recommended Posts

2dcoder    122
Why would this code cause an automation error? Any ideas? In VB(6) code: (Texture to texture works fine, but not backbuffer to texture?) I realize offscreen or off texture values could cause errors. But I'm wondering if I need to lock anything prior to the copyrects call? Thanks for any help. Public Sub BackBufferToTexture(ByVal SrcX As Single, ByVal SrcY As Single, _ ByVal srcwidth As Single, ByVal srcheight As Single, ByVal DstTexture As Long, _ ByVal DstX As Single, ByVal DstY As Single) ' Dim SSurface As Direct3DSurface8 Dim DSurface As Direct3DSurface8 ' With srect .Left = SrcX .Top = SrcY .Right = .Left + srcwidth .Bottom = .Top + srcheight End With ' With drect .Left = DstX .Top = DstY .Right = .Left + srcwidth .Bottom = .Top + srcheight End With ' Set SSurface = D3DDevice.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO) Set DSurface = Textures(DstTexture).GetSurfaceLevel(0) ' D3DDevice.CopyRects SSurface, srect, 1, DSurface, drect ' Set SSurface = Nothing Set DSurface = Nothing ' End Sub

Share this post


Link to post
Share on other sites
2dcoder    122
I can do surface to surface, texture to texture, no prob, so I must be missing something obvious to copyrects from the backbuffer to a texture. errr...

Share this post


Link to post
Share on other sites
neneboricua19    634
It seems you're using DX8 here. I'm not a VB coder but I can try to help.

You should be able to do this. What does the debug spew say? Do you get any error messages back? You say this causes an automation error; where does the error occur?

Why are you trying to copy the backbuffer in the first place? My guess is that you could probably achieve better results by rendering to a texture in the first place instead of rendering to the back buffer and then copying it to a texture.

neneboricua

Share this post


Link to post
Share on other sites
2dcoder    122
Thanks, the error is always at this line:

"D3DDevice.CopyRects SSurface, srect, 1, DSurface, drect"

I can modify the routine to have it work from surface to surface, surface to texture, or texture to texture, no problem. But as soon as I attempt to do it from the backbuffer to a surface (from a texture), the automation error pops up.

The code is in VB6 using DirectX8. Any help, ideas, is appreciated.

Share this post


Link to post
Share on other sites
neneboricua19    634
Again, what does the debug spew say? Do you get any error messages back?

Why are you trying to copy the backbuffer in the first place? What are you trying to do? My guess is that you could probably achieve better results by rendering to a texture in the first place instead of rendering to the back buffer and then copying it to a texture.

neneboricua

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