Improve crash dialogs when can't start game due to system being unable to support the current graphics backend

This commit is contained in:
UnknownShadow200 2022-03-19 11:07:05 +11:00
parent 3cb69128b1
commit 626a46d592
6 changed files with 21 additions and 11 deletions

View File

@ -36,9 +36,9 @@ build_win32() {
cp $ROOT_DIR/misc/CCicon_32.res $ROOT_DIR/src/CCicon_32.res
rm cc-w32-d3d.exe cc-w32-ogl.exe
$WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-d3d.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32
$WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-d3d.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -lwininet -lwinmm -limagehlp
if [ $? -ne 0 ]; then echo "Failed to compile Windows 32 bit" >> "$ERRS_FILE"; fi
$WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-ogl.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -lopengl32
$WIN32_CC *.c $ALL_FLAGS $WIN32_FLAGS -o cc-w32-ogl.exe CCicon_32.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lwininet -lwinmm -limagehlp -lopengl32
if [ $? -ne 0 ]; then echo "Failed to compile Windows 32 bit (OpenGL)" >> "$ERRS_FILE"; fi
}
@ -47,9 +47,9 @@ build_win64() {
cp $ROOT_DIR/misc/CCicon_64.res $ROOT_DIR/src/CCicon_64.res
rm cc-w64-d3d.exe cc-w64-ogl.exe
$WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-d3d.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32
$WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-d3d.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -lwininet -lwinmm -limagehlp
if [ $? -ne 0 ]; then echo "Failed to compile Windows 64 bit" >> "$ERRS_FILE"; fi
$WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-ogl.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -lopengl32
$WIN64_CC *.c $ALL_FLAGS $WIN64_FLAGS -o cc-w64-ogl.exe CCicon_64.res -DCC_COMMIT_SHA=\"$LATEST\" -DCC_BUILD_MANUAL -DCC_BUILD_WIN -DCC_BUILD_GL -DCC_BUILD_WINGUI -DCC_BUILD_WGL -DCC_BUILD_WINMM -DCC_BUILD_WININET -lwininet -lwinmm -limagehlp -lopengl32
if [ $? -ne 0 ]; then echo "Failed to compile Windows 64 bit (OpenGL)" >> "$ERRS_FILE"; fi
}

View File

@ -59,7 +59,7 @@ static void LoadD3D11Library(void) {
if (!lib) {
Logger_DynamicLibWarn("loading", &path);
Logger_Abort("Failed to load d3d11.dll. You may need to install Direct3D11.\n\nNOTE: Direct3D11 requires Windows 7 or later\nYou may need to use the Direct3D9 version instead.\n");
Logger_FailToStart("Failed to load d3d11.dll. You may need to install Direct3D11.\n\nNOTE: Direct3D11 requires Windows 7 or later\nYou may need to use the Direct3D9 version instead.\n");
}
DynamicLib_GetAll(lib, funcs, Array_Elems(funcs));
}
@ -96,7 +96,7 @@ static void CreateDeviceAndSwapChain(void) {
// https://github.com/MonoGame/MonoGame/issues/5789
// I decided to just not support GPUs that do not support at least feature level 10
if (fl < D3D_FEATURE_LEVEL_10_0)
Logger_Abort("Your GPU is too old to support the Direct3D11 version.\nTry using the Direct3D9 version instead.\n");
Logger_FailToStart("Your GPU is too old to support the Direct3D11 version.\nTry using the Direct3D9 version instead.\n");
// https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_texture2d_desc
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-limits

View File

@ -63,7 +63,7 @@ static void LoadD3D9Library(void) {
if (!lib) {
Logger_DynamicLibWarn("loading", &path);
Logger_Abort("Failed to load d3d9.dll. You may need to install Direct3D9.");
Logger_FailToStart("Failed to load d3d9.dll. You may need to install Direct3D9.");
}
DynamicLib_GetAll(lib, funcs, Array_Elems(funcs));
}
@ -83,10 +83,10 @@ static void FindCompatibleViewFormat(void) {
for (i = 0; i < Array_Elems(formats); i++) {
viewFormat = formats[i];
res = IDirect3D9_CheckDeviceType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, viewFormat, viewFormat, true);
res = IDirect3D9_CheckDeviceType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_SW, viewFormat, viewFormat, true);
if (!res) return;
}
Logger_Abort("Failed to create back buffer. Graphics drivers may not be installed.");
Logger_FailToStart("Failed to create back buffer. Graphics drivers may not be installed.\n\nIf that still does not work, try the OpenGL build instead");
}
static void FindCompatibleDepthFormat(void) {
@ -99,7 +99,7 @@ static void FindCompatibleDepthFormat(void) {
res = IDirect3D9_CheckDepthStencilMatch(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, viewFormat, viewFormat, depthFormat);
if (!res) return;
}
Logger_Abort("Failed to create depth buffer. Graphics drivers may not be installed.");
Logger_FailToStart("Failed to create depth buffer. Graphics drivers may not be installed.\n\nIf that still does not work, try the OpenGL build instead");
}
static void D3D9_FillPresentArgs(D3DPRESENT_PARAMETERS* args) {

View File

@ -558,7 +558,7 @@ static void OpenGL11Fallback(void) {
#else
/* No point in even trying for other systems */
static void OpenGL11Fallback(void) {
Logger_Abort("Only OpenGL 1.1 supported.\n\n" \
Logger_FailToStart("Only OpenGL 1.1 supported.\n\n" \
"Compile the game with CC_BUILD_GL11, or ask on the ClassiCube forums for it");
}
#endif

View File

@ -984,3 +984,12 @@ static void AbortCommon(cc_result result, const char* raw_msg, void* ctx) {
}
void Logger_Abort(const char* raw_msg) { Logger_Abort2(0, raw_msg); }
void Logger_FailToStart(const char* raw_msg) {
cc_string msg = String_FromReadonly(raw_msg);
Window_ShowDialog("Failed to start ClassiCube", raw_msg);
LogCrashHeader();
Logger_Log(&msg);
Process_Exit(1);
}

View File

@ -52,4 +52,5 @@ void Logger_Abort(const char* raw_msg);
/* Displays a message box with raw_msg body, logs state to disc, then immediately terminates/quits. */
/* Typically used to abort due to an unrecoverable error. (e.g. out of memory) */
CC_NOINLINE void Logger_Abort2(cc_result result, const char* raw_msg);
void Logger_FailToStart(const char* raw_msg);
#endif