1
Window / Re: SFML2 -- Possible Bug? Crashing when sf::Mouse::getPosition().x equals 36
« on: September 15, 2012, 10:33:10 pm »
Alright, I'm still having issues but I just found something interesting.
Still using the release client for SFML2, in Codeblocks. I've completely uninstalled codeblocks, MinGW, and removed everything SFML2 related from my computer.
I reinstalled CodeBlocks, it has a default version of MinGW included (I believe is 4.4.1). I've reset every one of the build options within code blocks and tried using dynamic libraries instead of static (the same result).
HOWEVER.
I copied the code on the getting started page on the SFML2 Tutorial page...the one that just draws a circle. It didn't do it. I tried commenting out the code related to the shape, and it still worked fine. I then added an or statement to the window.close if statement in the loop.
This causes the program to close and return no error when X is equal to 36.
While this works normally:
Does anyone have any ideas while this is. I have also tried moving the sf::Keyboard::Escape to it's own else if statement and it still has the same result. Then if you replace sf::Keyboard::Escape with sf::Keyboard::_____ where ____ = any other keyboard Key all it does is crash at a different X location. A crashes all the way at the left of the Window. Return crashes near the 57 mark somewhere.
Is this really just me? Does anyone have any ideas. I'm using the correct debug libraries and not mixing them up.
Edit: I just realized that it is not a crash. For some reason, the mouse hitting those coordinates causes the statement to execute that block of code. So it is executing window.close(). If I change the content of the block to cout << "derp" << endl; then it will output derp to the command prompt.
Still using the release client for SFML2, in Codeblocks. I've completely uninstalled codeblocks, MinGW, and removed everything SFML2 related from my computer.
I reinstalled CodeBlocks, it has a default version of MinGW included (I believe is 4.4.1). I've reset every one of the build options within code blocks and tried using dynamic libraries instead of static (the same result).
HOWEVER.
I copied the code on the getting started page on the SFML2 Tutorial page...the one that just draws a circle. It didn't do it. I tried commenting out the code related to the shape, and it still worked fine. I then added an or statement to the window.close if statement in the loop.
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape)
window.close();
}
window.clear();
window.draw(shape);
window.display();
cout << sf::Mouse::getPosition(window).x << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape)
window.close();
}
window.clear();
window.draw(shape);
window.display();
cout << sf::Mouse::getPosition(window).x << endl;
}
return 0;
}
This causes the program to close and return no error when X is equal to 36.
While this works normally:
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
cout << sf::Mouse::getPosition(window).x << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
cout << sf::Mouse::getPosition(window).x << endl;
}
return 0;
}
Does anyone have any ideas while this is. I have also tried moving the sf::Keyboard::Escape to it's own else if statement and it still has the same result. Then if you replace sf::Keyboard::Escape with sf::Keyboard::_____ where ____ = any other keyboard Key all it does is crash at a different X location. A crashes all the way at the left of the Window. Return crashes near the 57 mark somewhere.
Is this really just me? Does anyone have any ideas. I'm using the correct debug libraries and not mixing them up.
Edit: I just realized that it is not a crash. For some reason, the mouse hitting those coordinates causes the statement to execute that block of code. So it is executing window.close(). If I change the content of the block to cout << "derp" << endl; then it will output derp to the command prompt.