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
1
General / Re: Screen Artifacts with QSFMLWidget and QDockWidget
« on: October 17, 2016, 09:05:20 am »
Hello!

I cannot try your code at the moment, but I myself had (and still have !) some issues integrating properly SFML with Qt. Did you try handling resize events:
  • from the sf::RenderWindow perspective (and reset the sf::View with the proper width/height)?
  • from the QtWidget perspective (and force a repaint at this moment)?
Not sure it will help, I'll try your code when I have time :)

2
General / Re: Quick Question about objects and tiles
« on: October 05, 2016, 08:51:51 am »
In my opinion, it may be useful to have both.

When you set the position of your game objects on the map, if you manage to compute the tile(s) that are containing it (which is quite straight-forward), then it is a good solution to have your tiles owning reference to these items so that you can directly check the tile(s) that your character is on.

However, you could also at some point in your game have to iterate through all the objects on your map for whatever reason. In that case, it would be better to have a container having a reference to all of these objects. This container could be a std::vector, but it also could be a more advanced data model like a binary/quad tree to spacially divide your map and accessing faster to specific game objects for example.

So yeah, both solutions are good, it really depends on your game and what you want to achieve with it.

3
General / Re: Failed to load image with right quote
« on: October 03, 2016, 10:31:47 am »
OK then :) Thank you again.
If I ever manage to make it work and/or simply have new informations, I'll share it with you guys.

4
General / Re: Unresolved External Symbols
« on: October 03, 2016, 10:27:44 am »
Others may have a better answer than mine, but here are some questions/remarks:

- stupid question: are you able to compile properly a simple program which does not use sfml ?

- in debug mode, did you link the libraries with the "-d" suffixe ?

- what kind of project did you create in Visual Studio ? Console or Windows program ?
        => I always link the sfml-main[-d].lib library in my project, even though in a console program I don't have to.

- if you are linking dynamically, the libraries: opengl32.lib; freetype.lib; jpeg.lib; winmm.lib; flac.lib; vorbisenc.lib; vorbisfile.lib; vorbis.lib; ogg.lib; ws2_32.lib are useless (only use those with the sfml prefix).

- are you absolutely sure you downloaded the MSVC14 pre-compiled binaries for 32 bits windows ?

- did you try creating a new fresh project? Once it happens to me that a one of my project got corrupted.

Hope it helps  :-\

5
General / Re: Where is...
« on: October 03, 2016, 10:13:23 am »
Quote
VS 2015 is functioning weird
What do you mean exactly ?  ;D

6
General / Re: Failed to load image with right quote
« on: October 01, 2016, 09:07:14 pm »
I actually already tried this solution, but loading the image using it fails. Still, thank you Laurent.

Note that the image is properly loaded by Qt using QPixmap.

I guess the problem is not coming from the convertion operation, but from the loading step. Could it be possible that the loadfromfile method is not properly handling sf::String containing some UTF-32 characters (or this particular ’ character)?

I also need to try my code using another compiler (like MSVC), even though it would be weird that the problem comes from the compiler... Still open to suggestions :)

7
General / Re: Failed to load image with right quote
« on: September 29, 2016, 11:48:43 am »
Because I'm implementing a environment where the user can load any image file (using Qt) ; I could indeed warn him that the loaded images should not contain any weird characters, but meh I'm not really satisfied with this solution, he should be able to load any file which name has been approved by the OS he uses.

8
General / Re: Failed to load image with right quote
« on: September 29, 2016, 09:08:16 am »
Sorry to up this but I really need help on this one.

I've tried about anything I could imagine, and I do not manage to properly convert a QString to a sf::String in order to load a file with SFML. A lot of special characters are well-handled (éèàë etc.), but this character    ’    is not, and I don't know why.

I'm summoning you, Ô honorable SFML experts  ;D

9
General / Re: Questions about making tiled game
« on: September 27, 2016, 07:57:34 pm »
Quote
Interesting... But is it always faster then multiple draw(sf::Sprite) calls? Or if your map is super duper large then it becomes more efficient to draw only the tiles within your sf::View?

I'm not an expert so I cannot answer with absolute certainty, but yes I would assume that at some point it would become more efficient to draw only the tiles in the sf::View.

But that's actually a question I've been asking to myself : doesn't sf::View mechanism already imply that only visible items are drawn ?

