So I finally made the change over, and brought up a test project to test some things out. Linking the to lib folder alone gave me errors about missing dll's, so I linked to the bin folder that has the dll's for SFML in it and then the program ran just fine. But when I close the SFML window, I get a VS Just-in-time debugger error. Which is weird to say the least considering I don't even have VS installed on my computer anymore.
It's telling me I have "An unhandled win32 exception in Test.exe[4996]" then goes on to tell me no installed debugger has JIT debugging enabled, and how to get it for VS.
Running in release mode gives me the missing DLL error I had earlier, which I could have sworn I fixed for both release and debug. According to the SFML website, the release and debug libs are in the same directory and I have the same directories linked for both release and debug.
EDIT:
Fixed the DLL issue. Have to add "-2" to sfml-xxx in the linked libraries. And the program now works just fine with no errors in release mode. Still giving me the unhandled exception in debug though
I believe the release would link to, say, sfml-window-s-2, while the debug would link to sfml-window-s-d-2. At least, there needs to be a "-d" there somewhere.
Yea I got the linking issue resolved, as says my edit. Didn't know the SFML2 dll's added a -2 to their names.
Laurent of SFML pointed me towards some threads regarding my main issue. I guess it is a known issue dealing with the getDefaultFont() function that gets called automatically by the sf::Text constructor. Which is kind of annoying because that means if I want to have text anywhere, I have to load my own font file into it, which I currently know nothing about. I didn't even know fonts had files.
I think the general thing/point is that sfml is made to access hardware rendering. If you want text/buttons/etc in a simple way then you would want to use Qt or some other UI library. Mix the two together. You know, otherwise you have to make a button via jpeg or something (which is probably easier to add the text to that), and then the only way to press the button would be to figure out where on the window the mouse was clicked and see if that was a "button".
You might see some of my posts over at the sfml board. I'm not particularly happy with the responses I got, sort of told me that I shouldn't want to do the things I want to do.
I'm pretty sure someone actually wrote their own UI library over at the SFML forums. You could try looking through the projects forum.
Anyway, loading a font is actually ridiculously easy. Font is its own class, so you can reuse the same font for all your text.
To load a font, just create an sf::Font object and call loadFromFile("FontName.ttf").
I think you can specify the font size as well after the name.
Font files are usually in the ttf (true type font [?]) format, and you can probably find the ones installed with Microsoft under Windows/Fonts
Just remember that they are copyrighted, so if you want to release your project google around for some free fonts. Should be relatively easy to find what you want.
@ResidentBiscuit
Did the threads Laurent pointed you to suggest if this issue is on windows only? I stepped through it with the debugger last night and the crash appears to be coming from the deletion of sharedContext
WglContext.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
WglContext::~WglContext()
{
// Destroy the OpenGL context
if (m_context)
{
if (wglGetCurrentContext() == m_context)
wglMakeCurrent(NULL, NULL);
wglDeleteContext(m_context);//<-- debugger takes me from here to dtor below
}
// Destroy the device context
if (m_deviceContext)
ReleaseDC(m_window, m_deviceContext);
// Destroy the window if we own it
if (m_window && m_ownsWindow)
DestroyWindow(m_window);
}
GlContext.cpp
1 2 3 4 5 6 7 8 9 10 11 12
void GlContext::globalCleanup()
{
// Destroy the shared context
delete sharedContext; //<-- seems to crash here.
sharedContext = NULL;
// Destroy the internal contexts
sf::Lock lock(internalContextsMutex);
for (std::set<GlContext*>::iterator it = internalContexts.begin(); it != internalContexts.end(); ++it)
delete *it;
internalContexts.clear();
}
I dont have SFML2 settup in my linux VM yet to test if it is Windows only.