SFML community forums

Help => Window => Topic started by: reethok on May 13, 2013, 11:06:20 am

Title: How to mantain the proportion in full screen (for diferent screens)
Post by: reethok on May 13, 2013, 11:06:20 am
First at all, sorry for my bad english.

Now, what i want to do is... I create a render window, with... for example, 1024x576, that is 16:9, what can I do so when it switches to full screen, it scales mantaining the proportion and it stop when the width or heigh is filled, centring the image and filling the unoccuped space with black.

If i didnt explained it well, this is a graphic explanation:

(http://imageshack.us/a/img824/5562/55751741.png)

(http://imageshack.us/a/img11/2426/42486587.png)

(http://imageshack.us/a/img24/4197/99812100.png)

Greetings.
Title: Re: How to mantain the proportion in full screen (for diferent screens)
Post by: Nexus on May 13, 2013, 11:21:40 am
http://en.sfml-dev.org/forums/index.php?topic=10703

Read also the tutorial about views.
Title: Re: How to mantain the proportion in full screen (for diferent screens)
Post by: reethok on May 13, 2013, 07:30:30 pm
Thank you, but that isnt what I want to do exactly.

I dont want to mantain a specific size (for example, 800x600), but to resize mantaining the proportion, in that case 4:3, and just filling with black what dont fit. (As in the images I put in the post).

Greetings.
Title: Re: How to mantain the proportion in full screen (for diferent screens)
Post by: gostron on May 13, 2013, 07:42:37 pm
I'd say it's all the same,

create a View, get the size of your window, get the maximum considering your ratio and create the View of the right size. However changing the view this way will only result in having more or less entities printing on your screen depending on your screen resolution
Title: Re: How to mantain the proportion in full screen (for diferent screens)
Post by: reethok on May 13, 2013, 09:06:27 pm
Mmm, they game will be a visual novel, so i need it to escale :S
Title: Re: How to mantain the proportion in full screen (for diferent screens)
Post by: gostron on May 13, 2013, 09:38:57 pm
let's assume you display images of this 1024x768 and your screen size is 1920x1080.

I'd guess that you want a view that goes the maximum size, but of the right ratio.

So in this case i'd go with a view of 1365x768, to keep the right size but to go to the right ratio.

where 1365 = 1024 * (16/9) / (4/3)

and with being extra careful about not drawing anything on the borders (or to overwrite too black rectangles)
Title: Re: How to mantain the proportion in full screen (for diferent screens)
Post by: Perde on May 15, 2013, 01:22:12 am
Thank you, but that isnt what I want to do exactly.

I dont want to mantain a specific size (for example, 800x600), but to resize mantaining the proportion, in that case 4:3, and just filling with black what dont fit. (As in the images I put in the post).

Greetings.

Actually, Nexus reply contained the answer to your question. The part in the view-tutorial you'd want to look at is called "Defining how the view is viewed".