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

Author Topic: Fullscreen app sometimes does not start in focus  (Read 1905 times)

0 Members and 1 Guest are viewing this topic.

antonm

  • Newbie
  • *
  • Posts: 4
    • View Profile
Fullscreen app sometimes does not start in focus
« on: April 19, 2011, 08:53:12 am »
Hello, I'm doing an opengl app in fullscreen mode and every once in a while the app will start and display but the focus will be on the window "behind" it (basically still on the desktop or whatever was open last). Is this a known issue or am I doing something wrong?

The app runs fine after I alt+tab back into it, but its very annoying. I can post code but I figure I would ask first.

Thanks,
Anton

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Fullscreen app sometimes does not start in focus
« Reply #1 on: April 19, 2011, 09:08:53 am »
This could be a bug in SFML.

Can you show a complete and minimal code that reproduces this problem? What OS are you using? Which version of SFML?
Laurent Gomila - SFML developer

antonm

  • Newbie
  • *
  • Posts: 4
    • View Profile
Fullscreen app sometimes does not start in focus
« Reply #2 on: April 20, 2011, 06:51:19 am »
Yep, looks like its pretty minimal (I was able to yank everything and still reproduce it). I'm running 64bit Windows 7, compiling with codeblocks+mingw, SFML v1.6.

It seems to occur most often when you move the mouse as the app starts (perhaps input handling on startup is an issue?). I've gotten it to occur without any input, but I can't be sure, since maybe there were minor mouse movements...

Code: [Select]

#include <SFML/Window.hpp>

int GFX_WIDTH = 1920/2;
int GFX_HEIGHT = 1080/2;
int GFX_BPP = 32;
bool GFX_FULLSCREEN = true;

int main()
{
sf::Window App(sf::VideoMode(GFX_WIDTH, GFX_HEIGHT, GFX_BPP), "SFML OpenGL", GFX_FULLSCREEN ? sf::Style::Fullscreen : (sf::Style::Resize | sf::Style::Close));

    while (App.IsOpened())
    {

        sf::Event event;
        while (App.GetEvent(event))
        {
            if (event.Type == sf::Event::Closed) {
                App.Close();
            }
            else if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape)) {
                App.Close();
}
        }

glClearDepth(1.f);
glClearColor(0.0f, 0.0f, 0.0f, 0.f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        App.Display();
    }

    return EXIT_SUCCESS;
}


Let me know if there is anything else I can help with...this is quite a lame problem. I really like SFML (I've switched from SDL) and would like to stick with it but I can't see actually distributing the project if it does this :/

Hopefully its something on my end...maybe something to do with 32bit vs 64bit? The only library I'm linking with is fmod, if that of any help. All SFML libraries are linked statically.

Thanks,
-Anton

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Fullscreen app sometimes does not start in focus
« Reply #3 on: April 20, 2011, 07:35:51 am »
Quote
Yep, looks like its pretty minimal

What about this one?
Code: [Select]
#include <SFML/Window.hpp>

int main()
{
   sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Fullscreen);

    while (App.IsOpened())
    {
        sf::Event event;
        while (App.GetEvent(event))
        {
            if (event.Type == sf::Event::Closed)
                App.Close();
        }
        App.Display();
    }

    return EXIT_SUCCESS;
}

Should be the same, but I prefer to check first ;)
Laurent Gomila - SFML developer

antonm

  • Newbie
  • *
  • Posts: 4
    • View Profile
Fullscreen app sometimes does not start in focus
« Reply #4 on: April 20, 2011, 11:16:48 am »
Understandable.

Oddly, it happened the first time I ran that code, and then never again for the next 10 times. Going back to my code, the problem occurs again (so its not something flipped in my system).

The startup sequence for 800x600 is different from 1920x1080. The mode is definitely supported, as no error is thrown. For 800x600 though, it looks like this:

1. cursor disappears
2. screen goes black
3. cursor appears

For 1080p:

1. cursor does NOT disappear, but switches to a pointer (its usually a text caret since I'm in codeblocks)
2. screen goes white (or grey in my app, same mem as last app?)
3. screen displays what i'm rendering (i believe first frame)
4. screen goes black
5. screen displays what i'm rendering again (i believe next frame, but hard to verify)

When this bug occurs, the cursor switches back to the text caret sometime around the screen turning black. Clicking then kicks me out of the app, back into codeblocks (or whatever window is "beneath" the app).

The same thing happens when I run the source you provided in 1920x1080, at least more frequently (every few times) than 800x600 (only once).

This behavior also happens when running the app standalone, not launching out of codeblocks.

Thoughts?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Fullscreen app sometimes does not start in focus
« Reply #5 on: April 20, 2011, 11:26:47 am »
I guess that 1920x1080 is your desktop resolution, so the OS doesn't need to switch the resolution in this case. That's why it behaves slightly differently from 800x600.

Anyway, I have no idea what could cause this problem, sorry.
Laurent Gomila - SFML developer

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Fullscreen app sometimes does not start in focus
« Reply #6 on: April 21, 2011, 03:34:59 am »
Sometimes I feel like I have a similar problem without full screen enabled on Windows XP, but it has happened so rarely that I think I'm just tired when it happens.

My problem is that sometimes the application doesn't gain focus, but is visible and see-through (I can see the applications behind it) until I tab into it.

antonm

  • Newbie
  • *
  • Posts: 4
    • View Profile
Fullscreen app sometimes does not start in focus
« Reply #7 on: April 21, 2011, 08:59:15 am »
Yep 1920 is my desktop, and yes that problem is basically what I'm seeing. Perhaps you're not tired after all :) Next time you see it, maybe see if you can gain insight into it...

Anyway that's quite unfortunate, but thanks for your help. I'll give SFML2.0 a try, maybe it gets fixed somehow, and maybe try it on my WinXP machine. If I find anything I'll let you know...