Fixed bug 1491 - Directx3d Crash on resize
authorSam Lantinga <slouken@libsdl.org>
Mon, 11 Feb 2013 21:12:14 -0800
changeset 6860 c16fc4e46ae5
parent 6859 7b36a8a5ee51
child 6861 c1c9eab3bd20
Fixed bug 1491 - Directx3d Crash on resize Spinduluz RenderTarget has to be released before a device reset is done. It's a D3DPOOL_DEFAULT surface (resides in video memory and have to be recreated).
src/render/direct3d/SDL_render_d3d.c
--- a/src/render/direct3d/SDL_render_d3d.c	Mon Feb 11 21:04:46 2013 -0800
+++ b/src/render/direct3d/SDL_render_d3d.c	Mon Feb 11 21:12:14 2013 -0800
@@ -361,6 +361,9 @@
     D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
     HRESULT result;
 
+    /* Release the default render target before reset */
+    IDirect3DSurface9_Release(data->defaultRenderTarget);
+
     result = IDirect3DDevice9_Reset(data->device, &data->pparams);
     if (FAILED(result)) {
         if (result == D3DERR_DEVICELOST) {
@@ -377,6 +380,7 @@
     IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
                                     D3DCULL_NONE);
     IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
+    IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
     return 0;
 }