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

Author Topic: Text rendering broken on my machine when using sf::Shape  (Read 26311 times)

0 Members and 3 Guests are viewing this topic.

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Text rendering broken on my machine when using sf::Shape
« Reply #15 on: November 27, 2012, 03:24:38 pm »
I still don't understand how other libraries do just fine, Laurent. Other OpenGL libraries draw text just fine. While it's true it seems to be an ATI thing it's obviously not an absolute 100% ATI bug; there is a design flaw in SFML somewhere that is being missed. I've been able to do nothing for more than two weeks now because of this. ATI won't respond to my bug report, you don't seem to want to do anything about it; I am at a total deadlock right now.

It's obvious there are numerous people having issues with text. I hate to be the asshole, but something needs to be done on SFML's part. Ask yourself what you know about your code, Laurent, and why other libraries work just fine and SFML doesn't. Sure, ATI might be to blame, but there has to be something you can do with SFML - even if it's a patch or a hotfix that certain users can download for solving text problems.

As we deduced from the thread I had created, it's not freetype. If it's not freetype, and it's not the code built on top of SFML, and we don't have the ability to magically change the source code of the drivers, the only other component that can be changed in the equation is SFML.

This bug is killing productivity. It needs to be fixed. I really, really don't want to have to switch back to SDL because of this. I'm tired of pushing back release dates because of things that shouldn't be happening. People are asking why and all I can say is "I don't know, it's the graphics library I use. It simply doesn't work".
« Last Edit: November 27, 2012, 03:45:47 pm by Qix »
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Text rendering broken on my machine when using sf::Shape
« Reply #16 on: November 27, 2012, 03:42:49 pm »
...it's not freedraw. If it's not freedraw...
FreeType I assume... ;)

Although I didn't follow the whole other thread and thus don't have as much insight as Qix, but I agree.
Then again we all know that Laurent has little time on his hands and iirc he has a Nvidia card, so maybe we (as a community) can hunt down the problem and try fixing it and I'm sure he'll try to be as much of a help as possible. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Text rendering broken on my machine when using sf::Shape
« Reply #17 on: November 27, 2012, 03:48:59 pm »
...it's not freedraw. If it's not freedraw...
FreeType I assume... ;)

Although I didn't follow the whole other thread and thus don't have as much insight as Qix, but I agree.
Then again we all know that Laurent has little time on his hands and iirc he has a Nvidia card, so maybe we (as a community) can hunt down the problem and try fixing it and I'm sure he'll try to be as much of a help as possible. ;)

Oops, you're right; edited. Was getting confused with "libdrawtext".

I'd be totally up for testing and helping getting this fixed; it's just a matter of Laurent willing to admit there needs to be a fix ;)

I have several systems with ATI cards that I can test on and whatnot, but I honestly don't know where to go as far as testing/debugging from here. I need a little direction.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

opatut

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Text rendering broken on my machine when using sf::Shape
« Reply #18 on: November 27, 2012, 03:53:17 pm »
Quote
Also, I noticed that Rectangles (and Shapes in general) use triangles (a rectangle has 6 vertices), and sprites and font glyphs only 4. Maybe that is where it breaks...
If it was that, sprites wouldn't work either on your PC.

If only text is broken, the cause is not that trivial.
Well, sprites break as well... if I draw the font page texture using a sprite, it shows as a white square, if I draw a normal sprite, I think the same is happening. I was using a sprite texture that has a transparent pixel on the top left corner, and when drawing that directly after 2 shapes, it does not display anything. I will test it again with a test texture, seeing if only the top left pixel gets drawn across the full size... brb ;)

Edit: yes, definitely same error with sprites. So the problem seems to be only about tex coords (vertices are correct, only the top left pixel of the texture is drawn across all of the mesh).

so maybe we (as a community) can hunt down the problem and try fixing it and I'm sure he'll try to be as much of a help as possible. ;)
...
I have several systems with ATI cards that I can test on and whatnot, but I honestly don't know where to go as far as testing/debugging from here. I need a little direction.