If not, there is still the possibility to draw what the sf::View sees in a single draw operation using vertices ;)

10
General / Re: Questions about making tiled game
« on: September 26, 2016, 09:01:26 pm »
There is a faster way, you can actually draw your 1024x1024 tiles in a single draw operation using vertices. Have a look at the tilemap example here : http://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php

11
General / Re: Failed to load image with right quote
« on: September 26, 2016, 02:14:26 pm »
Quote
Might be related to https://github.com/SFML/SFML/issues/647
Indeed it seems related, thank you for the link.

EDIT: Actually, I don't know. My code works well with characters like éèàë or even the classic apostroph character. The problematic character is the french apostroph (and I assume there must be other similar problematic characters). I really don't know what to think.

Quote
QString offers a lot of conversion options, e.g. data() returns a UTF-16 byte array which you can load into an sf::String
Can you show me the piece of code that performs this operation ? I'm not quite sure how to manipulate the data() method  with the sf::String class.

EDIT 2: I tried with other QString conversion operations (tostd16 / to std32), it indeed works as to stdwstring, but I still have the problem that the french apostroph character is not recognized properly.

12
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

13
General / Re: QSFMLCanvas in QTabWidget : flickering
« on: August 25, 2016, 11:20:25 am »
Sure, here is a link to dl a video showing the flickering problem : http://crz.se/7102
If needed, here is a link to dl the project as-is : http://crz.se/7101

I tried changing the frametime argument but it doesnt seem to change anything

14
General / Re: QSFMLCanvas in QTabWidget : flickering
« on: August 25, 2016, 10:51:44 am »
Thank you for your answer. Unfortunately, I already tried (and I just tested it again) this, but it does not change anything :s

15
General / Re: [SOLVED] SFML inside QT: sf::RenderWindow and QScrollArea
« on: August 25, 2016, 10:09:09 am »
OK, so I know it's a bit late, but here is my implementation.

ScrollingMapCanvas.hpp
class ScrollingMapCanvas : public QAbstractScrollArea
{
public:
    ScrollingMapCanvas(MapCanvas* mapCanvas, QWidget *parent = Q_NULLPTR);

    MapCanvas* mapCanvas() const;

protected:
    void resizeEvent(QResizeEvent* event);
    void scrollContentsBy(int dx, int dy);

private:
    MapCanvas* m_mapCanvas;
};

ScrollingMapCanvas.cpp
ScrollingMapCanvas::ScrollingMapCanvas(MapCanvas* mapCanvas, QWidget* parent) :
    QAbstractScrollArea(parent)
{
    m_mapCanvas = mapCanvas;
    m_mapCanvas->setParent(viewport());

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
}

void ScrollingMapCanvas::resizeEvent(QResizeEvent* /*event*/)
{
    QSize areaSize = viewport()->size();
    m_mapCanvas->resize(areaSize);

    //add 1.f to width and height to see the end of the grid
    int width = (m_mapCanvas->map()->size().x * m_mapCanvas->map()->tileSize().x + 1) / m_mapCanvas->scale();
    int height = (m_mapCanvas->map()->size().y * m_mapCanvas->map()->tileSize().y + 1) / m_mapCanvas->scale();
    QSize mapSize = QSize(width, height);

    horizontalScrollBar()->setPageStep(areaSize.width());
    verticalScrollBar()->setPageStep(areaSize.height());
    horizontalScrollBar()->setRange(0, mapSize.width() - areaSize.width());
    verticalScrollBar()->setRange(0, mapSize.height() - areaSize.height());
}

void ScrollingMapCanvas::scrollContentsBy(int dx, int dy)
{
    m_mapCanvas->translate(sf::Vector2f(-dx * m_mapCanvas->scale(), -dy * m_mapCanvas->scale()));
}

MapCanvas* ScrollingMapCanvas::mapCanvas() const
{
    return m_mapCanvas;
}

MapCanvas is the class which inherits from QSFMLCanvas, it has a Map object (which owns in particular the size of the map and the tile size for the map), a translation (sf::Vector2f) and a scaling factor (for zoom). These 2 last attributes are used by an internal sf::View to update the camera at each frame.

Here you go, if you have any suggestion to improve it, I will gladly receive them !

Pages: [1] 2