|
|
|
@ -19,13 +19,13 @@ SDL_bool sdl_init_and_configure(void) {
|
|
|
|
|
|
|
|
|
|
// Bilinear resizing
|
|
|
|
|
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1")) {
|
|
|
|
|
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not enable bilinear filtering");
|
|
|
|
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not enable bilinear filtering");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
|
|
|
|
// Handle a click to gain focus as any other click
|
|
|
|
|
if (!SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1")) {
|
|
|
|
|
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not enable mouse focus clickthrough");
|
|
|
|
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not enable mouse focus clickthrough");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -73,7 +73,7 @@ static SDL_bool get_preferred_display_bounds(struct size *bounds) {
|
|
|
|
|
# define GET_DISPLAY_BOUNDS(i, r) SDL_GetDisplayBounds((i), (r))
|
|
|
|
|
#endif
|
|
|
|
|
if (GET_DISPLAY_BOUNDS(0, &rect)) {
|
|
|
|
|
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Could not get display usable bounds: %s", SDL_GetError());
|
|
|
|
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not get display usable bounds: %s", SDL_GetError());
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -137,26 +137,26 @@ SDL_bool screen_init_rendering(struct screen *screen, const char *device_name, s
|
|
|
|
|
screen->window = SDL_CreateWindow(device_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
|
window_size.width, window_size.height, SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE);
|
|
|
|
|
if (!screen->window) {
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not create window: %s", SDL_GetError());
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create window: %s", SDL_GetError());
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screen->renderer = SDL_CreateRenderer(screen->window, -1, SDL_RENDERER_ACCELERATED);
|
|
|
|
|
if (!screen->renderer) {
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Could not create renderer: %s", SDL_GetError());
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create renderer: %s", SDL_GetError());
|
|
|
|
|
screen_destroy(screen);
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (SDL_RenderSetLogicalSize(screen->renderer, frame_size.width, frame_size.height)) {
|
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Could not set renderer logical size: %s", SDL_GetError());
|
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not set renderer logical size: %s", SDL_GetError());
|
|
|
|
|
screen_destroy(screen);
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_Surface *icon = read_xpm(icon_xpm);
|
|
|
|
|
if (!icon) {
|
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not load icon: %s", SDL_GetError());
|
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load icon: %s", SDL_GetError());
|
|
|
|
|
screen_destroy(screen);
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
@ -167,7 +167,7 @@ SDL_bool screen_init_rendering(struct screen *screen, const char *device_name, s
|
|
|
|
|
screen->texture = SDL_CreateTexture(screen->renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING,
|
|
|
|
|
frame_size.width, frame_size.height);
|
|
|
|
|
if (!screen->texture) {
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Could not create texture: %s", SDL_GetError());
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture: %s", SDL_GetError());
|
|
|
|
|
screen_destroy(screen);
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
@ -196,7 +196,7 @@ void screen_destroy(struct screen *screen) {
|
|
|
|
|
static SDL_bool prepare_for_frame(struct screen *screen, struct size new_frame_size) {
|
|
|
|
|
if (screen->frame_size.width != new_frame_size.width || screen->frame_size.height != new_frame_size.height) {
|
|
|
|
|
if (SDL_RenderSetLogicalSize(screen->renderer, new_frame_size.width, new_frame_size.height)) {
|
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Could not set renderer logical size: %s", SDL_GetError());
|
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not set renderer logical size: %s", SDL_GetError());
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -218,7 +218,7 @@ static SDL_bool prepare_for_frame(struct screen *screen, struct size new_frame_s
|
|
|
|
|
screen->texture = SDL_CreateTexture(screen->renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING,
|
|
|
|
|
new_frame_size.width, new_frame_size.height);
|
|
|
|
|
if (!screen->texture) {
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Could not create texture: %s", SDL_GetError());
|
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture: %s", SDL_GetError());
|
|
|
|
|
return SDL_FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|