You can start by cloning SFML from github, baking it (cmake etc., see tutorial page), installing it to /usr/local/lib/, taking the test source from the pastebin in my OP, compiling it, and running it with LD_LIBRARY_PATH=/usr/local/lib/...
« Last Edit: November 27, 2012, 03:56:44 pm by opatut »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Text rendering broken on my machine when using sf::Shape
« Reply #19 on: November 27, 2012, 04:02:52 pm »
Quote
Other OpenGL libraries draw text just fine
Please tell me which ones you've tested, so that I can compare source code.

Quote
there is a design flaw in SFML somewhere that is being missed
Don't say this please. Because a driver bug is hard to exhibit, doesn't mean that there's a design flaw in SFML. Driver bugs are usually a combination of several small (and unrelated) things, and all libraries do things differently; unfortunately this time the winner is SFML, but it doesn't mean that my code is wrong (I'm pretty sure it is correct).

Quote
yes, definitely same error with sprites. So the problem seems to be only about tex coords
And what about shapes?
An interesting test would be to use normalized coordinates and disable the texture matrix, but there are a few different things to change in the source code, and I can't do it right now. Remind me next week if I haven't done anything ;D
You can also try the "Shader" SFML example, especially the effect which distords text.
Laurent Gomila - SFML developer

opatut

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Text rendering broken on my machine when using sf::Shape
« Reply #20 on: November 27, 2012, 04:03:58 pm »
And more testing was done and I found another solution. I uncommented all the caching stuff from RenderTarget::draw, so every draw call would do all the required OpenGL calls itself, not trusting them to be still present, and added a pushGLStates() on top and popGLStates() on bottom. It worked. So the caching is the problem. Seems like the ATI drivers don't keep the states as others do :( Are you sure you can expect them to do so or is it just undefined behaviour ?
« Last Edit: November 27, 2012, 04:06:05 pm by opatut »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Text rendering broken on my machine when using sf::Shape
« Reply #21 on: November 27, 2012, 04:16:35 pm »
Quote
And more testing was done and I found another solution. I uncommented all the caching stuff from RenderTarget::draw, so every draw call would do all the required OpenGL calls itself, not trusting them to be still present, and added a pushGLStates() on top and popGLStates() on bottom. It worked.
Great. Now, could you try to find which call or OpenGL state exactly solves the problem? Because what you describe involves a lot of stuff.

Quote
So the caching is the problem. Seems like the ATI drivers don't keep the states as others do  Are you sure you can expect them to do so or is it just undefined behaviour ?
OpenGL is a state machine. A state keeps its value until it is explicitely changed. It wouldn't make sense if the driver was doing hidden random changes.

I'm not going to explain how OpenGL works, nor explain every single line of my code, so let's first find the exact call/state that solves the problem, and then perhaps I'll be able to figure out what happens in the driver ;)
Laurent Gomila - SFML developer

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Text rendering broken on my machine when using sf::Shape
« Reply #22 on: November 27, 2012, 04:20:21 pm »
Please tell me which ones you've tested, so that I can compare source code.

SDL, Laurent. I've said this several times. This had been tested before and worked just fine.

Further, all other OpenGL applications that I use have never exhibited any text display issues. Why is it just SFML?

Don't say this please.

What should I say, then, Laurent? It's frustrating to see everything else work but SFML, after I've spent months building major portions of a product I had hoped to release before 2013 around a library that inexplicably refuses to work doing something you seem to think is so mundane. A revamp like switching to SDL means another 3-4 months of development/testing.

Because a driver bug is hard to exhibit, doesn't mean that there's a design flaw in SFML. Driver bugs are usually a combination of several small (and unrelated) things, and all libraries do things differently; unfortunately this time the winner is SFML, but it doesn't mean that my code is wrong (I'm pretty sure it is correct).

Perhaps you should re-read my earlier post. The fact there is a driver bug is irrelevant. SFML isn't working when other OpenGL libraries do the same thing just fine on the same graphics card SFML is broken on.

There is a flaw. I don't know how you can deny it.

What needs to be done to debug and fix this? I can't sit around and wait anymore. I need to know whether or not to ditch SFML.

iirc he has a Nvidia card

Hell, if I lived in France I'd hand-deliver an ATI card to him.

I realize the To-do list is huge and it's not easy to just fix one thing because someone (me) is whining about it. However, I've found similar issues dating back to February of this year (arguably back to December of last year) regarding text.

I don't know what else I can say past this point to persuade you that there is, indeed, something that can be done with SFML to fix text.

