From 26823b1bb4da8cfb2e68939484e0bb1328ee2806 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 23 Mar 2014 23:09:22 -0700 Subject: [PATCH] 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. --- include/SDL_events.h | 3 ++- src/render/direct3d11/SDL_render_d3d11.c | 3 +-- src/test/SDL_test_common.c | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index fc5a145e7..3bf604adb 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 bbfb2d3ea..df6983d4a 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 9d41a194e..676dee2ce 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;