diff --git a/src/global/TextUtils.cpp b/src/global/TextUtils.cpp index f7b63de9c..f95255146 100644 --- a/src/global/TextUtils.cpp +++ b/src/global/TextUtils.cpp @@ -6,10 +6,13 @@ #include "Charset.h" #include "Consts.h" +#include "RAII.h" #include "tests.h" +#include #include #include +#include #include #include @@ -39,6 +42,15 @@ bool isAbbrev(const std::string_view abbr, const std::string_view fullText) } namespace text_utils { + +std::string formatFloatClassic(const float val) +{ + std::ostringstream ss; + ss.imbue(std::locale::classic()); + ss << std::showpoint << val; + return ss.str(); +} + SplitResult split_at(const std::string_view sv, const size_t pos) { assert(pos <= sv.size()); @@ -216,6 +228,23 @@ void testTrim() } } +void testFormatFloatClassic() +{ + const char *oldLocale = std::setlocale(LC_ALL, nullptr); + const std::string savedLocale = oldLocale ? oldLocale : "C"; + RAIICallback restoreLocale{[savedLocale]() { std::setlocale(LC_ALL, savedLocale.c_str()); }}; + + std::setlocale(LC_ALL, "de_DE.UTF-8"); + + const std::string radStr = text_utils::formatFloatClassic(14.0f); + TEST_ASSERT(radStr.find(',') == std::string::npos); + TEST_ASSERT(radStr.find('.') != std::string::npos); + + const std::string extStr = text_utils::formatFloatClassic(28.5f); + TEST_ASSERT(extStr.find(',') == std::string::npos); + TEST_ASSERT(extStr.find('.') != std::string::npos); +} + } // namespace namespace test { @@ -223,5 +252,6 @@ void testTextUtils() { testPrefixSuffix(); testTrim(); + testFormatFloatClassic(); } } // namespace test diff --git a/src/global/TextUtils.h b/src/global/TextUtils.h index 0e680a9a1..81f1ffa37 100644 --- a/src/global/TextUtils.h +++ b/src/global/TextUtils.h @@ -19,6 +19,8 @@ NODISCARD extern bool isAbbrev(std::string_view abbr, std::string_view fullText) namespace text_utils { +NODISCARD std::string formatFloatClassic(float val); + template struct NODISCARD SplitResult final { diff --git a/src/opengl/legacy/ShaderUtils.cpp b/src/opengl/legacy/ShaderUtils.cpp index 0d107e85d..0fe8ad8dd 100644 --- a/src/opengl/legacy/ShaderUtils.cpp +++ b/src/opengl/legacy/ShaderUtils.cpp @@ -224,15 +224,19 @@ NODISCARD static GLuint compileShader(Functions &gl, const GLenum type, const So std::string defineNamedColors = "#define MAX_NAMED_COLORS " + std::to_string(MAX_NAMED_COLORS) + "\n"; std::string defineWeatherRadius = "#define WEATHER_RADIUS " - + std::to_string(WeatherConstants::WEATHER_RADIUS) + "\n"; + + text_utils::formatFloatClassic( + WeatherConstants::WEATHER_RADIUS) + + "\n"; std::string defineWeatherExtent = "#define WEATHER_EXTENT " - + std::to_string(WeatherConstants::WEATHER_EXTENT) + "\n"; + + text_utils::formatFloatClassic( + WeatherConstants::WEATHER_EXTENT) + + "\n"; std::string defineWeatherMaskOuter = "#define WEATHER_MASK_RADIUS_OUTER " - + std::to_string( + + text_utils::formatFloatClassic( WeatherConstants::WEATHER_MASK_RADIUS_OUTER) + "\n"; std::string defineWeatherMaskInner = "#define WEATHER_MASK_RADIUS_INNER " - + std::to_string( + + text_utils::formatFloatClassic( WeatherConstants::WEATHER_MASK_RADIUS_INNER) + "\n"; diff --git a/src/resources/shaders/legacy/room/tex/acolor/vert.glsl b/src/resources/shaders/legacy/room/tex/acolor/vert.glsl index 2bbeb02f5..34a79167d 100644 --- a/src/resources/shaders/legacy/room/tex/acolor/vert.glsl +++ b/src/resources/shaders/legacy/room/tex/acolor/vert.glsl @@ -20,14 +20,14 @@ void main() // | /| Triangles 012 and 023 both use CCW order. // |/ | Notice that the four vertices are in CCW order. // 0--1 - const ivec3[4] ioffsets = ivec3[4](ivec3(0, 0, 0), ivec3(1, 0, 0), ivec3(1, 1, 0), ivec3(0, 1, 0)); // fan + const ivec3 ioffsets[4] = ivec3[4](ivec3(0, 0, 0), ivec3(1, 0, 0), ivec3(1, 1, 0), ivec3(0, 1, 0)); // fan #else // GL_TRIANGLE_STRIP // 2--3 Note: Triangle strips alternate CCW/CW winding on every other triangle. This means... // |\ | triangle 012 is CCW order, but triangle 123 is CW order (backwards). // | \| Keep in mind that OpenGL does not actually draw the triangle backwards, // 0--1 so it does not affect glFrontFace() or the gl_FrontFacing variable. - const ivec3[4] ioffsets = ivec3[4](ivec3(0, 0, 0), ivec3(1, 0, 0), ivec3(0, 1, 0), ivec3(1, 1, 0)); // strip + const ivec3 ioffsets[4] = ivec3[4](ivec3(0, 0, 0), ivec3(1, 0, 0), ivec3(0, 1, 0), ivec3(1, 1, 0)); // strip #endif ivec3 ioffset = ioffsets[gl_VertexID];