Copy Backbuffer To Texture Help

Started by
5 comments, last by neneboricua19 18 years, 10 months ago
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
Advertisement
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...
Can anyone help? Obiwan, where are you! :)
One last bump to see if this is even possible. Thanks for your time. ;)
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
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.
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

This topic is closed to new replies.

Advertisement