SFML community forums

Help => General => Topic started by: Octav23 on January 08, 2013, 04:45:52 pm

Title: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 08, 2013, 04:45:52 pm
I've set up SFML with qt creator, it renders windows like it should, however it treats strings very weird.
 - If I try to set a location/path to a sprite for example "resources\\mysprite.png" it will say "Cannot find" then it will show me some very weird strings in the console, with symbols all over, and when trying to write this line of code:

sf::RenderWindow winMain(sf::VideoMode(500, 500, 32), "This works.");
(http://puu.sh/1LdOk)

The title looks like this, it's really weird, in fact I've never seen anything like this, I'm not sure it's a fault of SFML, but I've only encountered it in SFML sittuations.
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 08, 2013, 05:02:54 pm
Make sure that you're not using release libs in debug mode.
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 08, 2013, 05:32:32 pm
I added this:
CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-system -lsfml-window
CONFIG(debug, debug|release): LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-network-d -lsfml-system-d -lsfml-window-d

And everything SEEMS to work, even the strings do, however I am getting something strange here, look at my console:

(http://puu.sh/1LeCS)

I'm getting a ton of those, what do I do? All sprites appear as boxes and such in the game, and I'm getting those errors. Any ideas? (Thanks again for the fast answer by the way :D)
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 08, 2013, 06:50:48 pm
Can you show your code?

Are your OpenGL drivers up-to-date?
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 08, 2013, 07:06:26 pm
Can you show your code?

Are your OpenGL drivers up-to-date?

My code is pretty huge, but it can't be the code, I ported over the source from a game I wrote in VS2010 where I had set up SFML and boost, and the code worked 100% so I don't think it's my OpenGL drivers or the source code (Source code does compile without errors or even warning on both qt creator and VS2010)

For the record, by "porting" I mean I just added the source files (About 14) to my qt creator project which is a simple SFML project.

Also I'd like to add that the code also works in Codeblocks, and on both IDEs it shows the sprites and such perfectly, without the openGL things, I'm not sure what's causing it. It's pointing to Texture.cpp in the SFML sources so I don't think it's my code
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 08, 2013, 08:34:50 pm
You should try a small app (just a main() with a texture and a window), so that we can work on something minimal and focus on relevant stuff.
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 08, 2013, 08:45:07 pm
You should try a small app (just a main() with a texture and a window), so that we can work on something minimal and focus on relevant stuff.

I have, and everything works nicely, it's really annoying because the same code worked flawlessly in VS and codeblocks.

Even if it was my code, what could be causing it to pull off all those OpenGL errors if it works great on other IDEs?
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 08, 2013, 08:53:30 pm
If a minimal code works, then try to reproduce your error on another minimal example. It's hard to debug such an error in a complete application.
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 09, 2013, 02:00:08 pm
OK it turns out it's not actually my code, initially when Laurent suggested me to write a minimal app I did, but it was simply displaying a basic window with a title, nothing else, when I tried getting a sprite on the screen, it also worked, but when closing the program I got the OpenGL errors again. I don't think it's my code, all I have right now is 1 file: main.cpp, this is my code:

#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
using namespace std;

int main()
{
    sf::RenderWindow winMain(sf::VideoMode(500, 500, 32), "My window.");
    sf::Event ev1;

    sf::Texture text;
    text.loadFromFile("resources\\textlogo.png");
    sf::Sprite spr(text);
    spr.setPosition(100, 100);

    while(winMain.isOpen())
    {
        while(winMain.pollEvent(ev1))
        {
            if(ev1.type == sf::Event::Closed) winMain.close();
        }

        winMain.clear();
        winMain.draw(spr);
        winMain.display();
    }
}

Any other ideas? The code above does work, it does display a sprite on the screen but it shows 1 error of the OpenGL type for each sprite that I try to draw, and this happens when I close the program, unlike my previous game where all the openGL errors would happen when I was starting the program. Very odd, I truly have no idea how to fix this

EDIT:
I just made a check to see what my current OpenGL driver is, running this code:

sf::RenderWindow window(sf::VideoMode(500, 500, 32), "something");
    sf::ContextSettings settings = window.getSettings();
    std::cout << settings.majorVersion << "." << settings.minorVersion << std::endl;

The output is: 3.3
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 09, 2013, 02:11:50 pm
Did you compile SFML yourself? If not, where did you get it? And what's your version of gcc?
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 09, 2013, 02:47:03 pm
Did you compile SFML yourself? If not, where did you get it? And what's your version of gcc?
No, I didn't compile SFML myself, what I did was download this:
(http://puu.sh/1LA0P)

Then unpacked it in my F:\ directory, and set it up for each IDE in particular.

My gcc version is 4.6.2
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 09, 2013, 03:06:17 pm
Are you sure? That's SFML 1.6, not 2.0.
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 09, 2013, 03:27:11 pm
Are you sure? That's SFML 1.6, not 2.0.
No, my bad, I rushed when I took the screenshot, I downloaded the first link in the 2.0 snapshot location at the download page, it's called "Windows 32 bits - GCC DW2 (11.5 MB)"

Sorry about that, my bad
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 09, 2013, 03:33:02 pm
And are you sure that your gcc is a DW2 one? (you can check with "gcc -v")

To make sure that it's not a version mismatch, you should recompile SFML yourself.
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 09, 2013, 03:47:37 pm
And are you sure that your gcc is a DW2 one? (you can check with "gcc -v")

To make sure that it's not a version mismatch, you should recompile SFML yourself.
I checked if it's a version mismatch and it's not (months ago before I bought this new computer I had a version mismatch, and it wasn't behaving like this, it was essentially flooding me with errors which isn't the case now)

I also checked the gcc and it is
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 09, 2013, 09:41:36 pm
OK here's what I tried: I uninstalled the entire QT sdk and IDE from my computer and re-downloaded SFML in the same location, however now it won't even recognize the SFML setting. It's the same .pro file as before:

TEMPLATE = app
CONFIG += console
CONFIG -= qt

INCLUDEPATH += F:/SFML-2.0-rc/include
INCLUDEPATH += D:/boost_1_51_0

LIBS += -LF:/SFML-2.0-rc/lib

CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-system -lsfml-window
CONFIG(debug, debug|release): LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-network-d -lsfml-system-d -lsfml-window-d

SOURCES += main.cpp

However it's telling me "Cannot open include file  'SFML/System.hpp': No such file or directory and all I did was #include <SFML/System.hpp>

Is my .pro file alright? Why is it so difficult to set up SFML on qt creator?
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 09, 2013, 10:16:29 pm
I have no idea what's wrong, your project file looks good. But since I can't check what's on your hard drive and where it is, I can't say if it should work or not.

It's not more difficult to setup SFML with QtCreator. Include paths, linker paths, input libraries, it's the same stuff everywhere. And yet people continue to have problems because of stupid errors, whatever IDE they use ;)
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 10, 2013, 02:32:35 pm
For some reason restarting my computer magically made SFML work again on the fresh install of qt creator. I'll run a test again and tell you what happens.
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Octav23 on January 10, 2013, 02:37:25 pm
Everything works now. A fresh install of qt creator did the trick (God I've been struggling for this for a long time).

Thank you a ton Laurent, your graphical library has helped me immensely in my career as a beginner game developer, it's truly a gem in the many graphical libraries out there and I'll never switch to anything else  :D
Title: Re: Very strange SFML string behaviour in qt creator
Post by: Laurent on January 10, 2013, 02:38:54 pm
Thank you :)

I'm glad you solved your problem.