|
@@ -11,7 +11,7 @@
|
|
#include "imgui_impl_sdl3.h"
|
|
#include "imgui_impl_sdl3.h"
|
|
#include "imgui_impl_dx11.h"
|
|
#include "imgui_impl_dx11.h"
|
|
#include <d3d11.h>
|
|
#include <d3d11.h>
|
|
-#include <stdio.h>
|
|
|
|
|
|
+#include <stdio.h> // printf
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL.h>
|
|
|
|
|
|
// Data
|
|
// Data
|
|
@@ -40,7 +40,7 @@ int main(int, char**)
|
|
// Setup window
|
|
// Setup window
|
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
|
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
|
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
|
- SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+DirectX11 example", (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
|
|
|
|
|
+ SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+DirectX11 example", (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
|
if (window == nullptr)
|
|
if (window == nullptr)
|
|
{
|
|
{
|
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
|
@@ -54,7 +54,7 @@ int main(int, char**)
|
|
if (!CreateDeviceD3D(hwnd))
|
|
if (!CreateDeviceD3D(hwnd))
|
|
{
|
|
{
|
|
CleanupDeviceD3D();
|
|
CleanupDeviceD3D();
|
|
- return 1;
|
|
|
|
|
|
+ return -1;
|
|
}
|
|
}
|
|
|
|
|
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
|
@@ -189,6 +189,7 @@ int main(int, char**)
|
|
}
|
|
}
|
|
|
|
|
|
// Cleanup
|
|
// Cleanup
|
|
|
|
+ // [If using SDL_MAIN_USE_CALLBACKS: all code below would likely be your SDL_AppQuit() function]
|
|
ImGui_ImplDX11_Shutdown();
|
|
ImGui_ImplDX11_Shutdown();
|
|
ImGui_ImplSDL3_Shutdown();
|
|
ImGui_ImplSDL3_Shutdown();
|
|
ImGui::DestroyContext();
|
|
ImGui::DestroyContext();
|
|
@@ -224,7 +225,10 @@ bool CreateDeviceD3D(HWND hWnd)
|
|
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
|
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
|
D3D_FEATURE_LEVEL featureLevel;
|
|
D3D_FEATURE_LEVEL featureLevel;
|
|
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
|
|
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
|
|
- if (D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
|
|
|
|
|
|
+ HRESULT res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext);
|
|
|
|
+ if (res == DXGI_ERROR_UNSUPPORTED) // Try high-performance WARP software driver if hardware is not available.
|
|
|
|
+ res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_WARP, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext);
|
|
|
|
+ if (res != S_OK)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
CreateRenderTarget();
|
|
CreateRenderTarget();
|