SFML community forums

Help => Window => Topic started by: nitram_cero on May 21, 2009, 08:38:00 pm

Title: RenderWindow returning 0 width/height after creation (Win)
Post by: nitram_cero on May 21, 2009, 08:38:00 pm
I think it has something to do with
   GetClientRect(myHandle, &ActualRect);
in
   WindowImplWin32::WindowImplWin32()

Maybe the Window is not completly constructed and this function returns (0,0) width/height?

It doesn't happen all the time, so it's not easily reproduced
(I think it happens because of a debug breakpoint or load times)

The sequence is:
* I create the main RenderWindow (with params).
* I then use it's dimensions (GetWidth()/GetHeight()) to create a View.
* I then get float-NaN results on RenderWindow::ConvertCoords() as the View's half size is (0, 0).

Again, this happens sometimes, so it's probably a Windows thingy

-Martín
Title: RenderWindow returning 0 width/height after creation (Win)
Post by: Laurent on May 21, 2009, 09:32:39 pm
Did you try the latest sources?
Title: RenderWindow returning 0 width/height after creation (Win)
Post by: ptrxyz on May 22, 2009, 01:00:31 pm
I am using .GetWidth/.GetHeigh with latest SVN (SFML2) and it works like it should.
Title: RenderWindow returning 0 width/height after creation (Win)
Post by: nitram_cero on May 22, 2009, 05:03:54 pm
I did, SVN updated before posting (trunk)

This happens in counted occasions, it's not common, so it's not easy traceable (thou I'm doing my best to try to solve this)

It's probably a race condition (inherent to Windows) as most of the times due to debug-step delays or heavy CPU load.

Perhaps I'm querying GetWidth/Height after window creation but before the first WM_SIZE message (that resizes it from the default (1,1) w/h)?

Is there a reason to not set myWidth/myHeight in priv::WindowImpl from parameters?

Thanks
Title: RenderWindow returning 0 width/height after creation (Win)
Post by: Laurent on May 22, 2009, 06:05:49 pm
Quote
Is there a reason to not set myWidth/myHeight in priv::WindowImpl from parameters?

The last 2 lines of the constructor do it. It doesn't wait for the first WM_SIZE message.

Have you tried the sfml2 branch in SVN?
Title: RenderWindow returning 0 width/height after creation (Win)
Post by: nitram_cero on May 22, 2009, 06:23:01 pm
Can't do it right away; I have a hacked Audio lib (Music & SoundBuffer) so I would need to port that to SFML2.

I'll try to port it some other time, for now I just don't set the view on frames that have window width or height = 0.

One question that has nothing to do with this: Can I deploy my app with a static hacked SFML according to the licence? Thanks.
Title: RenderWindow returning 0 width/height after creation (Win)
Post by: Laurent on May 22, 2009, 07:13:51 pm
Quote
Can I deploy my app with a static hacked SFML according to the licence?

Sure :)