I’m attempting to do one thing actually fundamental with sf::View.
On a 1280×720 pixel window. I would like to position a viewport which is 560×560 with a 160px hole from the highest.
What I get is that this:
It creates the proper hole size on the highest, nevertheless it additionally applies a niche on the backside.
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 appear to be right, however I’m not positive why it leaves a niche on the backside.