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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Yohdu

Pages: [1]
1
General / Failed to load image with right quote
« on: September 25, 2016, 09:38:46 pm »
Hello,

I'm facing some weird behaviour when trying to load some files. I'm working in a french windows environment, and when i press the windows + print screen buttons it takes a screenshot and save it as "Capture d’écran (4).png"

Then when I try to load it using the loadFromFile method of the sf::Texture class, it fails. After many test, it seems that the problem is coming from the ’ character, which is different from the usual ' (quote character). And when i replace this character with any other (in the loading code AND in the image name of course), I successfully manage to load the texture.

Is this some kind of bug or am i doing something bad ?

Here is the minimal example code to reproduce my problem :

#include <string>
#include <SFML\Graphics.hpp>

int main(int argc, char* argv[])
{
        sf::RenderWindow window(sf::VideoMode(640, 480), "SFML works!");
       
        std::wstring path(L"Capture d’écran.png"); //DOES NOT WORK
        //std::wstring path(L"Capture d'écran.png"); //WORKS
        sf::String sfPath(path);

        sf::Texture texture;
        texture.loadFromFile(sfPath);
        //texture.loadFromFile("Capture d’écran.png"); //WORKS
        sf::Sprite sprite(texture);

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

                window.clear();
                window.draw(sprite);
                window.display();
        }

        return 0;
}

EDIT: in case you are wondering, I HAVE TO use the std::wstring intermediary in my context (converting QString to sf::String)

Thank you

2
General / QSFMLCanvas in QTabWidget : flickering
« on: August 25, 2016, 09:47:52 am »
Hello,

In order to implement (or try at least) a map editor using Qt and SFML, I implemented the QSFMLCanvas as described in the tutorial http://www.sfml-dev.org/tutorials/1.6/graphics-qt.php and http://becomingindiedev.blogspot.fr/2013/10/qt-5-and-sfml-20-integration.html (for sfml 2.X integration). It works well when I use it in a simple container.

But now I would like the user to be able to open several maps at the same time, using tabs. So I simply have a QTabWidget in which I add the opened qsfmlcanvas. Each time I open one, a have a small flickering effect just when the qsfmlcanvas appears. I also have this flickering effect sometimes when I change tab, here again when the qsfmlcanvas appears.

It is not a "big" problem, but still it's quite ugly and it hurts my eyes each time i open a new map.

I know it may not ne a pure SFML problem, but it is also not a pure Qt problem, so here I am... Do you have any idea of what may cause this flickering, and how to fix it ?

Thank you in advance :)

3
General / [SOLVED] Vertical lines shifted ?
« on: July 01, 2016, 01:44:13 pm »
Hello everyone,

I'm currently tryring to implement a tile map editor using sfml and Qt, and I am meeting some kind of a problem/bug when drawing vertical and horizontal lines. I can easily work around it, but it just does not feel right to me :).

Here is a code snippet that reproduces my problem :

    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!");

    sf::Vertex hLine[] =
    {
        sf::Vertex(sf::Vector2f(0, 0)),
        sf::Vertex(sf::Vector2f(150, 0))
    };

    sf::Vertex vLine[] =
    {
        sf::Vertex(sf::Vector2f(0, 0)),
        sf::Vertex(sf::Vector2f(0, 150))
    };

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

        window.clear();
        window.draw(hLine, 2, sf::Lines);
        window.draw(vLine, 2, sf::Lines);
        window.display();
    }
 

My question is : how is it that I can see the horizontal line but not the vertical one ?

If I add an offset of 0.01 for the x dimension of the vertical line, I can see it. But why ?
Now, if I try to move the lines at the extreme opposite of the window (hLine at y = 600 and vLine at x = 800), I can now see the vertical line but not the horizontal line. It makes sense regarding the initial issue, but then again it does not feel right, the two dimensions should work the same way...

Here are some related topics, they talk about a "0.375 offset issue", but it was supposed to be solved a long long time ago.

http://en.sfml-dev.org/forums/index.php?topic=15747.0
http://en.sfml-dev.org/forums/index.php?topic=14504
https://github.com/SFML/SFML/issues/252

Thank you in advance for your answers :)

Pages: [1]