diff --git a/gfx/d3d9/d3d9.cpp b/gfx/d3d9/d3d9.cpp index a59aa5647c..608a676dba 100644 --- a/gfx/d3d9/d3d9.cpp +++ b/gfx/d3d9/d3d9.cpp @@ -363,17 +363,17 @@ void D3DVideo::calculate_rect(unsigned width, unsigned height, else { float device_aspect = static_cast(width) / static_cast(height); - if (fabs(device_aspect - desired_aspect) < 0.0001) + if (fabsf(device_aspect - desired_aspect) < 0.0001f) set_viewport(0, 0, width, height); else if (device_aspect > desired_aspect) { - float delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5; - set_viewport(width * (0.5 - delta), 0, 2.0 * width * delta, height); + float delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; + set_viewport(int(roundf(width * (0.5f - delta))), 0, unsigned(roundf(2.0f * width * delta)), height); } else { - float delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5; - set_viewport(0, height * (0.5 - delta), width, 2.0 * height * delta); + float delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; + set_viewport(0, int(roundf(height * (0.5f - delta))), width, unsigned(roundf(2.0f * height * delta))); } } } diff --git a/gfx/gl.c b/gfx/gl.c index 0a0e03887f..bc55404724 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -783,22 +783,22 @@ void gl_set_viewport(void *data, unsigned width, unsigned height, bool force_ful else #endif { - if (fabs(device_aspect - desired_aspect) < 0.0001) + if (fabsf(device_aspect - desired_aspect) < 0.0001f) { // If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff), // assume they are actually equal. } else if (device_aspect > desired_aspect) { - delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5; - x = (unsigned)(width * (0.5 - delta)); - width = (unsigned)(2.0 * width * delta); + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; + x = (int)roundf(width * (0.5f - delta)); + width = (unsigned)roundf(2.0f * width * delta); } else { - delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5; - y = (unsigned)(height * (0.5 - delta)); - height = (unsigned)(2.0 * height * delta); + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; + y = (int)roundf(height * (0.5f - delta)); + height = (unsigned)roundf(2.0f * height * delta); } }