Use of sf::RenderWindow causes a segmentation fault on linux mint - sfml

I'm trying to get SFML working on LinuxMint 18, the Cinnamon version, but I get a segmentation fault, whenever I use sf::RenderWindow.
I installed SFML 2.4.2 by downloading the 64-bit Linux Version from the official website, as
sudo apt-get install libsfml-dev
strangely didn't install the libraries.
Using something different, like sf::Clock works perfectly fine.
I'm using the code from the SFML website, posted below:
#include <SFML/Graphics.hpp>
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();
}
return 0;
}
Any suggestions?
EDIT: I'm not running Linux Mint in any Virtual Machine. I'm dualbooting with Windows 10. Also the segmentation fault happens to be an invalid pointer error.

Related

(SFML library) RenderWindow constructor throws exception

I am getting started with SFML with Visual Studio 2019. I followed this tuttorial and launched the app successfuly. But without any changes to the code I launched it one more time and it gives me this error:
Exception thrown at 0x53582687 (sfml-system-2.dll) in Voidger.exe: 0xC0000005: Access violation reading location 0x0000016E. occurred
on this line:
RenderWindow window(VideoMode(200, 200), "SFML works!"); //not really
Ever since the app will output the same error and will occasionaly create a window if some magic stars allign. When I discovered the error I tried to create a new project but had issue with linker so abanded it as the other app didn't even start.
Here is the full code (provided on official website):
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
using namespace sf;
int main()
{
std::cout << "H\n";
RenderWindow window(VideoMode(200, 200), "SFML works!"); // error line
CircleShape shape(100.f);
shape.setFillColor(Color::Green);
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
The funniest thing is that the code always launches, outputs the h in cmd and most of times exits with code -1073741819.
Edit:
Here is config manager settings that I use.

Visual Studio SFML tutorial graphics not displaying properly

I'm not sure if this is a problem with Visual Studio (I'm using Visual Studio Community 2017) or SFML. I've followed the configuration process on https://www.sfml-dev.org/tutorials/2.4/start-vc.php and used their tutorial code. SFML is indeed configured but test graphic image is not displaying correctly according to the tutorial, and everything seems stretched vertically.
#include <SFML/Graphics.hpp>
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();
}
return 0;
}
If you're using a notebook with dual-GPU, then your Intel GPU driver is outdated and it has a bug, where it would setup the OpenGL "drawing area" on a window wrongly. Alternatively, you can force your application to run on the dedicated GPU.

Cannot Load clui.dll

for some reason when i try to compile and run this program following the Official SFML Website Tutorial:
#include <SFML/Graphics.hpp>
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();
}
return 0;
}
I get this error:
Severity Code Description Project File Line Suppression State
Error C1510 Cannot load language resource clui.dll. SFMLPractice1 >c:\Users\NAME\documents\visual studio >2015\Projects\SFMLPractice1\SFMLPractice1\CL 1
I need help on sorting this out.. Please Help!
You can move on to Visual Studio 2017 and install "VC++ 2015.3 v14.00 (v140) toolset for desktop". clui.dll seems to be inside this component.

SFML Window Not Rendering Shape

#include <SFML/Graphics.hpp>
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();
}
return 0;
}
This is directly from the tutorial's page, and I've checked and rechecked, so I know this is not a syntax or linker error.
When I run this program, I get a window whose contents are the same as whatever the place it is located in. Yet, if I remove the window.draw(shape) command, I see a black window, like I should.
I'm compiling on Windows 7 (32 bit) using mingw32-g++.exe (4.7.1). Oh, and it's the same if I compile debug or release and static or dynamic, so that's not the problem either.
Your code is correct, but to me it looks like you need to set the position of your circle. I maybe wrong here but the position could be any value and that is why it isn't displaying.
Could you try updating your code to this please.
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
shape.setPosition(50f, 50f);
shape.setScale(2,2); // You can remove this line if you want to, I just put it there for debugging
while (window.isOpen())
{
...
Here is the SFML documentation for setPosition (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Transformable.php#a4dbfb1a7c80688b0b4c477d706550208)
Here is the SFML documentation for setScale (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Transformable.php#aaec50b46b3f41b054763304d1e727471)
Let me know if that fixes your problem.

SFML won't open a window?

So, as the title suggests, I am trying to create a simple Window using SFML 1.6 in CodeBlocks (MinGW v.4.7.0) on Windows 7 (no, I'm not using an ATI GPU).
This is the code:
#include <SFML/Window.hpp>
int main()
{
sf::Window App(sf::VideoMode(800, 600, 16), "SFML Window");
App.Display();
return 0;
}
Whenever I try to run this code, it just says Program.exe is not responding and has to be shutdown using Close this program. The funny thing is, the first tutorial offered on the SFML tutorial website (the one utilizing sf::Clock in a console) works, so the libraries are loaded properly.
Can someone help me find the cause of the error I'm getting?
Other than the crash, I get no compiler or application errors.
The problem is that you haven't created the main loop which polls for events and handles OS messages. Append this to main() (yes, this is a snippet from the SFML documentation):
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Clear the screen
App.Clear();
// Put your update and rendering code here...
// Update the window
App.Display();
}
It is therefore not necessary for you to call App.Display() after you create the window.
For those who want the whole thing, this is a snippet extracted from the SFML website.
#include <SFML/Window.hpp>
int main()
{
sf::Window window(sf::VideoMode(800, 600), "SFML 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;
}
You will get: