1
\$\begingroup\$

I'm implementing a borderless fullscreen functionality and managed to make something that almost works. Using: C++, Winapi, OpenGL 3.3.

When in fullscreen borderless mode, if alt tab the game window loses focus but is still on top, not even the alt tab window shows.

I managed to track it down to SwapBuffers. If i disable it, no problems but also no rendering.

If i force the window to hide when it loses focus, the entire screen flickers. And if i alt tab back, only the game window flickers.

If i put the game in windowed mode, it works as normal.

Window Styles are first set to(windowed mode stops here):

WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE

And then are set to(if fullscreen):

GetWindowLong(window, GWL_STYLE) & ~WS_OVERLAPPEDWINDOW

My gameloop:

while(isRunning)
{
    loopNewTime = timeGetTime();
    loopDuration = (r32)(loopNewTime - loopOldTime);
    loopTime = Clamp(0.0f, (loopDuration - sleepTime), 250.0f);

    loopOldTime = loopNewTime;
    loopAccumulator += loopTime + sleepTime;

    while(loopAccumulator >= loopFixedDeltaTime)
    {
        if(isFocused || canRunWithoutFocus)
        {
            DoStuff();
        }

        loopAccumulator -= loopFixedDeltaTime;
    }

    if(isFocused || canRunWithoutFocus)
    {
        DoStuff();

        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

        DrawStuff();

        SwapBuffers(deviceContext);
    }



    framerateTimeThreshhold += loopTime + sleepTime;
    ++framerateCount;

    if(framerateTimeThreshhold >= 1)
    {
        framerate = framerateCount;
        framerateCount = 0;
        --framerateTimeThreshhold;
    }

    sleepTime = Max(timeStep - loopTime, 0.0f);

    Sleep((u32)sleepTime);
}

So, how can i solve this problem?

Thanks in advance.

\$\endgroup\$
  • \$\begingroup\$ To anyone with this problem, i found a 99% perfect answer here: stackoverflow.com/questions/23145217/… What i did: Set the window size to the size of the screen + 1. For some reason if window and screen are the same size, Windows reacts like a normal fullscreen. \$\endgroup\$ – José Carlos Candido Oct 28 '17 at 16:45
  • \$\begingroup\$ Post that as an answer \$\endgroup\$ – Bálint Oct 28 '17 at 21:44
  • \$\begingroup\$ If you take away WS_OVERLAPPEDWINDOW maybe there's no style left - have you tried setting the WS_POPUP style? SetWindowLong(window, GWL_STYLE, (GetWindowLong(window, GWL_STYLE) & ~WS_OVERLAPPEDWINDOW) | WS_POPUP); \$\endgroup\$ – Peter Stock Dec 23 '17 at 20:29
0
\$\begingroup\$

To anyone with this problem, i found a 99% perfect answer here: https://stackoverflow.com/questions/23145217/flickering-when-borderless-window-and-desktop-dimensions-are-the-same

What i did: Set the window size to the size of the screen + 1. For some reason if the window and the screen are the same size Windows will act like it's a "normal" fullscreen.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.