Skip to content

Commit

Permalink
Added an event SDL_RENDER_DEVICE_RESET, which is triggered on Direct3…
Browse files Browse the repository at this point in the history
…D 11 when the device has been lost and all textures need to be recreated.
  • Loading branch information
slouken committed Mar 24, 2014
1 parent 25919bf commit 26823b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/SDL_events.h
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions src/render/direct3d11/SDL_render_d3d11.c
Expand Up @@ -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);
}

Expand Down
7 changes: 7 additions & 0 deletions src/test/SDL_test_common.c
Expand Up @@ -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;
Expand Down

0 comments on commit 26823b1

Please sign in to comment.