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.


Messages - Yohdu

Pages: 1 [2]
16
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 :)

17
General / Re: Is it possible to run the RenderWindow in the background?
« on: August 03, 2016, 12:37:15 pm »
If you're not on MacOS, yes you can. However, events need to be polled in the same thread (so you're code seems correct)  : http://www.sfml-dev.org/tutorials/2.3/window-window.php

18
Well I'm glad you experienced those same problems! And yeah, when you think about it, it does not really make any sense to have a window which can grow indefinitely (depending on the map size for example).

I'll keep you posted (hopefully by the end of the week) :)

19
General / Re: how to check collision with mouse?
« on: July 25, 2016, 03:00:10 pm »
Can you provide us with your entire code ? (with the game loop and everything...)

EDIT : looking at the code you already provided, the point you are testing is actually not the mouse position. It should be :

sf::Vector2f point = sf::Mouse::getPosition(window)

20
Thank you very much sb :)

Coming back to your initial post, I also did try to put a QSFMLCanvas directly in a QScrollArea, but there was 2 problems :
 - as you said, creating a very large sf::RenderWindow did not seem to be very elegant ;
 - when I used the scroll bars, the scrolling process did not occur very smoothly ; there was like a white trail on the widget side (which would stop in the same time I would stop scrolling).

For my part, I was considering a solution using a class, named like QSFMLScollArea, which would inherits the astract class QAbstractScrollArea. Every QAbstractScrollArea has a viewport as central widget, which contents is the widget to be scrolled. In this case, the widget to be scrolled would be the QSFMLCanvas. Then I would follow the implementation details explained here : http://doc.qt.io/qt-5/qabstractscrollarea.html#details , in order to provide the custom scrollbar features.

I will do some testing to compare your solution and the one I just briefly described above, as soon as I will have the time to do so (meaning : I don't know when ^^). Hopefully I will come back to you if you're still interested :)

21
Hello,

Since you marked this topic as "solved", can you provide us with a solution please ?

I'm very curious about how you did it, because I was thinking about the same problematic like 2 weeks ago (without going into implementation, just having thoughts about this exact same feature I'd like to provide).

Thank you

22
General / Re: Vertical lines shifted ?
« on: July 01, 2016, 03:34:08 pm »
Wow, I actually did not think of drawing every line in a single draw call.
I was also wondering how to draw dotted line efficiently, I now have my answer!

Well, thanks a lot, that was very constructive for me :)

23
General / Re: Vertical lines shifted ?
« on: July 01, 2016, 03:04:17 pm »
Oh really ? I did not look for the implementation of sf::RectangleShape, but I was supposing that it used the vertex primitives to draw.

I'll use the 0.5 offset on line primitives then ! :)

24
General / Re: Vertical lines shifted ?
« on: July 01, 2016, 02:47:11 pm »
Mmmh OK. I think I'll just use sf::RectangleShape to draw my vertical/horizontal lines then, with a width/height of 1 pixel. It seems more practical to me.

Thank you again.

25
General / Re: Vertical lines shifted ?
« on: July 01, 2016, 01:55:12 pm »
Thank you Laurent for your quick answer. So should I just add 0.5 to the x dimension of all of my vertical lines ? What if on another machine it works the other way ?

EDIT : sorry, bad reading from me. So if I add 0.5 to all of my x and y coordinates, there should be no problem anymore ?

EDIT 2 : should I also add 0.5 when drawing bitmaps or shapes (rectangles, circles, ...) ?

I'm not sure to fully understand where the problem comes from. When exactly should I add 0.5 ? When drawing any kind of shapes or primitives ?

26
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 [2]