diff --git a/examples/common/hud.cpp b/examples/common/hud.cpp index 04bc8f5a..0d2e573a 100644 --- a/examples/common/hud.cpp +++ b/examples/common/hud.cpp @@ -528,7 +528,7 @@ Hud::Rebuild(int width, int height, int framebufferWidth, int framebufferHeight) x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_MIDDLE); } drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_RIGHT); - int pos = (int)((it->value/float(it->max-it->min))*it->w); + int pos = int(((it->value-it->min)/(it->max-it->min))*float(it->w)); drawChar(_staticVboSource, sx+pos, y, 1, 1, 0, FONT_SLIDER_CURSOR); } // draw pulldowns diff --git a/examples/common/hud.h b/examples/common/hud.h index a7859cd8..4605e2b9 100644 --- a/examples/common/hud.h +++ b/examples/common/hud.h @@ -127,11 +127,12 @@ protected: bool intStep; void SetValue(float v) { - value = std::max(std::min(v, max), min); + v = std::max(std::min(v, max), min); if (intStep) { // MSVC 2010 does not have std::round() or roundf() - value = v>0.0f ? floor(v+0.5f) : ceil(v-0.5f); + v = v>0.0f ? floor(v+0.5f) : ceil(v-0.5f); } + value = v; } };