-
When I create RenderWindow in OS Windows 10 - during some begin frames I see white color Window...
How to avoid this "flash effect", or change default window color while construct ?
-
You can clear/display once right after construction of the window and before you load all the resources and stuff.
-
no help - test yourself !!! and U will see..........
its some API windows settings........
how to tweak this I don't know
-
at Windows XP I remember was VOID screen but at Win10 White....
If U don't want test I can understand this.... some time, some investigate, some test, some fix....
-
Normally, a window being created is a time when a user will allow minor imperfections. A little flash of white would seem perfectly acceptable to most end-users.
A few approaches to consider:
Reduce the time that the white appears.
Immediately clear and display the window after creation (as mentioned already by eXpl0it3r:
sf::RenderWindow window(sf::VideoMode(800, 600), "");
window.clear();
window.display();
This most likely will not remove the flash completely.
Animate the flash.
Spend a small amount of time fading from white to which ever colour you wish.
This does draw attention to its colour but also removes any sudden flicker in the eye.
Use a more direct approach.
Use OS-specific functions to control the window.
This may require creating the window manually and then "giving it to SFML" however it may be possible to just use an SFML window and apply OS-specific functions to it using its handle (https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Window.php#a26368e7162229f8637c34d80ab0f138e).
Create small and resize.
Just an hypothesis: create a window of size 1x1 (likely white but only a pixel), clear and display as mentioned earlier, then resize the window and clear and display again...
-
Thank You.
Using last method still see "flash" - but much smaller white Rectangle at top-Left window corner.
Just about 110 x 20 px.
And some code to do this >>
Vector2u w_sZe(800, 600);
RenderWindow win;
win.create(VideoMode(0, 0), "My111");
Vector2i w_Pos = win.getPosition();
w_Pos.x -= w_sZe.x / 2;
w_Pos.y -= w_sZe.y / 2;
win.setPosition(w_Pos);
win.setSize(w_sZe);
-
The final method would only really work if the window is borderless since the plan is to make it a single pixel and therefore not noticable. However, if it's borderless, changing it to bordered would require recreating the window so it doesn't help.
If the flash is still bothering you, you could move the window off the desktop immediately (changing its position should be very fast) and then reposition it once it's ready:
sf::RenderWindow window(sf::VideoMode(800, 600), "No White Window Flash", sf::Style::Default);
const sf::Vector2i windowPosition{ window.getPosition() };
window.setPosition({ -2000, -2000 });
window.clear();
window.display();
window.setPosition(windowPosition);
-
In my opinion you're spending way too much time on something that's not even remotely important. Have you ever started any games, especially ones from AAA studios? They all open awkwardly for a few seconds.
I bet there are a lot more important features to work on for your game/application. ;)
-
eXpl0it3r in my opinion and opinion of Hapax its Very important - to not shock players eyes....
Hapax last method NOT work because need say to Window position on screen during Init window from OS.... but.... its maybe REAL logic to avoid "flash" and completely remove....
But its Wrong hack way ))...........
Thank You for Solutions !!!
SFML Team need to improve creation RenderWindow and do VOID screen background during Window creating from OS to avoid "flash white effect".....
YEEEEEEEEEEAAAAAAAAAAAHHHHH I found how AVOID !!!!!!!!!!!!!!!! ))))))))
Few seconds and U will see code....
RenderWindow win;
win.create(VideoMode(800, 600), "My111");
Vector2i w_Pos = win.getPosition();
win.setPosition(Vector2i(-700500, -700500));
win.clear();
win.display();
win.setPosition(w_Pos);
win.clear();
win.display();
-
Not sure that I agree with it being that important, to be fair.
Normally, a window being created is a time when a user will allow minor imperfections. A little flash of white would seem perfectly acceptable to most end-users.
If the flash is still bothering you
I found how AVOID !!!!!!!!!!!!!!!!
[...]
RenderWindow win;
win.create(VideoMode(800, 600), "My111");
Vector2i w_Pos = win.getPosition();
win.setPosition(Vector2i(-700500, -700500));
win.clear();
win.display();
win.setPosition(w_Pos);
win.clear();
win.display();
How is this different from what I suggested?
-
Thx, some modifications +2 strings... to your solution...
-
Final Solution to complete remove flash.
RenderWindow win;
Event ev;
Vector2i win_Pos_Scr;
const unsigned win_sZe_Origin_X = 600;
const unsigned win_sZe_Origin_Y = 550;
win.create(VideoMode(win_sZe_Origin_X, win_sZe_Origin_Y), "ReJewel", Style::Default);
win_Pos_Scr = win.getPosition();
win.setPosition(Vector2i(-700500, -700500));
// here need do trick with resize window
win.setSize(Vector2u(1, 1));
win.setSize(Vector2u(win_sZe_Origin_X, win_sZe_Origin_Y));
win.clear();
win.display();
win.setPosition(win_Pos_Scr);
// skip to not parse resize event
while (win.pollEvent(ev)) {}
-
Much easier is edit WindowImplWin32.cpp
And compile system, then window
////////////////////////////////////////////////////////////
void WindowImplWin32::registerWindowClass()
{
// ...
//windowClass.hbrBackground = 0;
windowClass.hbrBackground = CreateSolidBrush(RGB(0,0,0));
// ...
}