Recommended Posts

Public SceneRenderTargetBuffer As Direct3DSurface8
Public SceneRenderToSurface As Direct3DSurface8
'
Sub RenderToStart(Texture As Direct3DTexture8)
'
Set SceneRenderTargetBuffer = D3DDevice.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO)
Set SceneRenderToSurface = Texture.GetSurfaceLevel(0)
D3DDevice.EndScene
D3DDevice.SetRenderTarget SceneRenderToSurface, Nothing, 0
D3DDevice.BeginScene
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, DX.Lib.GetARGBColor(255, 0, 0, 0), 1#, 0
'
End Sub
'
Sub RenderToEnd()
'
D3DDevice.EndScene
D3DDevice.SetRenderTarget SceneRenderTargetBuffer, Nothing, 0
D3DDevice.BeginScene
DoLog "Done" ' This line gets written!!
'
End Sub
So in your code:
'
D3DDevice.BeginScene
'
' Render stuff normally to backbuffer
'
etc,etc,etc
'
' Now render a few things to a texture
'
RenderToStart MyTexture
'
etc,etc,etc
'
RenderToEnd
'
' Go on with scene
'
etc,etc,etc
'
D3DDevice.EndScene
So what's the problem? Well, it works great in the IDE, but fails on all computers when compiled. Actually it never makes it out of the RenderToEnd() routine even though if I add a log line at the end the log gets written.
I get the weird "Automation 440" Error. Very strange!!
If I remark this line in the RenderToEnd() routine:
D3DDevice.SetRenderTarget SceneRenderTargetBuffer, Nothing, 0
Then it at least makes it out of the routine, so setting the render target back to the original seems to be causing the automation error.
The passed texture has it's usage flag set to render target and is placed in the default pool. The other non render target textures are placed in the managed pool.
!@#$% Am I doing something wrong? Is there a different way to do this? Based on my research I don't think so?!?! The code compared to other parts of my dx code seems trivial and very basic, so why is this giving me problems? !@#$%^&
Thanks for your time.