You can start by cloning SFML from github, baking it (cmake etc., see tutorial page), installing it to /usr/local/lib/, taking the test source from the pastebin in my OP, compiling it, and running it with LD_LIBRARY_PATH=/usr/local/lib/...

I've done this already. I've gone as far as building all related libraries SFML uses from source. I've tried building dynamically, statically, etc.
« Last Edit: November 27, 2012, 04:24:58 pm by Qix »
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

opatut

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Text rendering broken on my machine when using sf::Shape
« Reply #23 on: November 27, 2012, 04:35:19 pm »
Please, don't hate each other now because there is a bug somewhere we don't know yet. I am really on it, and I think I have gotten pretty far on this one already. I think Laurent, we all know you'd rather keep SFML as-is and blame everything to ATI drivers, but since we don't understand the problem yet this is a stupid approach. I hope you understand that in our eyes, something can be done from SFML's side. Also, we probably have made it clear that we do not expect you to fix this for us, not only because you don't have the testing capabilities but also because we know you do this in your free time, and you don't have that much free time for issues you don't understand. But please stop trying to convince us to wait for some magic in ATI drivers to happen that fixes the issue.

I understand that some people may be angry with you (maybe Qix is) for not caring about this for a long time now. I don't think that is worth it, since you as the developer of a great piece of free software still have no responsibility for it to work. We should make it work together.

As you may have noticed, I have some basic understanding of what is going on in OpenGL myself, and while I appreciate any help from everyone here to understand the problem, I may need your help to understand what SFML is doing and why. I can't read the whole codebase and understand it, you have designed it and I would rather have some details explained by you than guessing what it is supposed to do and why. So that is what we need you for. I think we can solve the problem if we stay in touch, and you stop trying to blame ATI and forget about this bug.

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Text rendering broken on my machine when using sf::Shape
« Reply #24 on: November 27, 2012, 04:38:58 pm »
Please, don't hate each other now because there is a bug somewhere we don't know yet. I am really on it, and I think I have gotten pretty far on this one already. I think Laurent, we all know you'd rather keep SFML as-is and blame everything to ATI drivers, but since we don't understand the problem yet this is a stupid approach. I hope you understand that in our eyes, something can be done from SFML's side. Also, we probably have made it clear that we do not expect you to fix this for us, not only because you don't have the testing capabilities but also because we know you do this in your free time, and you don't have that much free time for issues you don't understand. But please stop trying to convince us to wait for some magic in ATI drivers to happen that fixes the issue.

I understand that some people may be angry with you (maybe Qix is) for not caring about this for a long time now. I don't think that is worth it, since you as the developer of a great piece of free software still have no responsibility for it to work. We should make it work together.

As you may have noticed, I have some basic understanding of what is going on in OpenGL myself, and while I appreciate any help from everyone here to understand the problem, I may need your help to understand what SFML is doing and why. I can't read the whole codebase and understand it, you have designed it and I would rather have some details explained by you than guessing what it is supposed to do and why. So that is what we need you for. I think we can solve the problem if we stay in touch, and you stop trying to blame ATI and forget about this bug.

+1
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Text rendering broken on my machine when using sf::Shape
« Reply #25 on: November 27, 2012, 04:47:49 pm »
Quote
SDL, Laurent. I've said this several times. This had been tested before and worked just fine.
Unless you use the not-yet-released SDL 2.0 with the OpenGL back-end, SDL doesn't use OpenGL, it's plain software rendering.
If that's what "all other OpenGL libraries" mean, sorry but this is not a valid argument ;)

Quote
Further, all other OpenGL applications that I use have never exhibited any text display issues.
Which ones?

Quote
What should I say, then, Laurent?
That ATI drivers are crappy. That's the only thing to say. And until you fully read and understand SFML code, you'll have to trust me.

Quote
It's frustrating to see everything else work but SFM
It's frustrating, I know. But again, don't say "everything else" if you can't be more precise on this point.

Quote
The fact there is a driver bug is irrelevant
It is, because I'm not supposed to work around driver bugs, and I usually don't unless the modification straight-forward.
If I had a lot of free time I would probably write a test program and start investigating. But I can't. But you can ;)

Quote
There is a flaw. I don't know how you can deny it.
As the library maintainer, I know a lot of driver bugs reported by users, and I know my code perfectly. You know none of them (or at least not better than me), so please don't say there is a flaw, unless you can spot it.

