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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Incatrix

Pages: [1]
1
Window / Re: Fill the Window by color in Fullscreen mode
« on: February 21, 2019, 12:34:25 pm »
The solution of this is creating of delayed loop with clear-display member functions of RenderWindow class and calling It after create or Ctor of the window. 10ms interval is enought. It is solid short time for reduce flashing and long time to completly prepare window for drawing.

2
Window / Re: Fill the Window by color in Fullscreen mode
« on: February 21, 2019, 12:00:25 am »
Using clear-display is without debate, it works well. Support real-time apps is important, all is about how whatever use correctly. It would be wrong just to rely on powerful components which they are today.

Quote
Yes, there can be some load up time, before the window first appears and before the first draw call is rendered. And then there's double buffering, which delays the rendering to the screen by one frame.

Thank You, I thought so.

Creating window with using getDesktopMode(), None style and setting top-left corner position do same work as well. Or...

It could be good create something to tell that window is ready for drawing.

Something like this:

//...
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "", sf::Style::Fullscreen);
window.waitForDraw(&window);
//...
 

where waitForDraw() is optional member function of sf::RenderWindow class to do not let go next until window will not to be completly ready for drawing.

But at the moment it's such a fresh idea..  :)

3
Window / Re: Fill the Window by color in Fullscreen mode
« on: February 20, 2019, 08:36:50 pm »
Yes, for first look It will be right, but issue is just masked behind endless loop (a lot of time was spend to avoid issue). Putting clear and display in main loop is good for dynamic image, not for static. Where calling display one time is enough. There is not place to play just with graphics. But this is not point of my post.

It looks unspecified number of draw iterations are skipped.

//...
window.create(mode, "", sf::Style::Fullscreen);
window.setFramerateLimit(60);

while (window.isOpen()) {
        sf::Event event;
       
        while (window.pollEvent(event)) {
                switch (event.type) {
                        case sf::Event::KeyPressed:
                                window.close();
                }
        }
        window.clear(sf::Color::Red); // Skipped X times before do allright
        window.display();
}
//...
 

Perfectly It is seen in this code:

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <cstdlib>
#include <ctime>

void wait(clock_t frequency, sf::RenderWindow *win);

int main() {   
        sf::VideoMode mode;
        sf::RenderWindow window;

        mode = sf::VideoMode::getDesktopMode();
        if (!mode.isValid()) {
                std::cout << "Window could not be created." << std::endl;
                std::exit(1);
        }

        window.create(mode, "", sf::Style::Fullscreen);
        window.setFramerateLimit(60);

        window.clear(sf::Color::Red); // Fail
        window.display();
        wait(5000, &window);
        window.clear(sf::Color::Green); // Ok
        window.display();
        wait(5000, &window);
        window.clear(sf::Color::Blue); // Ok
        window.display();
        wait(5000, &window);

        while (window.isOpen()) {
                sf::Event event;
       
                while (window.pollEvent(event)) {
                        switch (event.type) {
                                case sf::Event::KeyPressed:
                                        window.close();
                        }
                }

                window.clear(sf::Color::Black); // Ok
                window.display();
        }
       
        return 0;
}

void wait(clock_t frequency, sf::RenderWindow *win) {
        sf::Event event;

        clock_t start = clock();
        while ((clock() - start) < frequency) {
                while (win->pollEvent(event));
        }
}
 

It could be pass between Red, Green, Blue and Black color after five secs. But red part doesn't work. Default and Non style of window work well, Fullscreen style not.

4
Window / Fill the Window by color in Fullscreen mode
« on: February 20, 2019, 12:20:35 am »
Hi SFML lovers :),

I have a simple program, where I want create the window in Fullscreen mode, where parameters are same as an user actually has and fill It by choosen color (Red). For this I used getDesktopMode() to detect user's parameters of the window.

Code here:
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <cstdlib>

int main() {   
        sf::VideoMode mode;
        sf::RenderWindow window;

        mode = sf::VideoMode::getDesktopMode();
        if (!mode.isValid()) {
                std::cout << "Window could not be created." << std::endl;
                std::exit(1);
        }

        window.create(mode, "", sf::Style::Fullscreen); // None or Default is OK
        window.setFramerateLimit(60);
       
        window.clear(sf::Color::Red); // It doesn't work with Fullscreen
        window.display();
       
        while (window.isOpen()) {
                sf::Event event;
               
                while (window.pollEvent(event)) {
                        switch (event.type) {
                                case sf::Event::KeyPressed:
                                        window.close();
                        }
                }
        }
       
        return 0;
}
 

When I try create the window and set Fullscreen style, window will be create. For sure I use isValid() fuction to confirm to this mode is valid in Fullscreen. Up to here all is allright.

Next I want to set backround color of the window to red. But It doesn't work, just It flash from red to white and stay white until keypressed (to the end of the program). Where is problem? When I use Default style or None style, It works. Window will be filled by red. This is what I want, but I want to do with Fullscreen style.

And my question is:

How to fill the Window correctly by red color in Fullscreen style? Just sf::Style::Fullscreen of the window I want to use.

Thank You for your hints and help.

Incatrix

Pages: [1]