Problems rendering to a surface

Started by
1 comment, last by snake5 14 years, 3 months ago
I'm porting my 2D game engine from SDL/OpenGl to DirectX 9.0c. I need to be able to create bitmaps and blit stuff on them, so I figure I need to render to a surface. I'm using the ID3DXRenderToSurface interface to handle the details about rendering. Problem is, this is VERY slow. I suppose it happens because my texture does not have D3DUSAGE_RENDERTARGET specified so the interface has to render to its internal texture, then copy to my texture. So I try putting the render target flag, but now it complains that it is not in the default pool, and that's not exactly better because that would mean that I have to re-render everything when my device is lost, and I might need to lock too. (But it fixes the speed problem if I put default.) There's also another problem with rendering to a surface: the parts where nothing was rendered on gets garbage like what was previously on the screen the last time I ran the engine. I doubt I'm the first one trying to do a simple 2D engine with DirectX 9.0c, so how is this usually done?
Advertisement
Anyone? I'm sorta blocked on that issue.
Render on the D3DPOOL_DEFAULT surface, then copy it to a D3DPOOL_SYSTEMMEM surface yourself when you need it.
And clear the surface after setting it before you do any rendering on it to avoid seeing video memory dumps.

This topic is closed to new replies.

Advertisement