SFML community forums

Help => Graphics => Topic started by: Kylotan on October 31, 2012, 08:29:25 pm

Title: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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.)
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: eXpl0it3r 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. ;)
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Laurent on October 31, 2012, 09:12:48 pm
Could you please show a complete and minimal code that reproduces the problem?
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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]
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Laurent 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?
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: thisdyingsoul 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.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: FRex on November 01, 2012, 05:23:42 pm
There are nightly builds in general forum for some compilers.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: eXpl0it3r 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...
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan 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.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Laurent 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 ;)
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 01, 2012, 08:28:55 pm
I'm using a Radion HD 5750 (and version 12.10 of the drivers,) and I experience the same problem using the latest source.  Well, not quite the latest -- I haven't updated for the static library fix.  While playing around with the code Kylotan provided to show the issue, I found that changing either of the background or outline alpha settings to 0 (or setting the outline thickness to 0) caused the text to display properly.  I also noticed that drawing the rectangle elsewhere on the screen still seems to screw up the display of the text.

When I put together some code to test multiple scenarios in one run, that behavior disappeared, so I suspect it had something do with the initial state of the graphics subsystem.

This was the code for reference:
#include <SFML/Graphics.hpp>

struct Scenario {
    sf::Color background ;

    sf::Color box_fill ;
    sf::Color box_outline ;
    sf::Vector2f box_position ;
    sf::Vector2f box_size ;
    float box_outline_thickness ;

    sf::Text text ;
};

void doScenario(sf::RenderWindow& window, const Scenario& s) ;

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

    sf::Font font ;
    font.loadFromFile("sketchflow.ttf") ;
   
    sf::Text text("abcdefgh", font) ;
    text.setPosition(sf::Vector2f(10.0f,10.0f)) ;
    text.setCharacterSize(20) ;

    const sf::Color bg(10, 30, 10) ;
    const sf::Vector2f offTextPos(10.0f, 100.0f) ;
    const sf::Vector2f throughTextPos(10.0f, 25.0f) ;
    const sf::Vector2f onTextPos ( 10.0f, 10.0f ) ;

    const sf::Color fill_alphaOff(128, 128, 128, 0) ;
    const sf::Color fill_alphaOn(128, 128, 128, 255) ;
    const sf::Color fill_alphaMid(128, 128, 128, 128) ;

    const sf::Color outline_alphaOff(255, 255, 255, 0 ) ;
    const sf::Color outline_alphaOn(255, 255, 255, 255) ;
    const sf::Color outline_alphaMid(255, 255, 255, 128) ;

    const float thicknessOn = 2.0f ;
    const float thicknessOff = 0.0f ;
   
    const sf::Vector2f rectSize(100, 30) ;

    Scenario scenarios[] =
    {
        // bg color, box_fill, box_outline, box_position, box_size, box_outline_thickness
        { bg, fill_alphaOn, outline_alphaOn, onTextPos, rectSize, thicknessOn, text },
        { bg, fill_alphaOn, outline_alphaOn, throughTextPos, rectSize, thicknessOn, text },
        { bg, fill_alphaOn, outline_alphaOn, offTextPos, rectSize, thicknessOn, text },

        { bg, fill_alphaOn, outline_alphaOn, offTextPos, rectSize, thicknessOff, text },
        { bg, fill_alphaOff, outline_alphaOn, offTextPos, rectSize, thicknessOn, text },
        { bg, fill_alphaOn, outline_alphaOff, offTextPos, rectSize, thicknessOn, text },

        // text shows correctly only for these two cases:
        { bg, fill_alphaOff, outline_alphaOn, offTextPos, rectSize, thicknessOff, text },
        { bg, fill_alphaOff, outline_alphaOff, offTextPos, rectSize, thicknessOn, text }
    };

    for ( unsigned i=0 ; i<sizeof(scenarios)/sizeof(scenarios[0]); ++i )
        doScenario(window, scenarios[i]) ;
}

