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 25073 times)

0 Members and 1 Guest are viewing this topic.

Tiseno

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #30 on: November 07, 2012, 03:02:54 am »
I made this 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.

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:

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:

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!

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 #31 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 :(
Laurent Gomila - SFML developer

farmer

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #32 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
« Last Edit: November 07, 2012, 09:19:01 pm by farmer »

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #33 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.

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #34 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.

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #35 on: November 07, 2012, 10:13:07 pm »
Doubly confirmed.

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 #36 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?
Laurent Gomila - SFML developer

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #37 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.

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #38 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.

Kylotan

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #39 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);
}
 

Mr. Wonko

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #40 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!

NON

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #41 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.
« Last Edit: December 08, 2012, 01:13:50 am by NON »

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #42 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. :)

venom1270

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: sf::Shape rendering seems to break sf::Text rendering (2.0RC)
« Reply #43 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!