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

Author Topic: RenderWindow returning 0 width/height after creation (Win)  (Read 3333 times)

0 Members and 1 Guest are viewing this topic.

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
RenderWindow returning 0 width/height after creation (Win)
« Reply #1 on: May 21, 2009, 09:32:39 pm »
Did you try the latest sources?
Laurent Gomila - SFML developer

ptrxyz

  • Newbie
  • *
  • Posts: 32
    • View Profile
RenderWindow returning 0 width/height after creation (Win)
« Reply #2 on: May 22, 2009, 01:00:31 pm »
I am using .GetWidth/.GetHeigh with latest SVN (SFML2) and it works like it should.

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
RenderWindow returning 0 width/height after creation (Win)
« Reply #3 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
RenderWindow returning 0 width/height after creation (Win)
« Reply #4 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?
Laurent Gomila - SFML developer

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
RenderWindow returning 0 width/height after creation (Win)
« Reply #5 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
RenderWindow returning 0 width/height after creation (Win)
« Reply #6 on: May 22, 2009, 07:13:51 pm »
Quote
Can I deploy my app with a static hacked SFML according to the licence?

Sure :)
Laurent Gomila - SFML developer