Skip to content

Commit

Permalink
vulkan_sdl2: Size autodetect when :size=-1x-1
Browse files Browse the repository at this point in the history
Useful when running without WM (GH364). Perhaps we could eventually use
this behaviour for fullscreen by default (since we already do something
similar in the glfw display).
  • Loading branch information
mpiatka committed Dec 6, 2023
1 parent ad6743f commit cc3c06c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/video_display/vulkan/vulkan_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,19 @@ void* display_vulkan_init(module* parent, const char* fmt, unsigned int flags) {

int x = (args.x == SDL_WINDOWPOS_UNDEFINED ? SDL_WINDOWPOS_CENTERED_DISPLAY(args.display_idx) : args.x);
int y = (args.y == SDL_WINDOWPOS_UNDEFINED ? SDL_WINDOWPOS_CENTERED_DISPLAY(args.display_idx) : args.y);
if(s->width == -1 && s->height == -1){
SDL_DisplayMode mode;
int display_index = 0;
if(SDL_GetDesktopDisplayMode(display_index, &mode)){
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Failed to get display size\n");
mode.w = 0;
mode.h = 0;
}
s->width = mode.w;
s->height = mode.h;

log_msg(LOG_LEVEL_INFO, MOD_NAME "Detected display size: %dx%d\n", mode.w, mode.h);
}
if (s->width == 0) s->width = 960;
if (s->height == 0) s->height = 540;

Expand Down

0 comments on commit cc3c06c

Please sign in to comment.