mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Merge pull request #2038 from HaasJona/restart_required
Require a restart after changing hardware rendering
This commit is contained in:
@@ -3896,6 +3896,7 @@ STR_5554 :{SMALLFONT}{BLACK}Enable mountain tool
|
|||||||
STR_5555 :Show vehicles from other track types
|
STR_5555 :Show vehicles from other track types
|
||||||
STR_5556 :Kick Player
|
STR_5556 :Kick Player
|
||||||
STR_5557 :Stay connected after desynchronisation (Multiplayer)
|
STR_5557 :Stay connected after desynchronisation (Multiplayer)
|
||||||
|
STR_5558 :A restart is required for this setting to take effect
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# Rides/attractions #
|
# Rides/attractions #
|
||||||
|
|||||||
@@ -2143,6 +2143,9 @@ enum {
|
|||||||
STR_KICK_PLAYER = 5556,
|
STR_KICK_PLAYER = 5556,
|
||||||
STR_STAY_CONNECTED_AFTER_DESYNC = 5557,
|
STR_STAY_CONNECTED_AFTER_DESYNC = 5557,
|
||||||
|
|
||||||
|
STR_RESTART_REQUIRED = 5558,
|
||||||
|
|
||||||
|
|
||||||
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
|
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
|
||||||
STR_COUNT = 32768
|
STR_COUNT = 32768
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ extern int gNumResolutions;
|
|||||||
extern resolution *gResolutions;
|
extern resolution *gResolutions;
|
||||||
extern SDL_Window *gWindow;
|
extern SDL_Window *gWindow;
|
||||||
|
|
||||||
|
extern bool gHardwareDisplay;
|
||||||
|
|
||||||
extern bool gSteamOverlayActive;
|
extern bool gSteamOverlayActive;
|
||||||
|
|
||||||
// Platform shared definitions
|
// Platform shared definitions
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ SDL_Texture *gBufferTexture = NULL;
|
|||||||
SDL_PixelFormat *gBufferTextureFormat = NULL;
|
SDL_PixelFormat *gBufferTextureFormat = NULL;
|
||||||
SDL_Color gPalette[256];
|
SDL_Color gPalette[256];
|
||||||
uint32 gPaletteHWMapped[256];
|
uint32 gPaletteHWMapped[256];
|
||||||
|
bool gHardwareDisplay;
|
||||||
|
|
||||||
bool gSteamOverlayActive = false;
|
bool gSteamOverlayActive = false;
|
||||||
|
|
||||||
@@ -224,7 +225,7 @@ void platform_draw()
|
|||||||
int height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);
|
int height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);
|
||||||
|
|
||||||
if (!gOpenRCT2Headless) {
|
if (!gOpenRCT2Headless) {
|
||||||
if (gConfigGeneral.hardware_display) {
|
if (gHardwareDisplay) {
|
||||||
void *pixels;
|
void *pixels;
|
||||||
int pitch;
|
int pitch;
|
||||||
if (SDL_LockTexture(gBufferTexture, NULL, &pixels, &pitch) == 0) {
|
if (SDL_LockTexture(gBufferTexture, NULL, &pixels, &pitch) == 0) {
|
||||||
@@ -371,7 +372,7 @@ void platform_update_palette(const uint8* colours, int start_index, int num_colo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gOpenRCT2Headless && !gConfigGeneral.hardware_display) {
|
if (!gOpenRCT2Headless && !gHardwareDisplay) {
|
||||||
surface = SDL_GetWindowSurface(gWindow);
|
surface = SDL_GetWindowSurface(gWindow);
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
log_fatal("SDL_GetWindowSurface failed %s", SDL_GetError());
|
log_fatal("SDL_GetWindowSurface failed %s", SDL_GetError());
|
||||||
@@ -674,6 +675,8 @@ static void platform_create_window()
|
|||||||
|
|
||||||
RCT2_GLOBAL(0x009E2D8C, sint32) = 0;
|
RCT2_GLOBAL(0x009E2D8C, sint32) = 0;
|
||||||
|
|
||||||
|
gHardwareDisplay = gConfigGeneral.hardware_display;
|
||||||
|
|
||||||
// Create window in window first rather than fullscreen so we have the display the window is on first
|
// Create window in window first rather than fullscreen so we have the display the window is on first
|
||||||
gWindow = SDL_CreateWindow(
|
gWindow = SDL_CreateWindow(
|
||||||
"OpenRCT2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_RESIZABLE
|
"OpenRCT2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_RESIZABLE
|
||||||
@@ -858,13 +861,18 @@ void platform_refresh_video()
|
|||||||
|
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, gConfigGeneral.minimize_fullscreen_focus_loss ? "1" : "0");
|
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, gConfigGeneral.minimize_fullscreen_focus_loss ? "1" : "0");
|
||||||
|
|
||||||
if (gConfigGeneral.hardware_display) {
|
log_verbose("HardwareDisplay: %s", gHardwareDisplay ? "true" : "false");
|
||||||
|
|
||||||
|
if (gHardwareDisplay) {
|
||||||
if (gRenderer == NULL)
|
if (gRenderer == NULL)
|
||||||
gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||||
|
|
||||||
if (gRenderer == NULL) {
|
if (gRenderer == NULL) {
|
||||||
log_fatal("SDL_CreateRenderer %s", SDL_GetError());
|
log_warning("SDL_CreateRenderer failed: %s", SDL_GetError());
|
||||||
exit(-1);
|
log_warning("Falling back to software rendering...");
|
||||||
|
gHardwareDisplay = false;
|
||||||
|
platform_refresh_video(); // try again without hardware rendering
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gBufferTexture != NULL)
|
if (gBufferTexture != NULL)
|
||||||
|
|||||||
@@ -493,7 +493,16 @@ static void window_options_mouseup(rct_window *w, int widgetIndex)
|
|||||||
break;
|
break;
|
||||||
case WIDX_HARDWARE_DISPLAY_CHECKBOX:
|
case WIDX_HARDWARE_DISPLAY_CHECKBOX:
|
||||||
gConfigGeneral.hardware_display ^= 1;
|
gConfigGeneral.hardware_display ^= 1;
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Windows is apparently able to switch to hardware rendering on the fly although
|
||||||
|
// using the same window in an unaccelerated and accelerated context is unsupported by SDL2
|
||||||
|
gHardwareDisplay = gConfigGeneral.hardware_display;
|
||||||
platform_refresh_video();
|
platform_refresh_video();
|
||||||
|
#else
|
||||||
|
// Linux requires a restart. This could be improved in the future by recreating the window,
|
||||||
|
// https://github.com/OpenRCT2/OpenRCT2/issues/2015
|
||||||
|
window_error_open(STR_RESTART_REQUIRED, STR_NONE);
|
||||||
|
#endif
|
||||||
config_save_default();
|
config_save_default();
|
||||||
window_invalidate(w);
|
window_invalidate(w);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user