bool processEvents( sf::RenderWindow & window )
{
    bool continueProcessing = true ;
    sf::Event event ;
    while ( window.pollEvent(event) )
    {
        switch (event.type)
        {
        case sf::Event::Closed:
            continueProcessing = false ;
            window.close() ;
            break ;

        case sf::Event::KeyReleased:
            continueProcessing = false ;
            break ;
        }
    }
    return continueProcessing ;
}

void doScenario( sf::RenderWindow& window, const Scenario& s )
{
    sf::RectangleShape rect ;

    rect.setPosition(s.box_position) ;
    rect.setSize(s.box_size) ;
    rect.setFillColor(s.box_fill) ;
    rect.setOutlineColor(s.box_outline) ;
    rect.setOutlineThickness(s.box_outline_thickness) ;

    const sf::Text & t = s.text ;

    while ( window.isOpen() && processEvents(window) )
    {
        window.clear(s.background);
        window.draw(rect) ;
        window.draw(t) ;
        window.display() ;
    }
}
 

Result:
(http://img72.imageshack.us/img72/2636/fonttesto.png)
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan on November 01, 2012, 09:08:36 pm
He asked because in the latest sources there's no more default font, and you said you used the latest sources ;)
Ok, I'd rebuilt against the new headers, but forgot to copy the new DLLs over. Now I've done that, as you would expect, the text doesn't render at all - but once I add in a font and load a TTF into it, I get the same problem as I did before.

I guess Cire has shown that it's not just my system though, for which I'm thankful!
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: FRex on November 01, 2012, 09:17:23 pm
Try setting shapes texture to something not white(ie 512x512 magenta image) to see if it'll affect the white quads of text.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 01, 2012, 09:44:33 pm
The only thing that affects the color of the quads is the text color.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: FRex on November 01, 2012, 09:50:07 pm
That's supposed to happen. Does drawing vertex array instead of shape break text? Do sprites draw ok after drawing shape? Seems like it 'forgets' to set the font texture.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 01, 2012, 09:53:21 pm
Actually, if you load a texture for rect, the text does display correctly.  I typo'd the texture's file name and didn't notice it.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: FRex on November 01, 2012, 10:01:04 pm
Do sprites render ok after untextured shape? Does text render badly after untextured vertex array?
It seems like it can't distunguish between no texture and font texture. Also try: create few textures(sf::Texture dummy1; way, don't do anything with them) and then create shape, font instance and text and try that.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 01, 2012, 10:22:35 pm
Sprites do not render correctly after an untextured shape. (I get the shape of the sprite with the general color of the texture, unless the rectangle is not rendered due to alpha settings, in which case the sprite renders normally.)

Using a default constructed texture for the rectangle, there is no change rendering text from not using a texture at all.  For the sprite, nothing is rendered at all, even in the cases where the rectangle is not rendered due to alpha settings.

Just creating a texture (or textures) has no effect at all, as one would expect.

When drawing all 3, as long as the sprite is rendered after the text, it is always rendered correctly, and the same is true of the text, if the sprite is rendered prior to it.  The only thing that seems to be affected is what's rendered directly after an untextured (or default-textured) shape.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Laurent on November 01, 2012, 10:43:13 pm
It's late and my tired brain is unable to decode your last post. Could you please write a very small code that shows the simplest scenario that fails?

Thanks ;D
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 01, 2012, 11:43:08 pm
Sure.

#include <SFML/Graphics.hpp>

const sf::Vector2f box_size(100.0f, 30.0f) ;
const sf::Vector2f box_pos(10.0f, 100.0f) ;
const sf::Vector2f text_pos(10.0f, 10.0f) ;

sf::Text text ;

void waitForEnter( sf::RenderWindow& w)
{
    bool waiting = true ;
    while ( waiting )
    {
        sf::Event event ;
        if ( w.pollEvent(event) && event.type == sf::Event::KeyPressed )
            if ( event.key.code == sf::Keyboard::Return )
                waiting = false ;
    }
}

