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

Author Topic: Getting window not responding error when program starts  (Read 6511 times)

0 Members and 2 Guests are viewing this topic.

AstroThing

  • Newbie
  • *
  • Posts: 4
    • View Profile
Getting window not responding error when program starts
« on: November 21, 2015, 05:57:49 am »
I am running SFML2 on Fedora 22 along with Box2D and I am working on Eclipse Mars, whenever I start my program I get a "[Window name] is not responding" error, however the program is still running fine so I don't know why I am getting this error every time.

Has this occurred to anyone else before, if so, how can I fix this?
Thanks for the help!

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Getting window not responding error when program starts
« Reply #1 on: November 21, 2015, 09:31:02 am »
Any chance you forgot to handle window events? If you don't poll or wait for them, the SFML window won't respond to the window manager, causing that issue. Can't do further guesses without at least seeing some of your code.

AstroThing

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Getting window not responding error when program starts
« Reply #2 on: November 21, 2015, 07:31:27 pm »
Any chance you forgot to handle window events? If you don't poll or wait for them, the SFML window won't respond to the window manager, causing that issue. Can't do further guesses without at least seeing some of your code.
Hey Mario, thanks for responding. I believe I am handling events by having the while loop with the window.pollEvent(event) function. Here is my whole main.cpp, is there something that I am forgetting or doing wrong?

Code: [Select]
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <Box2D/Box2D.h>

#include "Entities/Entity.h"
#include "Entities/Planet.h"
#include "Entities/Asteroid.h"
#include <vector>

using namespace std;
using namespace sf;

int main()
{
//Window settings
RenderWindow window(VideoMode::getDesktopMode(), "Orbiter");
window.setFramerateLimit(60);

//World settings
b2Vec2 gravity(0.0f, 0.0f);
b2World world(gravity);

//Entities
Entity::init(&world, &window);
vector<Entity*> entities;

float planetX = window.getSize().x/2.f;
float planetY = window.getSize().y/2.f;
entities.push_back(new Planet(planetX, planetY, 0.25f, "assets/planets/Planet-8.png"));
((Planet*)entities[0])->setGravityForce(500.0f);

entities.push_back(new Asteroid(100.0f, 100.0f, 1.0f, "assets/asteroid.png"));
entities.push_back(new Asteroid(800.0f, 700.0f, 1.0f, "assets/asteroid.png"));

//*DELETE*
b2Vec2 force(215.f, -15.f);
entities[1]->getBody()->ApplyForce(force, entities[1]->getBody()->GetWorldCenter(), true);
entities[1]->getBody()->SetAngularVelocity(10.f);

entities[2]->getBody()->ApplyForce(force, entities[1]->getBody()->GetWorldCenter(), true);
entities[2]->getBody()->SetAngularVelocity(-15.f);

bool paused = false;

while(window.isOpen())
{
Event event;
while(window.pollEvent(event))
{
if(event.type == Event::Closed)
window.close();
if(event.type == Event::KeyPressed && event.key.code == Keyboard::Return)
{
paused = paused ? false : true;
}
}

if(!paused)
{
//Logic
world.Step(1/60.f, 8, 3);
((Asteroid*)entities[1])->step(&entities);
((Asteroid*)entities[2])->step(&entities);

//Drawing
window.clear(Color::Black);
entities[0]->draw();
entities[1]->draw();
entities[2]->draw();
window.display();
}
}

return 0;
}
« Last Edit: November 21, 2015, 07:50:31 pm by AstroThing »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Getting window not responding error when program starts
« Reply #3 on: November 21, 2015, 07:55:06 pm »
This is a known bug in SFML 2.3.1. Make sure you are using SFML 2.3.2.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

AstroThing

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Getting window not responding error when program starts
« Reply #4 on: November 21, 2015, 08:14:48 pm »
This is a known bug in SFML 2.3.1. Make sure you are using SFML 2.3.2.
I first tried SFML2.3.2 by downloading it and copying the files, it compiled fine but I still got this "Window not responding" error. Then later I deleted the files and installed it through dnf with the command: "dnf install SFML-devel" and the package that got installed was SFML-devel-2.3.2-1.fc22.x86_64 and I am still having this same problem while I get no compilation errors.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Getting window not responding error when program starts
« Reply #5 on: November 22, 2015, 10:00:52 am »
Could you try building from the master branch on GitHub? Your code looks fine (ignoring some weird ways to do some things :) ).

If you want to flip a boolean value, you could just use paused = !paused;. Also note that you should at least draw something while the game is paused, you could just skip game logic handling to achieve a "paused" game (don't forget to still check for unpausing).

AstroThing

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Getting window not responding error when program starts
« Reply #6 on: November 22, 2015, 10:48:28 pm »
Could you try building from the master branch on GitHub? Your code looks fine (ignoring some weird ways to do some things :) ).

If you want to flip a boolean value, you could just use paused = !paused;. Also note that you should at least draw something while the game is paused, you could just skip game logic handling to achieve a "paused" game (don't forget to still check for unpausing).
I uninstalled the package downloaded from dnf and built SFML from the Github master branch, the error window still shows up.  :( Could it be an error with Fedora or something else? What I have noticed is that sometimes the program starts with a barely scaled down resolution. I have a perfect circle on screen and when that happens I can see how that circle gets a little bit distorted, when this happens the error window does not show up but it does when the program starts with normal resolution. It's hard to try to replicate this though, it happens like 1 out of 20 times of clicking run.

And you are right about the pause boolean value and that it should draw when paused, thanks for telling me.  :P