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 - GeoCompute

Pages: [1]
1
Thank you for that, eXpl0it3r.   I may investigate that to better learn how things work with SFML, though at this point the urgency is gone as I've reworked things to move the loading of the font outside the draw routine, as the two of you suggested.

Thanks for the help!  :)
GeoCompute

2
Thank you both for your responses.

In thinking about your advice and how to apply it to my particular situation, I've realized I had a mistake in the way I was thinking of text output.  I was thinking of it in terms of being a primitive graphics command, like drawing a line or a rectangle.  (That's practically all text output was when I last spent a lot of time working on video games: about 30 years ago!  I guess things have progressed a bit since then.  ;) )  You've helped me realize I instead need to think of it as being more like a bitmap or a sound file.  I know the SFML text and font documentation already says as much, but I think my decades-old conditioning was preventing me from fully realizing it.

Laurent, regarding your statement that PR-1345 "was merged in master on 2018-01-25," what is master?  Is that a new build of SFML I would obtain by downloading version 2.4.2 over again from the main download page at <https://www.sfml-dev.org/download/sfml/2.4.2/>?

Thank you both for your time and help  :)
GeoCompute


3
Hi,

I'm having an issue and am wondering if it could possibly be a bug in SFML.  I think it might be related to the issue described at this link <https://github.com/SFML/SFML/pull/1345>, though the symptoms I'm experiencing seem to be quite a bit different.

I'm using SFML 2.4.2.  I don't know how to determine the build number, but I downloaded it on 2017-12-17 in case that helps.

My computer is a Windows 10 Home machine, 64-bit, with an i7, 8.00 GB, AMD Radeon HD 5450, and I'm use Microsoft Visual Studio Community 2017.

Here is the minimal code which consistently reproduces the issue:

Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int __stdcall WinMain(long, long, char *, int)
{
    sf::RenderWindow window;
    sf::Font         font  ;
    sf::Text         text  ;
    sf::Event        event ;

    window.create(sf::VideoMode(500, 300), "My Window");

    auto fnDrawText = [&](int x, int y, char const * sz)
    {
        text.setString(sz);
        text.setPosition(x, y);
        window.draw(text);
    };

    while (window.isOpen())
    {
        window.clear();

        font.loadFromFile("SomeFont.TTF");

        text.setFont(font);
        text.setCharacterSize(10);

        fnDrawText(100, 100, "My Text 1");
        fnDrawText(100, 120, "My Text 2");
        fnDrawText(100, 130, "My Text 1");
     // fnDrawText(100, 160, "ABCDEFG"); // Uncomment this line and everything works

        window.display();

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

With that code as-is, you will only get two lines of code output on the screen and it will be "My Text 2" followed by "My Text 1".  (So the first instance of "My Text 1" is missing.)

If you uncomment the last invocation of fnDrawText, then the output changes and all four lines of text will be output, including the initial instance of "My Text 1" which had previously been missing.

Does anybody have any ideas of what could be causing this?  (I'm a newbie to SFML.)

Thank you,
GeoCompute

Pages: [1]
anything