diff --git a/include/setup.h b/include/setup.h index 417fc112..68f4c135 100644 --- a/include/setup.h +++ b/include/setup.h @@ -123,6 +123,7 @@ public: Property(std::string const& _propname, Changeable::Value when):propname(_propname),change(when) { } void Set_values(const char * const * in); + void Set_values(const std::vector &in); void Set_help(std::string const& str); char const* Get_help(); virtual bool SetValue(std::string const& str)=0; diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index e14fcf0b..6766f861 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -1731,6 +1731,21 @@ void GFX_ShowMsg(char const* format,...) { if (!no_stdout) puts(buf); //Else buf is parsed again. (puts adds end of line) } +static std::vector Get_SDL_TextureRenderers() +{ + const int n = SDL_GetNumRenderDrivers(); + std::vector drivers; + drivers.reserve(n + 1); + drivers.push_back("auto"); + SDL_RendererInfo info; + for (int i = 0; i < n; i++) { + if (SDL_GetRenderDriverInfo(i, &info)) + continue; + if (info.flags & SDL_RENDERER_TARGETTEXTURE) + drivers.push_back(info.name); + } + return drivers; +} void Config_Add_SDL() { Section_prop * sdl_sec=control->AddSection_prop("sdl",&GUI_StartUp); @@ -1772,25 +1787,12 @@ void Config_Add_SDL() { Pstring->Set_help("What video system to use for output."); Pstring->Set_values(outputs); - const char *renderers[] = { - "auto", -#ifdef WIN32 - "direct3d", -#endif - "opengl", -#ifdef MACOSX - "metal", -#endif - "software", - 0 - }; - Pstring = sdl_sec->Add_string("texture_renderer", Property::Changeable::Always, "auto"); Pstring->Set_help("Choose a renderer driver if output=texture or texturenb.\n" "Use output=auto for an automatic choice."); - Pstring->Set_values(renderers); + Pstring->Set_values(Get_SDL_TextureRenderers()); Pbool = sdl_sec->Add_bool("autolock",Property::Changeable::Always,true); Pbool->Set_help("Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock)"); diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index db746cc9..afc5c5a7 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -508,6 +508,14 @@ void Property::Set_values(const char * const *in) { } } +void Property::Set_values(const std::vector & in) { + Value::Etype type = default_value.type; + for (auto &str : in) { + Value val(str, type); + suggested_values.push_back(val); + } +} + Prop_int* Section_prop::Add_int(string const& _propname, Property::Changeable::Value when, int _value) { Prop_int* test=new Prop_int(_propname,when,_value); properties.push_back(test);