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

Author Topic: Refresh draw but in background?  (Read 4642 times)

0 Members and 2 Guests are viewing this topic.

hechelion

  • Newbie
  • *
  • Posts: 24
    • View Profile
Refresh draw but in background?
« on: October 15, 2022, 07:27:13 pm »
Hi, I have a rather strange question.

I will try to explain what I need.

I have a friend who streams games to youtube, he currently uses the settings window of an emulator called Dolphin to capture his gamepad input and stream it to youtube.



With SFML (Core net 6 and SFML 2.5.0) I programmed an application that did the same thing, but was prettier.


To transmit, he uses the OBS program that allows him to capture the windows of the different applications, he normally transmits playing in full screen and the Dolphin window (the program he currently uses to capture the inputs of the gamepad) stays in the background and works without problem .

My application works even if the window does not have the focus, even SFML does capture the input of the gamepad while it is in the background (having the game in full screen).
I know this because I programmed a log every time an input was detected.

The problem is that visually SFML does not update while in the background, in the OBS stream, you see only the static image.


I understand that SFML is not meant to run in the background and this is a pretty weird application.

But is it possible to get SFML to refresh the windows while in the background?

If not, do you know any other way to do it?


EDIT:
I just noticed something similar, if you put the window created by SFML cut in the middle of one of the sides of the desktop.

The thumbnail generated by windows 10 only updates the part of the SFML window that is visible inside the script.


sorry for the blurry image, but I couldn't find a way to capture the thumbnail if it wasn't with a photo from my cell phone.
« Last Edit: October 15, 2022, 10:18:49 pm by hechelion »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Refresh draw but in background?
« Reply #1 on: October 19, 2022, 02:51:28 pm »
Yeah it's a known limitation that if you have a fullscreen application, but capture an SFML window behind it, that it won't be updated.

One would have to investigate what exactly is causing this to see if there's a workaround for it.

The only other workarounds I know is to have the "foreground" application run in borderless window mode or using a second screen to put the input window.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

hechelion

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Refresh draw but in background?
« Reply #2 on: October 19, 2022, 11:51:33 pm »
I imagined that it would not be something simple.

I already proposed the second monitor to him, but he would only use it for this, so I don't think he would connect a second monitor.

As always, thank you very much for your reply eXpl0it3r

EDIT:
In case it helps someone in the future.

In the end I have used a NET winform, the graphics are PictureBox and I have used SFML to capture the input.

The form's pictureBox is updated in the background, it's not ideal, but at least it works for what I need.
« Last Edit: October 20, 2022, 01:15:18 am by hechelion »

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Refresh draw but in background?
« Reply #3 on: October 20, 2022, 01:29:23 pm »
I haven't tried it in SFML.Net, but in C++ with a simple while game loop doing render and display I can OBS the SFML window updating correctly below a full screen game, but with some limits.
My monitor is 2560x1440. The SFML window is 1920x1080. The game (Knights Of The Old Republic) is 1600x1200 full screen.
When the game is in the foreground, the only part of the SFML window that updates is the region that exists in the upper left 1600x1200 part of the desktop. Moving the window around changes which part is visible, the rest is frozen in OBS. So the size of the full screen game is limiting which parts of other windows update.

If your friend is using Dolphin, maybe it's running at a fairly low res full screen (been a long time since I tried Dolphin, can't remember it's settings), and it just happens that your SFML window was outside of that region.
But I've only done a couple of minutes testing, so just guessing. I've got an idea of what might be happening, but I need to check the SFML source.
Edit: I checked the source, it's not doing what I thought.
« Last Edit: October 20, 2022, 01:59:10 pm by kojack »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Refresh draw but in background?
« Reply #4 on: October 20, 2022, 07:10:04 pm »
I think my assumption of what the limitations are, were a bit wrong.
I just tried it myself with the SFML Shaders example in the background of a fullscreen application, with both window and game capture and they worked just fine.



What doesn't work, and also doesn't work for lots of AAA games, is when you minimize the SFML application to then still capture anything while minimized.

kojack brought up a good point, that it might be important where the SFML window is positioned, if your fullscreen game changes the actual display resolution. Because the background application won't change it's size or position when you reduce the display resolution, so if it wasn't placed top-left quadrant, it might simply be "off screen" and thus stop rendering something.

Does Dolphin change the display resolution?
If so, can you make sure that the SFML window isn't minized and remains in the top left position of the screen?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

hechelion

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Refresh draw but in background?
« Reply #5 on: October 24, 2022, 08:15:01 pm »
Hi.
First, thanks for your time.
It took me a while to answer because I had to coordinate with my friend.

We did several tests, I made sure that the SFML application window was not minimized.

We placed the window in the upper left corner and with some emulators (mame) the application did work in the background.
But with other emulators (mednafen) we couldn't find a way to make it work.
I always mean having SFML in the background and the emulator in full screen.

I wouldn't know what to conclude, I really don't know because with some emulators/games it doesn't give a problem, but with others it does.


PS: In the afternoon I will edit this message with some videos of the tests we did.


 

anything