mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Viewporrt. Examples: DirectX10,11: Make the platform SetWindowSize handler not crash on failure to resize, which could happen (rarely) on invalid data or bug in the code.
This commit is contained in:
parent
637d9c42bf
commit
17a7f352b5
@ -23,6 +23,7 @@
|
|||||||
#include "imgui_impl_dx10.h"
|
#include "imgui_impl_dx10.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
|
#include <stdio.h>
|
||||||
#include <d3d10_1.h>
|
#include <d3d10_1.h>
|
||||||
#include <d3d10.h>
|
#include <d3d10.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
@ -581,6 +582,11 @@ static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
|||||||
ID3D10Texture2D* pBackBuffer = NULL;
|
ID3D10Texture2D* pBackBuffer = NULL;
|
||||||
data->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
data->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
data->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
data->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
if (pBackBuffer == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ImGui_ImplDX10_SetWindowSize() can't created buffers.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &data->RTView);
|
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &data->RTView);
|
||||||
pBackBuffer->Release();
|
pBackBuffer->Release();
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "imgui_impl_dx11.h"
|
#include "imgui_impl_dx11.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
|
#include <stdio.h>
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
|
|
||||||
@ -588,6 +589,11 @@ static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
|||||||
ID3D11Texture2D* pBackBuffer = NULL;
|
ID3D11Texture2D* pBackBuffer = NULL;
|
||||||
data->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
data->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
data->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
data->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
if (pBackBuffer == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ImGui_ImplDX11_SetWindowSize() can't created buffers.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &data->RTView);
|
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &data->RTView);
|
||||||
pBackBuffer->Release();
|
pBackBuffer->Release();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user