Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Game resolution dilemma  (Read 9015 times)

0 Members and 4 Guests are viewing this topic.

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Game resolution dilemma
« Reply #15 on: February 01, 2015, 06:57:53 pm »
Why aren't you resizing it on the Resize event like your main view? Also your asking AFS for follow-up advice et you didn't even follow his advice from his previous post.

Have you tried debugging? Print out your numbers to see where things are going wrong, this way you can make an accurate assumption.

ex. If windowView.getViewport() is giving you the wrong numbers, you know where to start your fix.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Game resolution dilemma
« Reply #16 on: February 01, 2015, 07:17:30 pm »
Values of the viewport are between 0 and 1 so probably aren't much use in creating a view.
I wouldn't have thought that you need the temp view at all really since the .getLetterboxView() function returns a view.
Also, I believe that the letterbox parameters ask for the size of the window, not the view.

I'm thinking more this:
_renderService.Window.setView(_renderService.getLetterboxView(windowView, _renderService.Window.getSize().x, _renderService.Window.getSize().y););
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

AFS

  • Full Member
  • ***
  • Posts: 115
    • View Profile
Re: Game resolution dilemma
« Reply #17 on: February 01, 2015, 07:49:27 pm »
Like the guys said, yes, the function receives the window size, not the view's. Also, you *should* be calling the function only after the Resized event, but calling it every time you create the view will also work if you are creating the view every frame instead of having it as a member.

Like Hapax said, the viewport values are between 0 and 1, and you shouldn't be using this when creating the view, just use 0 and 0. Remember, when creating a view using a rectangle, the first two numbers indicate the position while the other two numbers indicate the size.

I think something like this should work, and you won't need to call the function after the Resized event because the view is created on the fly:

void UserInterface::Draw()
{
    int viewWidth = _renderService.Window.getView().getSize().x;
    int viewHeight = _renderServide.Window.getView().getSize().y;
    int windowWidth = _renderService.Window.getSize().x;
    int windowHeight = _renderService.Window.getSize().y

    sf::View interfaceView( sf::FloatRect(0, 0, viewWidth, viewHeight) );
    interfaceView = _renderService.getLetterboxView(interfaceView, windowWidth, windowHeight);

        _renderService.Window.setView(interfaceView);
        _renderService.Window.draw(BottomBar);

        (...)
}

I still think that having the view as a member would be better, but whatever :P
« Last Edit: February 01, 2015, 08:00:46 pm by AFS »

Canvas

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Game resolution dilemma
« Reply #18 on: February 02, 2015, 01:55:27 am »
Cheers for the reply AFS,

I have updated my code to update now on resizing and it works fine, however I need to move my UI view when my player moves which doesn't seem to be a problem but not sure if that is 100% correct :). When you say "I still think that having the view as a member would be better, but whatever :P" what do you mean by a member? could you please explain.

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: Game resolution dilemma
« Reply #19 on: February 02, 2015, 10:04:17 am »
Make interfaceView a member of UserInterface instead of creating a new one each frame. Might squeeze a few more FPS out of your application.

 

anything