SFML community forums

Help => Graphics => Topic started by: tetra on May 09, 2015, 04:15:11 am

Title: Zooming in with a View - 'Corrupting' sprites?
Post by: tetra on May 09, 2015, 04:15:11 am
Hi, I have a curious problem.

In my game, I'm generating a 40 x 30 grid of sprites (as a 'dungeon'), each sized 32 x 32.

My window size is 640 x 480.

So, the view to see the entire dungeon would be 1280 x 960, with the center as 640 x 480.

That's fine, and that view works, nothing is corrupted.

However, when I try zooming in so I can see a part of the dungeon (in this case, changing the view size to 480 x 360, and the center to the player's position), my sprite's details are 'corrupted', where some lines are thicker than others.

Here's a few pictures to better illustrate my point.

Zoomed out (1280 x 960):

(http://puu.sh/hGzDu/3b7e55c05c.png)

Zoomed in (480 x 360):

(http://puu.sh/hGzLN/6c3a66e496.png)

Can anyone explain what is happening here?

My code, for reference.

        if (viewToggle) {
            view.setSize(480, 360);
            view.setCenter(game.getPlayer().getPosition());
        } else {
            view.setSize(1280, 960);
            view.setCenter(640, 480);
        }
       
        rt.setView(view);
where 'rt' is the render target, first block is zoomed in, second block is zoomed out.

Edit:

Fixed by scaling to an integer value, e.g. 2x zoom as opposed to 2.67 zoom. Fractional pixels are bad.