Quote
Hell, if I lived in France I'd hand-deliver an ATI card to him.
I bought one only to help users with ATI bugs. But I don't have the time too investigate.

Quote
I don't know what else I can say past this point to persuade you that there is, indeed, something that can be done with SFML to fix text
I know that something can be done, there is always a ugly workaround to apply to make things work. But ATI won't fix their drivers if everyone works around their bugs.

I'm not angry but I'd like people to focus on technical and relevant details. Saying "there's a flaw" or "it works with all other libraries" without any detail doesn't lead anywhere. Debug stuff on your side, do more tests, try to understand the code, etc. Don't come here every hour to say "there's a flaw". Please.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Text rendering broken on my machine when using sf::Shape
« Reply #26 on: November 27, 2012, 04:51:52 pm »
So... I can't help at the moment, I'm really sorry, but you two can continue to investigate and find more interesting things related to this bug. I think that's the best thing to do until I can help more.

Look at the "RenderTexture bug" thread: someone decided that it was time to solve this old problem, and within a few days it was solved. Users did an amazing job.
Laurent Gomila - SFML developer

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Text rendering broken on my machine when using sf::Shape
« Reply #27 on: November 27, 2012, 05:07:13 pm »
Unless you use the not-yet-released SDL 2.0 with the OpenGL back-end, SDL doesn't use OpenGL, it's plain software rendering.
If that's what "all other OpenGL libraries" mean, sorry but this is not a valid argument ;)
Yes, SDL 2.0. I think I would have noted that before talking about SDL.

Which ones?
All source engine games, all webGL experiments, basically any other application that uses OpenGL and text works perfectly fine.

That ATI drivers are crappy. That's the only thing to say. And until you fully read and understand SFML code, you'll have to trust me.
Laurent, we're both programmers. You and I both know that "trust me" isn't a term that is easily digested.

It's frustrating, I know. But again, don't say "everything else" if you can't be more precise on this point.
I can be precise. I've had no other text drawing issue when using any other OpenGL application other than the samples I use with SFML.

It is, because I'm not supposed to work around driver bugs, and I usually don't unless the modification straight-forward.
If I had a lot of free time I would probably write a test program and start investigating. But I can't. But you can ;)
I have written a test program, and you shot it down as something I shouldn't care about. Now we're here, and you're suggesting I do the same thing. I'm out of options.

As the library maintainer, I know a lot of driver bugs reported by users, and I know my code perfectly. You know none of them (or at least not better than me), so please don't say there is a flaw, unless you can spot it.
That is a really shitty excuse for ignoring an obvious problem.

I bought one only to help users with ATI bugs. But I don't have the time too investigate.
Well we're users, and we're having ATI bugs. You also won't help us fix it, so you must want to fix it on your own.

Perhaps it's time to start investigating.

I know that something can be done, there is always a ugly workaround to apply to make things work. But ATI won't fix their drivers if everyone works around their bugs.

Two retorts to this god awful statement: 1) Please, enlighten us. I'm sure many people would gladly put this "ugly workaround" in as a temporary fix to this gaping hole of a bug. 2) That's like saying "my son won't learn to not play with fire if we keep pouring water on him when he dowses himself in gasoline and decides to have a smoke".

Seriously? ATI doesn't give two shits about SFML. It's ATI. A big, multi-million (possibly multi-billion) dollar corporation. Their intent is to make money their own way. If they had cared the least bit about making sure there weren't any bugs, we wouldn't be having this issue in the first place.

You aren't ATI's father, you can't 'teach them a lesson'. They have a bug that has been present for several versions now, and the next couple of betas they have put out have failed to fix it thus far.

I'm not angry but I'd like people to focus on technical and relevant details. Saying "there's a flaw" or "it works with all other libraries" without any detail doesn't lead anywhere. Debug stuff on your side, do more tests, try to understand the code, etc. Don't come here every hour to say "there's a flaw". Please.

We've given you many, many "technical and relevant details". You're telling us you're not going to explain anything and that SFML is just fine and we should just ignore this bug. I've been debugging this for two weeks. There is no other explanation other than SFML isn't working without some help from you.

