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

Pages: [1] 2
1
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 28, 2012, 08:22:06 am »
I'm glad to see that it was indeed a mystical driver (at least for opatut) bug :P

Still, it was a driver bug that only occurs with SFML :P I'll keep  my eyes open to why that is the case, but I'll rest on it for now.

2
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 27, 2012, 09:17:00 pm »
defining texture mapping with pixel coordinates is what seems more intuitive for someone who doesn't know the low-level 3D APIs -- in my opinion.

I agree on the API side, and think you made a great number of design decisions.

The fixed pipeline is already deprecated, not only texture matrices. In the near future everything will have to be done in shaders, and there will be no problem to keep pixel texture coordinates.

Then what keeps you from designing a custom pipeline now? Are you planning on that for the foreseeable future? How much work would it be, and how backwards-compatible would it be?

---

By the way, catalyst 12.11 beta does fix the problem, sadly, I get a stupid "AMD Unsupported Hardware" watermark displayed when using that driver :(

3
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 27, 2012, 07:56:06 pm »
That is being undiscerning again. Why should SFML not normalize texture coordinates internally while keeping the old API. Really, OpenGL is not designed to be used with non-normalized texture coordinates, or at least mordern graphics programming strongly discourages it. You still get pixel-perfect results, so why not switch to the correct way? The texture matrix stack is long outdated anyway. I wouldn't expect modern drivers in the next 10+ years to still support these legacy ways of OpenGL 1...

Edit: I switched Sprites to normalized coordinates completely, and it changes.... nothing. So keep your texture matrix, I'll wait for a catalyst fix and stop using SFML then.

4
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 27, 2012, 06:50:14 pm »
I guess so, the symptoms are similar and match my observations, and I found also there was a problem with glTexCoordPointer(), and it is also catalyst 12.9 related.

I am currently trying to change SFML to only normalized texture coordinates, though this may take a while, we may benefit from it. Since normalized coords are usually preferred over texture matrices (they are easier to understand, matrices are brain-fuck for most people), this may be where SFML is going in a different direction. So yes, this might fix it.

Also, the normalization seems like a good idea, since we observe the texture coordinates to me changed from (0,0)/(w,h) to (0,0)/(1,1) and as such only displaying the top left pixel. This is definitely worth trying, IMO.

I will fork SFML on github so you can see my progress, as soon as I have something compiling and working using normalized coords.

5
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 27, 2012, 06:28:18 pm »
Dude, why didn't you link to that earlier? (and why is the search function in this forum so fucked up, of course I searched stuff like "shape text breaking" before posting, but found nothing).

Quote
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!

6
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« 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.

7
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« 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.

8
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« 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 ?

9
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« 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/...

10
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 27, 2012, 02:25:51 pm »
Hum... are you really sure?
Yes, pretty sure. I reset my clone to master and changed only the one line, and it worked.

I was expecting a problem with texture coordinates, and the vertex caches changes nothing to texture coordinates; and more important: storing more than 4 vertices in it is undefined behaviour because it is declared as an array of 4 sf::Vertex...

[I wrote a lot of stuff here, then I found you told me storing more than 4 vertices was undefined behaviour, and so I removed it again... I was thinking stupid :P]

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

11
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 27, 2012, 12:39:03 am »
I am working directly in SFML code, but anyway.... seems like the texture coordinates are fine, for the first quad I get (0,2) (14x17) on both the broken and the correct glyph...

I also found a workaround by enabling the vertex cache for all cases, even when we have more than 4 vertices. Did this by replacing RenderTarget.cpp:165 with

// bool useVertexCache = (vertexCount <= StatesCache::VertexCacheSize);
bool useVertexCache = true;

I still don't know what is going wrong, but like this it works. I will see into more detail what the vertex cache is doing tomorrow.

12
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 26, 2012, 11:14:28 pm »
And more observations:

When the font glyph page initializes its texture, it sets the top left 2x2 pixels to white (for the underline style), see src/SFML/Graphics/Font.cpp:581. When I set the top left color to something else (i.e. setPixel(0, 0, Color::Red); ) , the "wrong" square and all the wrong glyph rectangles have this color (red in this case)... Are probably the texture coords broken?

13
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 26, 2012, 11:00:29 pm »
I completely trust you, but... there must be a way to avoid this, even if it means some minor hacks. And since I am really not the only one with an ATI graphics card, I guess it is somehow of interest for a (possibly small but existent) group of people who share this common problem. I don't expect you, Laurent, to fix this right now or in foreseeable future, but I think it should be worked upon in general.

I am not trying to convince you that this is the most important problem in SFML 2 right now, nor do I think switching the driver is a satisfying solution.

Quote
Wow, this is confusing. But from my observations above I guess one can see how complicated this problem is, and that is probably has something to do with how textures are handled in SFML.
To be honest, I don't think so.

I am not saying it is your (or SFML's) fault, only it has to do with texture handling in SFML. I've been using SFML for a very long time now, and I admire basically all about SFML. I really believe myself ATI drivers are causing the problem in the first place, but there is not much I or you can do about it. But seeing a lot of other libraries and opengl software working fine, there is definitely another way to do it, which works with the current OpenGL implementation of the ATI drivers.

This is basically my reason for discussing here: I can't go any deeper than SFML at this problem. I could resolve the problem using my above investigations, but only for myself, and the solution would not be satisfying at all. What I do instead is posting here, initiating a discussing with the developers of SFML (you) and users of it, hoping to find a one-fits-all solution for this problem. I could not go onto ATI driver level with this problem, I honestly don't know shit about it and wouldn't even know where to start asking questions or who to address. So I went as deep as I could, at a level where I think the problem could be solved.

I am still happy about suggestions what might probably go wrong here -  and hopefully how to fix this.

14
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 26, 2012, 08:56:48 pm »
How comes all other libraries render text just fine? While I agree with you on that it is a driver-specific issue, the driver can definitely be used to render text as usual. It must be a problem with the combination of fglrx + SFML, which will probably not be concerned about int fglrx, making SFML the point where it should be addressed.

I would really appreciate this to be fixed real soon, as it probably does not only occur on my machine, and it can definitely be done correctly. Unfortunately I do not understand the problem, so I cannot help fixing it, only provide a testing machine.

Another interesting fact: I have no problem when drawing a sprite instead of a shape, even though one would expect a sprite to work exactly like a shape, only with texture handling on top... I'll keep investigating.

And one more thing: when I create the sf::Text only once before the loop, it is rendered correctly in all frames. Seems like there is a problem when rendering the text to a buffer texture (SFML is doing this, right), not when rendering it out onto the target.

Even more interesting: when rendering the font's texture directly into a Sprite (see code below), I have a nice glyph page in the first frame, and a white square in the following. This happens even when I only create and modify both the font and the sprite before the main loop, so it means the font's texture is being corrupted somehow by something that should not even touch it. And it does not seem to be the sf::Text class, since I can completely uncomment that one, giving me an empty glyph page (only a small white dot in the upper left corner) in the first frame, and again the big white square in the following ones. Uncommenting the draw command of the rectangle(s) however leaves the font texture untouched. Now that is weird, since shapes really don't have anything to do with fonts. My guess: does the shape class "construct" a white texture to use the same rendering mechanisms as the sprite class, but overwrites the font glyph page texture in this case?

sf::Sprite sprite(font.getTexture(20));

And more edits: when I use the font texture twice (e.g. render 2 sf::Texts or render one sf::Text and the sf::Sprite with the font's texture) the second (and third and probably all following) render works fine and displays the correct texture. Only the first render after 2 shapes is broken (so yes, I can break the above chain by drawing two shapes in between), these 2 shapes can be separated by other drawing calls to keep it working (either of sf::Text or sf::Sprite with other texture). Rendering another object (e.g. a test sprite) between the shapes and the text fixes the text, the other object however is not being rendered at all. [Hope you understand all of this ;)]

Shape 1, Shape 2, Text // broken text
Shape 1, Shape 2, Sprite, Shape 3, Text  // renders Shape 1-3 and Text, but not Sprite
Shape 1, Sprite, Shape 2, Text // renders everything

Wow, this is confusing. But from my observations above I guess one can see how complicated this problem is, and that is probably has something to do with how textures are handled in SFML.

15
Graphics / Re: Text rendering broken on my machine when using sf::Shape
« on: November 26, 2012, 08:18:57 pm »
Yes, error still occurs with the current git master :(

Pages: [1] 2