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

Author Topic: [bug?] Width & Height become 0 while not focussed.  (Read 5005 times)

0 Members and 1 Guest are viewing this topic.

vincentrevelations

  • Newbie
  • *
  • Posts: 7
    • View Profile
[bug?] Width & Height become 0 while not focussed.
« on: May 29, 2010, 05:18:47 pm »
at least in v1.6, in the dotnet version, and when using Style.Close. but i suppose this error is everywhere.

While the window is not focussed, the .Width and .Height fields of the RenderWindow are 0, though it is stated that those should be constant.
The fields are restored to the correct values when the window regains focus and .Display() is called.

This makes wrapping moving stuff around the window when it's not focusssed impossible without a workaround.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[bug?] Width & Height become 0 while not focussed.
« Reply #1 on: May 29, 2010, 07:34:14 pm »
Can you show a complete and minimal example that reproduces this problem?
Laurent Gomila - SFML developer

vincentrevelations

  • Newbie
  • *
  • Posts: 7
    • View Profile
[bug?] Width & Height become 0 while not focussed.
« Reply #2 on: May 29, 2010, 08:07:16 pm »
Code: [Select]


using System;
using System.Collections;
using SFML;
using SFML.Graphics;
using SFML.Window;

namespace Nereid
{
    static class Bug
    {
        public static RenderWindow App;

        static void Main()
        {

            Styles style = Styles.Close;

            App = new RenderWindow(new VideoMode(1024, 768), "SFML.Net OpenGL", style, new WindowSettings(24, 8, 4));

            while (App.IsOpened())
            {
                App.DispatchEvents();

                App.Clear();

                if (App.Width == 0 && App.Height == 0) { System.Console.WriteLine("Something's not right"); }

                App.Draw(Shape.Rectangle(new Vector2(App.Width - 150, App.Height - 150), new Vector2(App.Width, App.Height), Color.Blue));

                App.Display();
            }

        }
    }
}


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[bug?] Width & Height become 0 while not focussed.
« Reply #3 on: May 29, 2010, 08:51:22 pm »
Thank you very much, I'll test that as soon as possible :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[bug?] Width & Height become 0 while not focussed.
« Reply #4 on: May 31, 2010, 07:24:23 pm »
I couldn't reproduce your problem, your code works fine for me. When the window is out of focus it keeps its size. The size becomes zero only if I minimize the window to the task bar, which is expected.
Laurent Gomila - SFML developer

vincentrevelations

  • Newbie
  • *
  • Posts: 7
    • View Profile
[bug?] Width & Height become 0 while not focussed.
« Reply #5 on: May 31, 2010, 08:05:32 pm »
Quote from: "Laurent"
I couldn't reproduce your problem, your code works fine for me. When the window is out of focus it keeps its size. The size becomes zero only if I minimize the window to the task bar, which is expected.


ah, yes, that's what i meant actually.
why does the size becomes zero when minimized? that doesn't seem logical to me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[bug?] Width & Height become 0 while not focussed.
« Reply #6 on: May 31, 2010, 08:42:23 pm »
The size of the window really becomes zero (the window is not visible anymore yet still focused), so it seems logical that SFML reports that.

I admit that it's not really useful, but what problem do you get with that? Maybe I can think about changing this behaviour if you show me one example where it clearly is an issue :)
Laurent Gomila - SFML developer

vincentrevelations

  • Newbie
  • *
  • Posts: 7
    • View Profile
[bug?] Width & Height become 0 while not focussed.
« Reply #7 on: May 31, 2010, 09:14:56 pm »
Quote from: "Laurent"
The size of the window really becomes zero (the window is not visible anymore yet still focused), so it seems logical that SFML reports that.

I admit that it's not really useful, but what problem do you get with that? Maybe I can think about changing this behaviour if you show me one example where it clearly is an issue :)


well, i have this sidescrolling starfield with about 300 stars. the stars wrap around the screen borders (kinda like recycling). so i use something like
if(this.x > program.window.width) {this.x=0;}
after the star has been moved, and then i draw it.

but when the windows is minimized, the stars keep wrapping around a 'window' that is 0px wide. so when i restore the window from the taskbar, all the stars have x==0. all on the left side of the screen.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[bug?] Width & Height become 0 while not focussed.
« Reply #8 on: May 31, 2010, 09:52:56 pm »
I see.

In the future there will probably be a Minimized/Deactivated event in SFML, so you could use it to pause your game and not update it when its size is zero.
But maybe it would be better to keep the size as well, yes.

Thanks for your help.
Laurent Gomila - SFML developer

vincentrevelations

  • Newbie
  • *
  • Posts: 7
    • View Profile
[bug?] Width & Height become 0 while not focussed.
« Reply #9 on: May 31, 2010, 10:17:39 pm »
In the future there will probably be a Minimized/Deactivated event in SFML, so you could use it to pause your game and not update it when its size is zero.
yeah, i tried it like that with the out of focus events. but that was not enough obviously.

But maybe it would be better to keep the size as well, yes.
that would be good. but don't forget you have a Style.Resize option for when you construct a window.

Thanks for your help.
anytime, i love projects like this.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[bug?] Width & Height become 0 while not focussed.
« Reply #10 on: May 31, 2010, 11:21:06 pm »
Quote

In the future there will probably be a Minimized/Deactivated event in SFML, so you could use it to pause your game and not update it when its size is zero.
yeah, i tried it like that with the out of focus events. but that was not enough obviously.

Out of focus and minimized are two different things. A window can be minimized and keep the focus, it can also be maximized and loose the focus.
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
[bug?] Width & Height become 0 while not focussed.
« Reply #11 on: June 01, 2010, 05:06:35 am »
I personally have had no problem with it, but I could see how plenty of issues could arise by having the screen size set to 0 when minimized. I can't see any real benefit to setting the size to 0, either. If people want a minimized screen to be treated like a size of 0, that kind of logic would probably be easier on the application level since you can just check against another property.