Commit 26823b1bb4da8cfb2e68939484e0bb1328ee2806

Sam Lantinga 2014-03-23T23:09:22

Added an event SDL_RENDER_DEVICE_RESET, which is triggered on Direct3D 11 when the device has been lost and all textures need to be recreated.

diff --git a/include/SDL_events.h b/include/SDL_events.h
index fc5a145..3bf604a 100644
--- a/include/SDL_events.h
+++ b/include/SDL_events.h
@@ -135,7 +135,8 @@ typedef enum
     SDL_DROPFILE        = 0x1000, /**< The system requests a file open */
 
     /* Render events */
-    SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset */
+    SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
+    SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
 
     /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
      *  and should be allocated with SDL_RegisterEvents()
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index bbfb2d3..df6983d 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -1593,9 +1593,8 @@ D3D11_HandleDeviceLost(SDL_Renderer * renderer)
 
     /* Let the application know that the device has been reset */
     {
-        /* TODO/FIXME: consider adding a new SDL event to indicate that the entire rendering device has been reset, not just render targets! */
         SDL_Event event;
-        event.type = SDL_RENDER_TARGETS_RESET;
+        event.type = SDL_RENDER_DEVICE_RESET;
         SDL_PushEvent(&event);
     }
 
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 9d41a19..676dee2 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1198,6 +1198,13 @@ SDLTest_PrintEvent(SDL_Event * event)
                 event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure);
         break;
 
+    case SDL_RENDER_DEVICE_RESET:
+        SDL_Log("SDL EVENT: render device reset");
+        break;
+    case SDL_RENDER_TARGETS_RESET:
+        SDL_Log("SDL EVENT: render targets reset");
+        break;
+
     case SDL_QUIT:
         SDL_Log("SDL EVENT: Quit requested");
         break;