SFML community forums

Help => General => Topic started by: doomista on July 16, 2017, 05:53:40 pm

Title: Fullscreen SFML app and CreateProcess
Post by: doomista on July 16, 2017, 05:53:40 pm
Hi,
I am trying to create an App Launcher with SFML for launching my games. I am using CreateProcess to launch a game. So far I've discovered that when my app has sf::Style::Default, game launched by CreateProcess (namely FTL) will go to fullscreen and play just fine. Unfortunately, when my app has sf::Style::Fullscreen, FTL will run in fullscreen, in foreground, has focus, will apply alternate style to mouse cursor, but nothing draws on the screen. Music plays, I can even click buttons (and exit FTL), but I can't see anything. I've tried to unset visibility of sfml window with setVisibility(false), but it didn't helped. Also I didn't find function to disable and reenable fullscreen.

Can you please help? Thanks in advance. App launching code:
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));

if (!CreateProcess("FTLGame.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))    {
        printf("CreateProcess failed (%d).\n", GetLastError());
}
else {
        printf("Prcess Creation Success");
}

WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
Title: Re: Fullscreen SFML app and CreateProcess
Post by: eXpl0it3r on July 16, 2017, 07:16:16 pm
I can imagine that two fullscreen applications can cause issues (both want exclusive screen rights).
Question I ask myself is, why does your launcher need to run in fullscreen mode?
Title: Re: Fullscreen SFML app and CreateProcess
Post by: doomista on July 16, 2017, 11:40:06 pm
Cosmetic reasons, mostly. I have my gaming PC under TV (I don't have any console) and a convenient game launcher with interface similar to console interface that can be controlled by a gamepad is a nice touch. At this point I have one written in HTML+JS interpreted as HTA. That's a deprecated Windows feature that allows running processes from javascript. But it is buggy at best and I want different layout and I simply don't have the nerves to write it again in HTML+JS.

Anyways, I've probably found a solution:
Simply close SFML window right before executing a proces and then recreate context when launched game has been exited. Hopefully it will not unload my textures, we'll see. But I am quite surprised that setVisible() hasn't done the trick.
Title: Re: Fullscreen SFML app and CreateProcess
Post by: dabbertorres on July 18, 2017, 03:14:59 am
You might consider making your launcher borderless-windowed fullscreen. I believe that's what Steam Big Picture does by default.
Title: Re: Fullscreen SFML app and CreateProcess
Post by: doomista on July 18, 2017, 05:32:38 pm
I've tried that, raises the same issue as using fullscreen.
Title: Re: Fullscreen SFML app and CreateProcess
Post by: Hapax on July 18, 2017, 10:55:05 pm
At what size of window does it stop causing the issue? i.e. How large can it be before it causes your issue?