mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
@@ -658,7 +658,7 @@ private:
|
||||
|
||||
// Create window in window first rather than fullscreen so we have the display the window is on first
|
||||
uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
if (gConfigGeneral.drawing_engine == DRAWING_ENGINE_OPENGL)
|
||||
if (gConfigGeneral.drawing_engine == DrawingEngine::OpenGL)
|
||||
{
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
|
||||
@@ -30,17 +30,16 @@ namespace OpenRCT2
|
||||
class DrawingEngineFactory final : public IDrawingEngineFactory
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<IDrawingEngine> Create(
|
||||
DRAWING_ENGINE_TYPE type, const std::shared_ptr<IUiContext>& uiContext) override
|
||||
std::unique_ptr<IDrawingEngine> Create(DrawingEngine type, const std::shared_ptr<IUiContext>& uiContext) override
|
||||
{
|
||||
switch (static_cast<int32_t>(type))
|
||||
switch (type)
|
||||
{
|
||||
case DRAWING_ENGINE_SOFTWARE:
|
||||
case DrawingEngine::Software:
|
||||
return CreateSoftwareDrawingEngine(uiContext);
|
||||
case DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY:
|
||||
case DrawingEngine::SoftwareWithHardwareDisplay:
|
||||
return CreateHardwareDisplayDrawingEngine(uiContext);
|
||||
#ifndef DISABLE_OPENGL
|
||||
case DRAWING_ENGINE_OPENGL:
|
||||
case DrawingEngine::OpenGL:
|
||||
return CreateOpenGLDrawingEngine(uiContext);
|
||||
#endif
|
||||
default:
|
||||
|
||||
@@ -1023,7 +1023,7 @@ static void window_options_mousedown(rct_window* w, rct_widgetindex widgetIndex,
|
||||
gDropdownItemsArgs[i] = DrawingEngineStringIds[i];
|
||||
}
|
||||
window_options_show_dropdown(w, widget, numItems);
|
||||
dropdown_set_checked(gConfigGeneral.drawing_engine, true);
|
||||
dropdown_set_checked(EnumValue(gConfigGeneral.drawing_engine), true);
|
||||
break;
|
||||
}
|
||||
case WIDX_SCALE_UP:
|
||||
@@ -1334,12 +1334,12 @@ static void window_options_dropdown(rct_window* w, rct_widgetindex widgetIndex,
|
||||
}
|
||||
break;
|
||||
case WIDX_DRAWING_ENGINE_DROPDOWN:
|
||||
if (dropdownIndex != gConfigGeneral.drawing_engine)
|
||||
if (dropdownIndex != EnumValue(gConfigGeneral.drawing_engine))
|
||||
{
|
||||
int32_t srcEngine = drawing_engine_get_type();
|
||||
int32_t dstEngine = dropdownIndex;
|
||||
DrawingEngine srcEngine = drawing_engine_get_type();
|
||||
DrawingEngine dstEngine = static_cast<DrawingEngine>(dropdownIndex);
|
||||
|
||||
gConfigGeneral.drawing_engine = static_cast<uint8_t>(dstEngine);
|
||||
gConfigGeneral.drawing_engine = dstEngine;
|
||||
bool recreate_window = drawing_engine_requires_new_window(srcEngine, dstEngine);
|
||||
platform_refresh_video(recreate_window);
|
||||
config_save_default();
|
||||
@@ -1604,7 +1604,7 @@ static void window_options_invalidate(rct_window* w)
|
||||
}
|
||||
|
||||
// Disable Steam Overlay checkbox when using software rendering.
|
||||
if (gConfigGeneral.drawing_engine == DRAWING_ENGINE_SOFTWARE)
|
||||
if (gConfigGeneral.drawing_engine == DrawingEngine::Software)
|
||||
{
|
||||
w->disabled_widgets |= (1 << WIDX_STEAM_OVERLAY_PAUSE);
|
||||
}
|
||||
@@ -1615,7 +1615,7 @@ static void window_options_invalidate(rct_window* w)
|
||||
|
||||
// Disable scaling quality dropdown when using software rendering or when using an integer scalar.
|
||||
// In the latter case, nearest neighbour rendering will be used to scale.
|
||||
if (gConfigGeneral.drawing_engine == DRAWING_ENGINE_SOFTWARE
|
||||
if (gConfigGeneral.drawing_engine == DrawingEngine::Software
|
||||
|| gConfigGeneral.window_scale == std::floor(gConfigGeneral.window_scale))
|
||||
{
|
||||
w->disabled_widgets |= (1 << WIDX_SCALE_QUALITY);
|
||||
@@ -1628,7 +1628,7 @@ static void window_options_invalidate(rct_window* w)
|
||||
}
|
||||
|
||||
// Disable changing VSync for Software engine, as we can't control its use of VSync
|
||||
if (gConfigGeneral.drawing_engine == DRAWING_ENGINE_SOFTWARE)
|
||||
if (gConfigGeneral.drawing_engine == DrawingEngine::Software)
|
||||
{
|
||||
w->disabled_widgets |= (1 << WIDX_USE_VSYNC_CHECKBOX);
|
||||
}
|
||||
@@ -1647,7 +1647,8 @@ static void window_options_invalidate(rct_window* w)
|
||||
// Dropdown captions for straightforward strings.
|
||||
window_options_display_widgets[WIDX_FULLSCREEN].text = window_options_fullscreen_mode_names[gConfigGeneral
|
||||
.fullscreen_mode];
|
||||
window_options_display_widgets[WIDX_DRAWING_ENGINE].text = DrawingEngineStringIds[gConfigGeneral.drawing_engine];
|
||||
window_options_display_widgets[WIDX_DRAWING_ENGINE].text = DrawingEngineStringIds[EnumValue(
|
||||
gConfigGeneral.drawing_engine)];
|
||||
window_options_display_widgets[WIDX_SCALE_QUALITY].text = window_options_scale_quality_names
|
||||
[static_cast<int32_t>(gConfigGeneral.scale_quality) - 1];
|
||||
|
||||
@@ -1670,8 +1671,7 @@ static void window_options_invalidate(rct_window* w)
|
||||
gConfigGeneral.virtual_floor_style)];
|
||||
|
||||
widget_set_checkbox_value(w, WIDX_ENABLE_LIGHT_FX_CHECKBOX, gConfigGeneral.enable_light_fx);
|
||||
if (gConfigGeneral.day_night_cycle
|
||||
&& gConfigGeneral.drawing_engine == DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY)
|
||||
if (gConfigGeneral.day_night_cycle && gConfigGeneral.drawing_engine == DrawingEngine::SoftwareWithHardwareDisplay)
|
||||
{
|
||||
w->disabled_widgets &= ~(1 << WIDX_ENABLE_LIGHT_FX_CHECKBOX);
|
||||
}
|
||||
@@ -1682,7 +1682,7 @@ static void window_options_invalidate(rct_window* w)
|
||||
|
||||
widget_set_checkbox_value(
|
||||
w, WIDX_ENABLE_LIGHT_FX_FOR_VEHICLES_CHECKBOX, gConfigGeneral.enable_light_fx_for_vehicles);
|
||||
if (gConfigGeneral.day_night_cycle && gConfigGeneral.drawing_engine == DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY
|
||||
if (gConfigGeneral.day_night_cycle && gConfigGeneral.drawing_engine == DrawingEngine::SoftwareWithHardwareDisplay
|
||||
&& gConfigGeneral.enable_light_fx)
|
||||
{
|
||||
w->disabled_widgets &= ~(1 << WIDX_ENABLE_LIGHT_FX_FOR_VEHICLES_CHECKBOX);
|
||||
@@ -1982,7 +1982,7 @@ static void window_options_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_SCALE].left + 1, w->widgets[WIDX_SCALE].top + 1 });
|
||||
|
||||
colour = w->colours[1];
|
||||
if (gConfigGeneral.drawing_engine == DRAWING_ENGINE_SOFTWARE
|
||||
if (gConfigGeneral.drawing_engine == DrawingEngine::Software
|
||||
|| gConfigGeneral.window_scale == std::floor(gConfigGeneral.window_scale))
|
||||
{
|
||||
colour |= COLOUR_FLAG_INSET;
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace OpenRCT2
|
||||
std::unique_ptr<TitleScreen> _titleScreen;
|
||||
std::unique_ptr<GameState> _gameState;
|
||||
|
||||
int32_t _drawingEngineType = DRAWING_ENGINE_SOFTWARE;
|
||||
DrawingEngine _drawingEngineType = DrawingEngine::Software;
|
||||
std::unique_ptr<IDrawingEngine> _drawingEngine;
|
||||
std::unique_ptr<Painter> _painter;
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace OpenRCT2
|
||||
return _gameStateSnapshots.get();
|
||||
}
|
||||
|
||||
int32_t GetDrawingEngineType() override
|
||||
DrawingEngine GetDrawingEngineType() override
|
||||
{
|
||||
return _drawingEngineType;
|
||||
}
|
||||
@@ -486,13 +486,13 @@ namespace OpenRCT2
|
||||
_drawingEngineType = gConfigGeneral.drawing_engine;
|
||||
|
||||
auto drawingEngineFactory = _uiContext->GetDrawingEngineFactory();
|
||||
auto drawingEngine = drawingEngineFactory->Create(static_cast<DRAWING_ENGINE_TYPE>(_drawingEngineType), _uiContext);
|
||||
auto drawingEngine = drawingEngineFactory->Create(_drawingEngineType, _uiContext);
|
||||
|
||||
if (drawingEngine == nullptr)
|
||||
{
|
||||
if (_drawingEngineType == DRAWING_ENGINE_SOFTWARE)
|
||||
if (_drawingEngineType == DrawingEngine::Software)
|
||||
{
|
||||
_drawingEngineType = DRAWING_ENGINE_NONE;
|
||||
_drawingEngineType = DrawingEngine::None;
|
||||
log_fatal("Unable to create a drawing engine.");
|
||||
exit(-1);
|
||||
}
|
||||
@@ -501,7 +501,7 @@ namespace OpenRCT2
|
||||
log_error("Unable to create drawing engine. Falling back to software.");
|
||||
|
||||
// Fallback to software
|
||||
gConfigGeneral.drawing_engine = DRAWING_ENGINE_SOFTWARE;
|
||||
gConfigGeneral.drawing_engine = DrawingEngine::Software;
|
||||
config_save_default();
|
||||
drawing_engine_init();
|
||||
}
|
||||
@@ -516,9 +516,9 @@ namespace OpenRCT2
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
if (_drawingEngineType == DRAWING_ENGINE_SOFTWARE)
|
||||
if (_drawingEngineType == DrawingEngine::Software)
|
||||
{
|
||||
_drawingEngineType = DRAWING_ENGINE_NONE;
|
||||
_drawingEngineType = DrawingEngine::None;
|
||||
log_error(ex.what());
|
||||
log_fatal("Unable to initialise a drawing engine.");
|
||||
exit(-1);
|
||||
@@ -529,7 +529,7 @@ namespace OpenRCT2
|
||||
log_error("Unable to initialise drawing engine. Falling back to software.");
|
||||
|
||||
// Fallback to software
|
||||
gConfigGeneral.drawing_engine = DRAWING_ENGINE_SOFTWARE;
|
||||
gConfigGeneral.drawing_engine = DrawingEngine::Software;
|
||||
config_save_default();
|
||||
drawing_engine_init();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
struct IObjectManager;
|
||||
struct IObjectRepository;
|
||||
struct IScenarioRepository;
|
||||
enum class DrawingEngine : int32_t;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
struct IStream;
|
||||
@@ -125,7 +127,7 @@ namespace OpenRCT2
|
||||
virtual IScenarioRepository* GetScenarioRepository() abstract;
|
||||
virtual IReplayManager* GetReplayManager() abstract;
|
||||
virtual IGameStateSnapshots* GetGameStateSnapshots() abstract;
|
||||
virtual int32_t GetDrawingEngineType() abstract;
|
||||
virtual DrawingEngine GetDrawingEngineType() abstract;
|
||||
virtual Drawing::IDrawingEngine* GetDrawingEngine() abstract;
|
||||
virtual Paint::Painter* GetPainter() abstract;
|
||||
|
||||
|
||||
@@ -82,10 +82,10 @@ namespace Config
|
||||
ConfigEnumEntry<int32_t>("YY/DD/MM", DATE_FORMAT_YEAR_DAY_MONTH),
|
||||
});
|
||||
|
||||
static const auto Enum_DrawingEngine = ConfigEnum<int32_t>({
|
||||
ConfigEnumEntry<int32_t>("SOFTWARE", DRAWING_ENGINE_SOFTWARE),
|
||||
ConfigEnumEntry<int32_t>("SOFTWARE_HWD", DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY),
|
||||
ConfigEnumEntry<int32_t>("OPENGL", DRAWING_ENGINE_OPENGL),
|
||||
static const auto Enum_DrawingEngine = ConfigEnum<DrawingEngine>({
|
||||
ConfigEnumEntry<DrawingEngine>("SOFTWARE", DrawingEngine::Software),
|
||||
ConfigEnumEntry<DrawingEngine>("SOFTWARE_HWD", DrawingEngine::SoftwareWithHardwareDisplay),
|
||||
ConfigEnumEntry<DrawingEngine>("OPENGL", DrawingEngine::OpenGL),
|
||||
});
|
||||
|
||||
static const auto Enum_Temperature = ConfigEnum<TemperatureUnit>({
|
||||
@@ -168,7 +168,8 @@ namespace Config
|
||||
model->window_snap_proximity = reader->GetInt32("window_snap_proximity", 5);
|
||||
model->window_width = reader->GetInt32("window_width", -1);
|
||||
model->default_display = reader->GetInt32("default_display", 0);
|
||||
model->drawing_engine = reader->GetEnum<int32_t>("drawing_engine", DRAWING_ENGINE_SOFTWARE, Enum_DrawingEngine);
|
||||
model->drawing_engine = reader->GetEnum<DrawingEngine>(
|
||||
"drawing_engine", DrawingEngine::Software, Enum_DrawingEngine);
|
||||
model->uncap_fps = reader->GetBoolean("uncap_fps", false);
|
||||
model->use_vsync = reader->GetBoolean("use_vsync", true);
|
||||
model->virtual_floor_style = reader->GetEnum<VirtualFloorStyles>(
|
||||
@@ -249,7 +250,7 @@ namespace Config
|
||||
writer->WriteInt32("window_snap_proximity", model->window_snap_proximity);
|
||||
writer->WriteInt32("window_width", model->window_width);
|
||||
writer->WriteInt32("default_display", model->default_display);
|
||||
writer->WriteEnum<int32_t>("drawing_engine", model->drawing_engine, Enum_DrawingEngine);
|
||||
writer->WriteEnum<DrawingEngine>("drawing_engine", model->drawing_engine, Enum_DrawingEngine);
|
||||
writer->WriteBoolean("uncap_fps", model->uncap_fps);
|
||||
writer->WriteBoolean("use_vsync", model->use_vsync);
|
||||
writer->WriteEnum<int32_t>("date_format", model->date_format, Enum_DateFormat);
|
||||
|
||||
@@ -19,6 +19,7 @@ enum class MeasurementFormat : int32_t;
|
||||
enum class TemperatureUnit : int32_t;
|
||||
enum class ScaleQuality : int32_t;
|
||||
enum class VirtualFloorStyles : int32_t;
|
||||
enum class DrawingEngine : int32_t;
|
||||
|
||||
struct GeneralConfiguration
|
||||
{
|
||||
@@ -34,7 +35,7 @@ struct GeneralConfiguration
|
||||
int32_t fullscreen_width;
|
||||
int32_t fullscreen_height;
|
||||
float window_scale;
|
||||
int32_t drawing_engine;
|
||||
DrawingEngine drawing_engine;
|
||||
ScaleQuality scale_quality;
|
||||
bool uncap_fps;
|
||||
bool use_vsync;
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
enum DRAWING_ENGINE
|
||||
enum class DrawingEngine : int32_t
|
||||
{
|
||||
DRAWING_ENGINE_NONE = -1,
|
||||
DRAWING_ENGINE_SOFTWARE,
|
||||
DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY,
|
||||
DRAWING_ENGINE_OPENGL,
|
||||
DRAWING_ENGINE_COUNT,
|
||||
None = -1,
|
||||
Software,
|
||||
SoftwareWithHardwareDisplay,
|
||||
OpenGL,
|
||||
Count,
|
||||
};
|
||||
|
||||
enum DRAWING_ENGINE_FLAGS
|
||||
@@ -43,7 +43,6 @@ namespace OpenRCT2::Ui
|
||||
|
||||
namespace OpenRCT2::Drawing
|
||||
{
|
||||
enum class DRAWING_ENGINE_TYPE;
|
||||
struct IDrawingContext;
|
||||
|
||||
struct IDrawingEngine
|
||||
@@ -81,7 +80,7 @@ namespace OpenRCT2::Drawing
|
||||
{
|
||||
}
|
||||
virtual std::unique_ptr<IDrawingEngine> Create(
|
||||
DRAWING_ENGINE_TYPE type, const std::shared_ptr<OpenRCT2::Ui::IUiContext>& uiContext) abstract;
|
||||
DrawingEngine type, const std::shared_ptr<OpenRCT2::Ui::IUiContext>& uiContext) abstract;
|
||||
};
|
||||
|
||||
struct IWeatherDrawer
|
||||
|
||||
@@ -33,7 +33,7 @@ rct_string_id DrawingEngineStringIds[] = {
|
||||
STR_DRAWING_ENGINE_OPENGL,
|
||||
};
|
||||
|
||||
int32_t drawing_engine_get_type()
|
||||
DrawingEngine drawing_engine_get_type()
|
||||
{
|
||||
auto context = GetContext();
|
||||
return context->GetDrawingEngineType();
|
||||
@@ -50,10 +50,10 @@ static IDrawingEngine* GetDrawingEngine()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool drawing_engine_requires_new_window(int32_t srcEngine, int32_t dstEngine)
|
||||
bool drawing_engine_requires_new_window(DrawingEngine srcEngine, DrawingEngine dstEngine)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (srcEngine != DRAWING_ENGINE_OPENGL && dstEngine != DRAWING_ENGINE_OPENGL)
|
||||
if (srcEngine != DrawingEngine::OpenGL && dstEngine != DrawingEngine::OpenGL)
|
||||
{
|
||||
// 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
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
|
||||
struct rct_drawpixelinfo;
|
||||
struct GamePalette;
|
||||
enum class DrawingEngine : int32_t;
|
||||
|
||||
extern rct_string_id DrawingEngineStringIds[3];
|
||||
|
||||
int32_t drawing_engine_get_type();
|
||||
bool drawing_engine_requires_new_window(int32_t srcEngine, int32_t dstEngine);
|
||||
DrawingEngine drawing_engine_get_type();
|
||||
bool drawing_engine_requires_new_window(DrawingEngine srcEngine, DrawingEngine dstEngine);
|
||||
void drawing_engine_init();
|
||||
void drawing_engine_resize();
|
||||
void drawing_engine_set_palette(const GamePalette& colours);
|
||||
|
||||
@@ -495,7 +495,7 @@ static void benchgfx_render_screenshots(const char* inputPath, std::unique_ptr<I
|
||||
}
|
||||
|
||||
const double average = totalTime / static_cast<double>(totalRenderCount);
|
||||
const auto engineStringId = DrawingEngineStringIds[DRAWING_ENGINE_SOFTWARE];
|
||||
const auto engineStringId = DrawingEngineStringIds[EnumValue(DrawingEngine::Software)];
|
||||
const auto engineName = format_string(engineStringId, nullptr);
|
||||
std::printf("Engine: %s\n", engineName.c_str());
|
||||
std::printf("Render Count: %u\n", totalRenderCount);
|
||||
|
||||
@@ -1930,7 +1930,7 @@ void viewport_set_saved_view()
|
||||
|
||||
ZoomLevel ZoomLevel::min()
|
||||
{
|
||||
if (drawing_engine_get_type() == DRAWING_ENGINE_OPENGL)
|
||||
if (drawing_engine_get_type() == DrawingEngine::OpenGL)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace OpenRCT2::Ui
|
||||
class X8DrawingEngineFactory final : public IDrawingEngineFactory
|
||||
{
|
||||
std::unique_ptr<IDrawingEngine> Create(
|
||||
[[maybe_unused]] DRAWING_ENGINE_TYPE type, const std::shared_ptr<IUiContext>& uiContext) override
|
||||
[[maybe_unused]] DrawingEngine type, const std::shared_ptr<IUiContext>& uiContext) override
|
||||
{
|
||||
return std::make_unique<X8DrawingEngine>(uiContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user