I'm having an incredibly novice issue while following the tutorial for Visual Studio with SFML (
http://www.sfml-dev.org/tutorials/2.2/start-vc.php). I have almost everything working with the sample code provided by the tutorial to test that I set up the project and linking fine:
#include "stdafx.h"
#include "SFML/Graphics.hpp"
int main(int argc, _TCHAR* argv[])
{
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;
}
However, when I try to run the code, I get the following error:
Unhandled exception at 0x0000000000000000 in HelloWorld.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
I've had a bit of experience in the distant past with the C# binding of SFML, and remembered that x64 and x86 can't mix (which was also pretty visible around on the internet), and had fixed that before I tried running the program, so it seems like that isn't the issue here. (I
am running the x64 version, though I honestly don't need to be)
What I did find is that when I comment out the following line/code:
window.draw(shape);
the program stops crashing, and shows the SFML window. No matter what I do to what's being drawn on the screen, I can't seem to make the error stop appearing without simply not drawing anything (which unfortunately doesn't help much).
For reference/full disclosure, here are .lib I linked into the project:
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;sfml-system-s-d.lib;winmm.lib;openal32.lib;sndfile.lib;sfml-window-s-d.lib;opengl32.lib;winmm.lib;gdi32.lib;sfml-graphics-s-d.lib;freetype.lib;glew.lib;jpeg.lib;opengl32.lib;
More Details: I'm statically linking, and have taken the extra step needed that I understood from the tutorial (add the SFML_STATIC; to one of the project properties). I've also checked that I am in-fact running in debug mode. I did remove the sfml-audio-s-d.lib to make sure that wasn't somehow the issue, though I did leave its dependencies in the linker list.
EDIT: Quick Summary: window.draw(shape); is mysteriously, single-handedly crashing the tutorial code from (
http://www.sfml-dev.org/tutorials/2.2/start-vc.php) into an unhandled exception. It most definitely is a novice mistake. I will gladly accept any suggestions/help.
I've done a good amount of searching online for the issue, but I haven't been able to find a solution in any of the posts. For the moment, I'm completely out of ideas on things to double-check. If you have any suggestions or things for me to try, I'd greatly appreciate it.
-Gab C