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.


Topics - Incatrix

Pages: [1]
1
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]
anything