mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Recreate render target textures when the D3D device is being reset, and notify the application using the SDL_RENDER_TARGETS_RESET event when this happens.
This commit is contained in:
parent
9f2509da79
commit
ae05f178c2
@ -134,6 +134,9 @@ typedef enum
|
|||||||
/* Drag and drop events */
|
/* Drag and drop events */
|
||||||
SDL_DROPFILE = 0x1000, /**< The system requests a file open */
|
SDL_DROPFILE = 0x1000, /**< The system requests a file open */
|
||||||
|
|
||||||
|
/* Render events */
|
||||||
|
SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset */
|
||||||
|
|
||||||
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
|
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
|
||||||
* and should be allocated with SDL_RegisterEvents()
|
* and should be allocated with SDL_RegisterEvents()
|
||||||
*/
|
*/
|
||||||
|
@ -474,6 +474,7 @@ D3D_Reset(SDL_Renderer * renderer)
|
|||||||
{
|
{
|
||||||
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
|
SDL_Texture *texture;
|
||||||
|
|
||||||
/* Release the default render target before reset */
|
/* Release the default render target before reset */
|
||||||
if (data->defaultRenderTarget) {
|
if (data->defaultRenderTarget) {
|
||||||
@ -481,6 +482,13 @@ D3D_Reset(SDL_Renderer * renderer)
|
|||||||
data->defaultRenderTarget = NULL;
|
data->defaultRenderTarget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Release application render targets */
|
||||||
|
for (texture = renderer->textures; texture; texture = texture->next) {
|
||||||
|
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||||
|
D3D_DestroyTexture(renderer, texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result = IDirect3DDevice9_Reset(data->device, &data->pparams);
|
result = IDirect3DDevice9_Reset(data->device, &data->pparams);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
if (result == D3DERR_DEVICELOST) {
|
if (result == D3DERR_DEVICELOST) {
|
||||||
@ -491,9 +499,24 @@ D3D_Reset(SDL_Renderer * renderer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocate application render targets */
|
||||||
|
for (texture = renderer->textures; texture; texture = texture->next) {
|
||||||
|
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||||
|
D3D_CreateTexture(renderer, texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
|
IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
|
||||||
D3D_InitRenderState(data);
|
D3D_InitRenderState(data);
|
||||||
D3D_UpdateViewport(renderer);
|
D3D_UpdateViewport(renderer);
|
||||||
|
|
||||||
|
/* Let the application know that render targets were reset */
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_RENDER_TARGETS_RESET;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,8 +672,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||||||
pparams.FullScreen_RefreshRateInHz = 0;
|
pparams.FullScreen_RefreshRateInHz = 0;
|
||||||
} else {
|
} else {
|
||||||
pparams.Windowed = FALSE;
|
pparams.Windowed = FALSE;
|
||||||
pparams.FullScreen_RefreshRateInHz =
|
pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
|
||||||
fullscreen_mode.refresh_rate;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pparams.Windowed = TRUE;
|
pparams.Windowed = TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user