SFML community forums

Help => Graphics => Topic started by: mudale222 on June 01, 2015, 04:46:40 pm

Title: q: how to use the sf:view correctly?
Post by: mudale222 on June 01, 2015, 04:46:40 pm
I defined the size of the window as (800,650) and i have image of (1439,659).
I want to see just part of the image so that i can move a little to the sides and still be on the image.
What that happen is that instead of showing just the part of the image it's squeezing almost the whole image into the screen.

code:
sf::View view(sf::Vector2f(middle_x, middle_y), sf::Vector2f(window.getSize().x, window.getSize().y));
view.setSize(WINDOW_X_LENGTH, WINDOW_Y_LENGTH - 50);
 

when middle_x and middle_y is the center of the image.
Title: Re: q: how to use the sf:view correctly?
Post by: DarkRoku12 on June 01, 2015, 07:06:50 pm
you need to consider "view" as a diferent window.

First , in the window localize the point: middle_x , middle_y , then draw a rectangle with the size WINDOW_X_LENGTH, WINDOW_Y_LENGTH - 50 and put the center of this rectagle in middle_x , middle_y and that its your new window.

suposse this example:

window size( 800 , 650 ) ( 800 , 650 - 50 = 800 , 600 view size ) 
image size ( 1440 , 660 )
center of the image (  720 , 330 ) ( center of the view )
And mi profile avatar rendered with the view. ( positionated in 0,0 )

See attachment.