I am trying to do something really basic with sf::View.
On a 1280x720 pixel window, I need to place a viewport which is 560x560 with a 160px gap from the top.
What I get is this:
https://imgur.com/a/2zhiV7SIt creates the correct gap length, but it also applies a gap at the bottom
Code I wrote for the viewport:
int viewport_bl_OffsetX = 0;
int viewport_bl_OffsetY = 160;
int viewport_bl_W = 560;
int viewport_bl_H = 560;
sf::View viewBL(sf::FloatRect(
static_cast<float>(viewport_bl_OffsetX),
static_cast<float>(viewport_bl_OffsetY),
static_cast<float>(viewport_bl_W),
static_cast<float>(viewport_bl_H)
));
float viewport_bl_OffsetXRatio = static_cast<float>(viewport_bl_OffsetX) / window_W;
float viewport_bl_OffsetYRatio = static_cast<float>(viewport_bl_OffsetY) / window_H;
float viewport_bl_WRatio = static_cast<float>(viewport_bl_W) / window_W;
float viewport_bl_HRatio = static_cast<float>(viewport_bl_H) / window_H;
viewBL.setViewport(sf::FloatRect(
viewport_bl_OffsetXRatio, // 0.00000000
viewport_bl_OffsetYRatio, // 0.222222224
viewport_bl_WRatio, // 0.437500000
viewport_bl_HRatio // 0.777777791
));
The ratios seem to be correct, but I am not sure why it leaves a gap at the bottom.