int main()
{
   sf::RenderWindow window(sf::VideoMode(150, 150), "Test");
   sf::RectangleShape box(box_size) ;
   box.setPosition(box_pos) ;

   box.setOutlineThickness(2.0f) ;  /* REQUIRED FOR RENDERING FAILURE */

   sf::Font font ;
   font.loadFromFile("sketchflow.ttf") ;
   text.setString("abcdefgh") ;
   text.setFont(font) ;

   // rendered correctly.
   window.clear() ;
   window.draw(box) ;
   window.draw(text) ;
   window.display() ;

   waitForEnter(window) ;

   // not rendered correctly.
   window.clear() ;
   window.draw(box) ;
   window.draw(text) ;
   window.display() ;

   waitForEnter(window) ;
}

If I run this as-is I see:
(http://img28.imageshack.us/img28/8628/textl.png)

If I substitue a sprite for the sf::Text object, I see:
(http://img31.imageshack.us/img31/9549/spritexp.png)

If I never set the outline thickness, everything would render correctly.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: thisdyingsoul on November 02, 2012, 04:20:21 am
Well...
if you comment this:
//box.setOutlineThickness(2.0f) ;  /* REQUIRED FOR RENDERING FAILURE */
and change the first draw order:

// window.draw(box) ;
// window.draw(text) ;  
   window.draw(text) ;
   window.draw(box) ;

You get the error again.. in the second draw o.O.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 02, 2012, 04:23:53 am
The error was occuring in the second draw.  If you parse the images from left to right, the order matches that shown in the code.  Thus the "// not rendered correctly" comment in the code.

Although, I didn't try the reverse order without setting the thickness.

[edit:  Nope.  Everything renders correctly no matter which order is used if the thickness isn't set for me. ]
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan on November 02, 2012, 04:28:57 pm
Hey, I just want to say thanks to you all for the effort put in to examining this problem.

I can confirm that I see Cire's results with his test code. With the code as posted, I get the blocky text on the second rendering. If I comment out the setOutlineThickness call, the text is fine both times.

I can also confirm thisdyingsoul's results: if I comment out the setOutlineThickness call, AND swap the order of the first 2 draw calls, the second text rendering is broken.

However, if I swap both sets of draw calls (ie. so it's text before box, both times), leaving setOutlineThickness commented out - then the text is fine both times.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 02, 2012, 05:28:55 pm
Mm..  when I made the change to test, I didn't notice he specified only changing the first draw order and not the second.  If I only change the first draw order and comment out the thickness change, I do, indeed, also get the goofed up rendering.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan on November 06, 2012, 01:27:12 am
Anybody got any idea what can be done about this? A workaround maybe?
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Tiseno on November 07, 2012, 03:02:54 am
I made this http://en.sfml-dev.org/forums/index.php?topic=9624 (http://en.sfml-dev.org/forums/index.php?topic=9624) post with the same problem, and i have found some new things to add to this very peculiar bug.

I (almost (see Case 3)) only get the bug when drawing 2 Shapes, not with 1. The 2 Shapes yields the same result as one Shape with the setOutlineThickness(2.0f);.

If you have several Sprites with the same texture, only the first of one type of texture will not work. Thus if you try to draw 3 Sprites with Texture 1 (and some RectangleShapes or whatnot to get the bug) they will not work, but after that you can draw a Sprite with another Texture and after you have drawn that one you can draw the first Texture!

It's hard to explain in text so here is the code used and some images:
#include "stdafx.h"
#include <SFML/Graphics.hpp>

using namespace sf;

int main(){

        RenderWindow window(VideoMode(150, 140, 32), "SFML", Style::Default);
        window.setFramerateLimit(4);

        CircleShape fooShape(20.0f, 30);
        CircleShape barShape(25.0f, 30);
        fooShape.setPosition(10.0f, 10.0f);
        barShape.setPosition(70.0f, 20.0f);

        Texture aTexture1;
        aTexture1.loadFromFile("texture1.png");
        Texture aTexture2;
        aTexture2.loadFromFile("texture2.png");

        Sprite sprite1;
        sprite1.setTexture(aTexture1);
        sprite1.setPosition(15.0f, 100.0f);
        Sprite sprite2;
        sprite2.setTexture(aTexture1);
        sprite2.setPosition(40.0f, 100.0f);
        Sprite sprite3;
        sprite3.setTexture(aTexture1);
        sprite3.setPosition(65.0f, 100.0f);
        Sprite sprite4;
        sprite4.setTexture(aTexture2);
        sprite4.setPosition(90.0f, 100.0f);
        Sprite sprite5;
        sprite5.setTexture(aTexture1);
        sprite5.setPosition(115.0f, 100.0f);
        Sprite sprite6;
        sprite6.setTexture(aTexture1);
        sprite6.setPosition(40.0f, 50.0f);

        bool drawFoo = false;
        bool drawBar = false;
        bool drawOtherSprites = true;
        bool drawTexture2 = true;
        bool drawMiddle = false;

        while(window.isOpen()){
                Event Event;
                while(window.pollEvent(Event)){
                        if(Event.type == Event.KeyPressed){
                                if(Event.key.code == Keyboard::U){/*Choose if drawing first shape*/
                                        if(drawFoo) drawFoo = false;
                                        else        drawFoo = true;
                                }else if(Event.key.code == Keyboard::I){/*Choose if drawing second shape*/
                                        if(drawBar) drawBar = false;
                                        else        drawBar = true;
                                }else if(Event.key.code == Keyboard::O){/*Choose if drawing other sprites than the first and the middle-Sprite*/
                                        if(drawOtherSprites)    drawOtherSprites = false;
                                        else                    drawOtherSprites = true;
                                }else if(Event.key.code == Keyboard::P){/*Choose if drawing Sprite with texture2*/
                                        if(drawTexture2)        drawTexture2 = false;
                                        else                    drawTexture2 = true;
                                }else if(Event.key.code == Keyboard::L){/*Choose if drawing texture1 Sprite between drawing of shapes*/
                                        if(drawMiddle)  drawMiddle = false;
                                        else            drawMiddle = true;
                                }
                        }
                }      
                window.clear(Color(200, 100, 40));
                if(drawFoo)
                        window.draw(fooShape);
                if(drawMiddle)
                        window.draw(sprite6);
                if(drawBar)
                        window.draw(barShape);

                window.draw(sprite1);
                if(drawOtherSprites){
                        window.draw(sprite2);
                        window.draw(sprite3);
                        if(drawTexture2)
                                window.draw(sprite4);
                        window.draw(sprite5);
                }
                window.display();
        }
        return EXIT_SUCCESS;
}
(I'm using Visual C++ 2010 Express, a XFX Radeon 5750 graphics card and i updated to the latest SFML 2.0 build today)

Case 1.
(http://img546.imageshack.us/img546/7862/sfmlbug.png)
All Sprites.                        Only the first few are affected. When not drawing second textured sprite, all are affected.


Case 2.
I also noticed a difference when i have transparency in my Textures:
(http://img87.imageshack.us/img87/6459/sfmlbugtransparent.png)
Exactly the same as before but with transparency instead of white background.

As seen the partially transparent Textures will not draw anything at all instead of a white box.


Case 3.
Also, when drawing only the first Sprite, it will be affected by the bug after one of the Shapes have been set to not drawing, furthermore if i then start drawing the other Sprites it will take exactly 1 frame to update and show all the Textures correctly:
(http://img689.imageshack.us/img689/9237/sfmlbug2.png)
Bug.                                 Still Bug.                           This will show for exactly one frame and then revert to this.

This is the reason of window.setFramerateLimit(4); in the code, because it will not be noticeable with a framerate of 60 or even 10.


Case 4.
As you said in the posts before, after a Shape has been drawn, the Sprites after that one will not work, in my case, after 2 shapes, and if i draw one Sprite of texture1.png, between those two Shapes, everything will render normally, except if i remove the middle Sprite and then draw it again, it will produce something like in Case 3.

This is way too much info, but if any one can get something out of this I'm happy to help!
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Laurent on November 07, 2012, 08:50:04 am
Hi

This is the 3rd report in two weeks, I think you should create an issue on the task tracker with a link to the corresponding forum thread(s).

Unfortunately I can't reproduce the error with my PC, and looking at the code I can't see anything wrong :(
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: farmer on November 07, 2012, 09:15:04 pm
Using the latest beta catalyst drivers (12.11 Beta) seemed to have cleared the issue up for me.

http://support.amd.com/us/gpudownload/windows/Pages/radeonaiw_vista64.aspx#1

Last download link on the above page.

XFX 7950 DD, win7 64bit

-farmer
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan on November 07, 2012, 09:48:07 pm
NB: I typed all this out before Farmer posted!


I've tried running this example through AMD's GPU PerfStudio and it seems like everything is called from SFML the way you'd expect. There's one glDrawArrays call made for each shape and sprite, the most recent glBindTexture call is always to the texture you expect (or 0 for the shapes), and glGetError always returns GL_NO_ERROR after every single operation.

However when I grab a freeze frame under GPU PerfStudio, the frame it shows at that point always has the first 4 quads missing (whether everything has been rendering correctly or not) - not even rendered as a white block (as in Tiseno's examples above) or a black one (as I've been seeing locally with Tiseno's code).

So, it looks to me very much like a bug in the AMD drivers.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan on November 07, 2012, 10:09:24 pm
Confirmed: updating the drivers to the 12.11 Beta version (dated 7th November 2012) fixes the problem for me.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 07, 2012, 10:13:07 pm
Doubly confirmed.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Laurent on November 07, 2012, 10:19:12 pm
Excellent timing. Or maybe it was introduced by the previous version of the driver, and they rushed to fix it?
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: cire on November 08, 2012, 01:13:00 am
It occurred with 12.9 too.  Wasn't quite up-to-date the first time I tried it.  Driver updates have been pretty frequent lately, though.  I wouldn't be surprised if it was something that got borked up recently.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan on November 08, 2012, 03:31:05 am
It turns out that the beta drivers crash Dishonored, so bear their experimental status in mind if you upgrade to get round this bug. I can't say I'm too happy with AMD really - seems they routinely put out drivers that break things.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Kylotan on November 08, 2012, 08:43:26 pm
This bit of code is helping me work around the issue. Anywhere you need to render text or sprites and it sometimes renders wrongly, insert a call to this function right before it to ensure the texture will get re-bound properly. It's a hacky thing that creates a 1x1 texture and draws a sprite with it offscreen.

#include <SFML\Graphics.hpp>
void WorkaroundAMDBug(sf::RenderWindow* window)
{
        static sf::Texture amdWorkaroundImage;
        static sf::Sprite sprite;

        if (amdWorkaroundImage.getSize() == sf::Vector2u(0,0))
        {
                amdWorkaroundImage.create(1, 1);
                sprite.setTexture(amdWorkaroundImage);
                sprite.setPosition(-20, -20); // offscreen
        }
        window->draw(sprite);
}
 
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Mr. Wonko on November 11, 2012, 12:13:29 am
After spending all afternoon and half the night trying to track this down I can confirm it's an ATI driver issue and is fixed in the new beta drivers.

Apparently happens when you do glDrawArrays(GL_TRIANGLE_STRIP) - the next glTexCoordPointer() won't actually happen until after the next glDrawArrays() or something stupid like that, causing texture coordinates to be wrong in that call, which could be a Text, or a Sprite, or something custom... Most annoying. That's 8 hours I could've spent doing something more important for Fuck This Jam!
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: NON on December 08, 2012, 01:12:08 am
This bit of code is helping me work around the issue.
Thanks!! I had the problem in my project too. After checking everything relevant, I could have sworn I didn't do anything wrong, then I found this thread. Your hack fixed the problem.

Guess I'll have to leave the hack in the code until the official 12.11 drivers has been out for at least a year or so.
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: Spodi on December 17, 2012, 05:45:24 am
Great, thanks Kylotan! I was getting plagued by this bug as well. At least the hacky fix doesn't come with much perf cost. :)
Title: Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
Post by: venom1270 on January 02, 2013, 10:40:44 am
Hi I'm new here, sorry if this post is a little late!

I briefly read through this thread and wanted to share my alternate temporary fix (that has almost no impact on performance I hope)

I noticed that only the first sf::Text that is drawn will be blocky, so I just fixed it by adding another sf::Text (set to position -100, -100) and draw it before all others.

I hope it works for you too!