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

Author Topic: update the Window while it isn't selected  (Read 2997 times)

0 Members and 1 Guest are viewing this topic.

Reborn

  • Newbie
  • *
  • Posts: 25
    • View Profile
update the Window while it isn't selected
« on: May 09, 2014, 11:48:12 pm »
Hey,
i want that my game window render it's pictures, while it isn't the foreground window how i can i do that?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: update the Window while it isn't selected
« Reply #1 on: May 09, 2014, 11:57:01 pm »
It does that by default.  If your main game loop looks anything like the one in the tutorials, it will keep getting executed (and drawing stuff) until the window is closed.  When the window loses focus, all that does is generate an sf::Event::LostFocus, which you're free to ignore.

Are you experiencing a problem of some kind that makes you think this isn't the default behavior?
« Last Edit: May 09, 2014, 11:58:35 pm by Ixrec »

Reborn

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: update the Window while it isn't selected
« Reply #2 on: May 10, 2014, 12:09:29 am »
First Thanks for the quick answer.
I want make possible to resize my window, but i want to keep the aspect ratio. So i added
case WM_SIZE:
case WM_SIZING:
in the WindowImplWin32.cpp, at first just for trying purposes, i think, so can i set the width to the new hight from my window. But when i resize the window, my game stop polling events from the stack, so i cant handle WM_SIZING-Events.
« Last Edit: May 10, 2014, 12:13:03 am by Reborn »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: update the Window while it isn't selected
« Reply #3 on: May 10, 2014, 12:13:46 am »
Uhh well modifying SFML source code isn't the solution to your problem. Instead use the view and/or the setSize function.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: update the Window while it isn't selected
« Reply #4 on: May 10, 2014, 12:14:43 am »
You can easily do this with regular SFML using the Resized event and sf::Views.  There's no reason to start modifying the library.  Please go read *all* of the official SFML tutorials (they're not that long).

Reborn

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: update the Window while it isn't selected
« Reply #5 on: May 10, 2014, 12:16:29 am »
Not the ratio of my View, i mean the ratio of my Window, i know the tutorial already. And i want show the changes in realtime, so i haveto catch the WM_SIZING - Message. I don't know another reason.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: update the Window while it isn't selected
« Reply #6 on: May 10, 2014, 12:49:50 am »
Oh, you want the aspect ratio to be maintained while the user is resizing the window, rather than simply "snapping" to the closest size matching the ratio after the user lets go.

This is definitely not something SFML currently provides, and I have no idea if it's possible to implement this in a portable way.  But if you get it working on one or more platforms, please do tell us how you did it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: update the Window while it isn't selected
« Reply #7 on: May 10, 2014, 09:21:31 am »
The only portable way to implement it with SFML is to handle events in a separate thread. You won't get Resized events during resize though, so you'll have to call window.getSize() in another thread to react to size changes in realtime.
Laurent Gomila - SFML developer

Reborn

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: update the Window while it isn't selected
« Reply #8 on: May 10, 2014, 10:39:43 am »
Ok i think i understand. Thank you.

 

anything