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

Author Topic: sf::Shape rendering seems to break sf::Text rendering (2.0RC)  (Read 24829 times)

0 Members and 2 Guests are viewing this topic.

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« on: October 31, 2012, 08:29:25 pm »
I am rendering a lot of text to the screen, and usually it works correctly, but I've found that when I render sf::Shapes too, especially when there are a lot of shapes, the text rendering breaks. Specifically, it looks like either the text texture gets lost or the blending is broken because each glyph is rendered as a filled white square instead of showing the character.

This isn't consistent and it appears that one text can render wrongly while the very next text can appear correctly, with no other rendering taking place between the two. But it only happens when shapes are being drawn in that frame. Commenting out calls to a shape's draw() method fixes the behaviour.

It's as if some part of the rendering state is leaking out from one call to another - but we're just calling draw() on each Drawable without passing in a RenderStates argument, so I would have thought it would reset to normal on each call.

I'm using the default font for all text, but it happened with loaded fonts also (TTF or OTF).

Is this a known bug in SFML? Or if not, is there some way I can help in tracking down what is causing this?

(Using the April 2.0RC build, on Windows 7.)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #1 on: October 31, 2012, 08:33:09 pm »
Well the default font is depreciated and already removed in newer versions of SFML, but as you said it's most probably no the source.

I'd kind of guess that you're doing something wrong since I haven't heard of such a problem yet, thus you should provide a complete and minimal example that reproduces the problem. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #2 on: October 31, 2012, 08:45:21 pm »
Newer versions? As far as I can tell 2.0RC is the newest version that can be downloaded without building it myself, no? And the live docs say nothing about the default font being deprecated.

As for a minimal example, that's probably not going to happen in the short term so I'm trying to find out if this is a known problem that may have been fixed since 2.0RC.

All I can say, is that we never change the RenderStates, or the Font, but sometimes the text doesn't work, and sometimes it does.
« Last Edit: October 31, 2012, 08:54:46 pm by Kylotan »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #3 on: October 31, 2012, 09:12:48 pm »
Could you please show a complete and minimal code that reproduces the problem?
Laurent Gomila - SFML developer

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #4 on: October 31, 2012, 09:29:43 pm »
As mentioned above, that's unlikely to happen right now. It's a fairly complex project with lots of what gets rendered being conditional on various in-game values, and it'll be quite slow to clone it all and simplify it. However the actual rendering part is simple so I was hoping someone might have some ideas on what could be going wrong.

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #5 on: October 31, 2012, 10:15:04 pm »
Actually, I got lucky and found a quick repro case.


#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(900, 900), "Test");

        sf::RectangleShape shOutline;
        sf::Text tName;

        tName.setPosition(sf::Vector2f(10,10));
        tName.setCharacterSize(20);
        tName.setString("Abcdefgh");
        shOutline.setPosition(sf::Vector2f(10,10));
        shOutline.setSize(sf::Vector2f(100,30));
        shOutline.setFillColor(sf::Color(128,128,128,128));
        shOutline.setOutlineColor(sf::Color(255,255,255));
        shOutline.setOutlineThickness(2.0);

        while (1)
        {
                sf::Color darkGreyGreen(10, 30, 10, 255);
                window.clear(darkGreyGreen);

                window.draw(shOutline);
                window.draw(tName);

                window.display();
        }
}
 

The result is shown in the image attached.

And if I comment out window.draw(shOutline), the text renders normally.

[attachment deleted by admin]
« Last Edit: October 31, 2012, 10:17:29 pm by Kylotan »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #6 on: October 31, 2012, 10:35:53 pm »
It works for me (with the latest sources). What's your OS and graphics card? Are your graphics drivers up to date?
Laurent Gomila - SFML developer

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #7 on: October 31, 2012, 11:00:22 pm »
Windows 7, AMD Radeon HD 6800 Series (not sure exactly which model, since the Catalyst Control Center doesn't tell me!), latest drivers (12.10).

Note that I'm not using the latest source, but the most recent binary download.
« Last Edit: October 31, 2012, 11:03:07 pm by Kylotan »

thisdyingsoul

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #8 on: November 01, 2012, 01:00:32 am »
Nice, the same problem ^^.
Same config as above, but Radeon HD 5800.
And I´m just get the latest src to verify.
« Last Edit: November 01, 2012, 01:04:46 am by thisdyingsoul »

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #9 on: November 01, 2012, 05:19:43 pm »
thisdyingsoul, did you get the same result with the latest source? I don't want to have to go through the build process unless I'm confident that it will fix the problem.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #10 on: November 01, 2012, 05:23:42 pm »
There are nightly builds in general forum for some compilers.
Back to C++ gamedev with SFML in May 2023

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #11 on: November 01, 2012, 06:16:05 pm »
Ah, thank you! I just got the latest nightly and tested with that, and I still see the same problem.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #12 on: November 01, 2012, 06:26:04 pm »
Ah, thank you! I just got the latest nightly and tested with that, and I still see the same problem.
And what font did you use?
It works perfectly fine on my end...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #13 on: November 01, 2012, 06:49:13 pm »
See the example code above - it uses the default font on Windows. (Arial?) However in my full program I get the same results with other TTF and OTF fonts.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #14 on: November 01, 2012, 07:43:18 pm »
He asked because in the latest sources there's no more default font, and you said you used the latest sources ;)
Laurent Gomila - SFML developer