Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Very strange SFML string behaviour in qt creator  (Read 6424 times)

0 Members and 1 Guest are viewing this topic.

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Very strange SFML string behaviour in qt creator
« 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.");


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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Very strange SFML string behaviour in qt creator
« Reply #1 on: January 08, 2013, 05:02:54 pm »
Make sure that you're not using release libs in debug mode.
Laurent Gomila - SFML developer

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Very strange SFML string behaviour in qt creator
« Reply #2 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:



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)
« Last Edit: January 08, 2013, 05:58:42 pm by Octav23 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Very strange SFML string behaviour in qt creator
« Reply #3 on: January 08, 2013, 06:50:48 pm »
Can you show your code?

Are your OpenGL drivers up-to-date?
Laurent Gomila - SFML developer

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Very strange SFML string behaviour in qt creator
« Reply #4 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
« Last Edit: January 08, 2013, 07:46:51 pm by Octav23 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Very strange SFML string behaviour in qt creator
« Reply #5 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.
Laurent Gomila - SFML developer

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Very strange SFML string behaviour in qt creator
« Reply #6 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Very strange SFML string behaviour in qt creator
« Reply #7 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.
Laurent Gomila - SFML developer

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Very strange SFML string behaviour in qt creator
« Reply #8 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
« Last Edit: January 09, 2013, 02:04:59 pm by Octav23 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Very strange SFML string behaviour in qt creator
« Reply #9 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?
Laurent Gomila - SFML developer

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Very strange SFML string behaviour in qt creator
« Reply #10 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:


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

My gcc version is 4.6.2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Very strange SFML string behaviour in qt creator
« Reply #11 on: January 09, 2013, 03:06:17 pm »
Are you sure? That's SFML 1.6, not 2.0.
Laurent Gomila - SFML developer

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Very strange SFML string behaviour in qt creator
« Reply #12 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Very strange SFML string behaviour in qt creator
« Reply #13 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.
Laurent Gomila - SFML developer

Octav23

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Very strange SFML string behaviour in qt creator
« Reply #14 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

 

anything