Jump to content
  • Advertisement
Sign in to follow this  
2dcoder

Copy Backbuffer To Texture Help

This topic is 4939 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

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
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...

Share this post


Link to post
Share on other sites
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!