From 5e790774917beacfc1a17997f8f705d195320451 Mon Sep 17 00:00:00 2001 From: Aki Koskinen Date: Sun, 27 Nov 2016 16:34:48 +0200 Subject: [PATCH] Always use a dot as a decimal point in string, independent of locale std::to_string() potentially uses a decimal point character different than a dot (.), depending on the environment's locale. But since this generated string will be part of GLSL code, there needs to be a dot and nothing else. --- src/mbgl/programs/program.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp index c912de13f..e5aae2499 100644 --- a/src/mbgl/programs/program.hpp +++ b/src/mbgl/programs/program.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace mbgl { @@ -17,7 +18,11 @@ public: {} static std::string pixelRatioDefine(const ProgramParameters& parameters) { - return std::string("#define DEVICE_PIXEL_RATIO ") + std::to_string(parameters.pixelRatio) + "\n"; + std::ostringstream pixelRatioSS; + pixelRatioSS.imbue(std::locale("C")); + pixelRatioSS.setf(std::ios_base::showpoint); + pixelRatioSS << parameters.pixelRatio; + return std::string("#define DEVICE_PIXEL_RATIO ") + pixelRatioSS.str() + "\n"; } static std::string fragmentSource(const ProgramParameters& parameters) {