Skip to content

Commit 805a549

Browse files
authored
Adds debug output of the render driver (#93)
The game was crashing on windows. Probably due to the render/driver/gpu combo which was chosen at startup. This patch adds output for this data in debug mode in an attempt to figure out the cause of the crash.
1 parent 410eb74 commit 805a549

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/main.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,23 @@ bool initSDL(void)
171171
return false;
172172
}
173173

174+
#ifdef DEBUG
175+
/* Dump the renderer info */
176+
const char *renderer_name = SDL_GetRendererName(gRenderer);
177+
if (renderer_name != NULL) {
178+
debug("Renderer: %s", renderer_name);
179+
if (SDL_strcmp("gpu", renderer_name) == 0) {
180+
SDL_GPUDevice *device =
181+
SDL_GetPointerProperty(SDL_GetRendererProperties(gRenderer),
182+
SDL_PROP_RENDERER_GPU_DEVICE_POINTER,
183+
NULL);
184+
debug(" Driver: %s", SDL_GetGPUDeviceDriver(device));
185+
}
186+
} else {
187+
error("Unable to get renderer name: %s", SDL_GetError());
188+
}
189+
#endif
190+
174191
if (SDL_TextInputActive(gWindow)) {
175192
debug("Disabling text input");
176193
SDL_StopTextInput(gWindow);
@@ -1373,7 +1390,7 @@ validate_lib_checksum(void)
13731390
fatal("Unable to open %s for reading\n", file);
13741391
}
13751392

1376-
unsigned calculated = checksum_fp(fp);
1393+
unsigned calculated = checksum_fp(fp);
13771394
fclose(fp);
13781395

13791396
if (calculated != expected) {
@@ -1409,7 +1426,7 @@ int main(int argc, char *argv[])
14091426
return -1;
14101427

14111428
if (settings_get()->fullscreen_enabled) {
1412-
// Game starts in windowed mode so this will
1429+
// Game starts in windowed mode so this will
14131430
// change to fullscreen
14141431
toggle_fullscreen();
14151432
}

0 commit comments

Comments
 (0)