I'm not here every hour. I spent a week trying to fix it on my own, and finally made a thread about it. In fact, I've been taking a break from the project for another week now waiting for replies from somebody shedding some light on the matter. You gave up on it telling me that the drivers were mystical and I shouldn't try to understand why there is a bug.

To me, that sounds like you either don't care about SFML working right, just about it being clean. Secondly, it sounds like you're so caught up with the idea that SFML is yours and you want nobody to touch it that you're forgetting that it's open source and ignoring the fact that there is something wrong with it!!

There is a bug that can be fixed in SFML. We've given you all we have so far. We are two users who would rather not have to stop using SFML, which is why we made threads. I have personally spent more time on this than I should have had to spend, and the fact that the only person who seems to know this magical workaround is cock-blocking his user-base is utterly frustrating.

I would advise that instead of attacking us for asking for help, perhaps it's time to break out the ATI, give us some direction with debugging, or tell us about this magical fix from the mystical garden of workarounds...

So... I can't help at the moment, I'm really sorry, but you two can continue to investigate and find more interesting things related to this bug. I think that's the best thing to do until I can help more.

Look at the "RenderTexture bug" thread: someone decided that it was time to solve this old problem, and within a few days it was solved. Users did an amazing job.

Dear god man. We have investigated. We are at a dead end. What the hell do you expect us to do?

Not everyone has an ATI card, and not all ATI cards are affected. The only people who are going to be interested in investigating are us and you, and you seem to be doing a good job at being nonchalant about your own project.
« Last Edit: November 27, 2012, 05:11:53 pm by Qix »
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Text rendering broken on my machine when using sf::Shape
« Reply #28 on: November 27, 2012, 05:58:53 pm »
Ok ok... we should stop fighting. We could continue, but I don't think it would help to solve this problem ;)

First: no, I don't know this magical workaround (sorry). I just said there's probably a way to make text work, since all other libraries do it successfully, but I have no idea how. All I know is that it could be related to non- normalized texture coordinates, so if you want a starting point to investigate further, this is all I can say for now.

You say you've already debugged it hard , and that's true. You did many tests and provided a lot of details. But the problem is still not clear, and not solved. I'm not a magician, I'm as lost as you. So what do I expect from you? To continue to investigate, try to find what's causing this in SFML, and see if a workaround can be applied. And when it works (as for the RenderTexture bug), then wow, this is really amazing and for a moment I don't feel alone anymore :P

And sorry for being nonchalant, but a lot of problems were solved by just updating to a newer (or older...) version of the driver. So it's really hard to motivate myself to spend time on this problem, if the solution is in the next version of the driver.
« Last Edit: November 27, 2012, 06:00:48 pm by Laurent »
Laurent Gomila - SFML developer

opatut

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Text rendering broken on my machine when using sf::Shape
« Reply #29 on: November 27, 2012, 06:06:41 pm »
+1 to the above 2 comments ;)

I have a guess where we might have a little problem. See the following code from Texture.cpp:405

// in void sf::Texture::bind(CoordinateType) const;
// Load the matrix
glCheck(glMatrixMode(GL_TEXTURE));
glCheck(glLoadMatrixf(matrix));

// Go back to model-view mode (sf::RenderTarget relies on it)
glCheck(glMatrixMode(GL_MODELVIEW));

Thing is, RenderTarget::pushGLStates() does the following:

glCheck(glMatrixMode(GL_MODELVIEW));
glCheck(glPushMatrix());
glCheck(glMatrixMode(GL_PROJECTION));
glCheck(glPushMatrix());
glCheck(glMatrixMode(GL_TEXTURE));
glCheck(glPushMatrix());

Which seems a bit odd, that the texture thinks it has to set the matrix mode to GL_MODELVIEW, but the RenderTarget itself sets it to GL_TEXTURE in the end.

And sorry for being nonchalant, but a lot of problems were solved by just updating to a newer (or older...) version of the driver. So it's really hard to motivate myself to spend time on this problem, if the solution is in the next version of the driver.

I noticed that most of the problems on this board are "noob-questions" (yes, sorry, but it's true) where people have similar problems because of stupidity, but in this case, I can probably say Qix and I have both searched for the problem at our side, then investigated and found weird behavior in the libs/drivers we are using. I can completely understand you, Laurent, denying a problem with SFML in the first place.