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

Author Topic: on start,window freezes  (Read 7265 times)

0 Members and 1 Guest are viewing this topic.

Grimnack

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
on start,window freezes
« on: April 05, 2021, 09:27:33 pm »
So the window on starting,simply freezes.All i see is the border of the window and the desktop background.Even with the simplest example on this website,i get that rezult.

#include <SFML/Window.hpp>
int main()
{
    sf::Window window(sf::VideoMode(800, 600), "My window");
    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }
    }
    return 0;
}
Now this doesn't happen with renderWindow,but renderWindow starts and quits immediatly.
At least he starts....i get a glimpse of the window.
I use Ubuntu  Mate 20.04.2 LTS 64bit
latest sfml
gcc 9.3.0
Thoughts?

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: on start,window freezes
« Reply #1 on: April 05, 2021, 10:50:22 pm »
you forgot to clear and display the window

window.clear()
window.display()

inside the 'while(window.isOpen){' loop


EDIT: one more thing, you should use sf::RenderWindow, not sf::Window.
« Last Edit: April 05, 2021, 11:35:07 pm by Stauricus »
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Grimnack

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: on start,window freezes
« Reply #2 on: April 05, 2021, 11:28:53 pm »
error: ‘class sf::Window’ has no member named ‘clear’.
I think those are for renderWindow class.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: on start,window freezes
« Reply #3 on: April 06, 2021, 01:29:58 am »
it is, i edited my post above. do you have any particular reason to use sf::Window? if you just want to have a minimalist SFML window, use RenderWindow.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Grimnack

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: on start,window freezes
« Reply #4 on: April 06, 2021, 10:05:13 pm »
i dont have any particular reason to use sf::Window.Just following examples on the website.So i have no practical need to sf::Window?
sf::renderWindow would suffice for all my needs?

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: on start,window freezes
« Reply #5 on: April 07, 2021, 01:37:54 am »
yes, sf::RenderWindow is the 'default' window for SFML programs. it inherits from sf::Window, which would be more targeted to using some OpenGL calls directly.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

 

anything