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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Manuel

Pages: [1]
1
Window / Window Resizing on OS X and Linux
« on: August 07, 2013, 03:02:49 am »
I came up with a simple solution to keep the aspect ratio of my window correct, even if the user choses to manually resize the window. This I am doing by resizing the window to the proper aspect ratio once the resize event fires (user has released the mouse button). This has worked well under OS X and Windows for SFML 2.0.

Sadly with SFML 2.1 it stopped working under OS X ( 10.6 - 10.8) , it still works under Windows as intended. (Tested Versions 7, 8 and XP x64 & x86)

Under Windows it works. The user resizes the window. It resizes itself again to the nearest matching aspect correct size and then then stops. This all happens within a couple of milliseconds, barely noticeable.

Under OS X It resizes several times a second, very quickly the window jittering between various sizes. After some time it settles on a (correct aspect) size. I have noticed that it seems to fire the window::Resized event during OS X resizing animation. Could this be the culprit?

Under Linux (Ubuntu x64), the event seems to fire properly but it does not resize the window. i.e. the size remains unchanged from after the user input. (e.g. squashed)

The main part of the code is basically this:
       
//Window Resized?
if ( event.type == sf::Event::Resized )
{
        //The Window was Resized - Maintain Aspect Ratio
        float AspectX = (float)window.getSize().x / 800.0f;
        float AspectY = (float)window.getSize().y / 600.0f;
               
        //Find Which Is the smaller aspect
        if ( AspectX < AspectY )
        {
                //Resize Y To Fit
                sf::Vector2u tempSize = sf::Vector2u( window.getSize().x, (int)(AspectX * 600.0f) );
                window.setSize( tempSize );
        }
        else if ( AspectX > AspectY )
        {
                //Resize X To Fit
                sf::Vector2u tempSize = sf::Vector2u( (int)(AspectY * 800.0f), window.getSize().y );
                window.setSize( tempSize );
        }
}
 

Is this a bad idea?
Are there more elegant ways to do this? A work around to the issue?

I have also attached a minimum example based on my application that reproduces the problem.

Do you think it is possible to devise a work around until the issue is fixed?

Edit: Tried the latest nightly SFML build, still the issue persists.

2
General discussions / Re: SFML 2.1
« on: August 07, 2013, 02:50:37 am »
Good point, will make a new thread to avoid spamming up this one.

3
General discussions / Re: SFML 2.1
« on: August 07, 2013, 02:26:28 am »
Hey Laurent, first of all thanks for the fantastic work with SFML.
Thanks to this neat library I managed to write my first C++ game and overcome my irrational fear of the language. I started out with version 2.0 and then moved on to 2.1.

Sadly, it seems there are some bugs in version 2.1 under OS X.
When I resize the window my code to keep the correct Aspect ratio seems to go crazy. It worked before in version 2.0 so I'm not sure my code is to blame. Also it seems to do nothing under Linux (SFML 2.1, Ubuntu).


I have attached a minimum example based on my main loop that reproduces the problem reliably.
Do you think it is possible to devise a work around until the issue is fixed?


Thanks again for your time!

Pages: [1]