memononen / fontstash

Light-weight online font texture atlas builder
zlib License
688 stars 88 forks source link

Blending only works partially #35

Closed behrisch closed 7 years ago

behrisch commented 7 years ago

Thanks a lot for providing this library! We are currently converting our project to use it and it may be entirely my lack of GL understanding but I am not able to make the blending work out correctly. Some background polygons are blended correctly but some are not, see the picture. Sometimes the streets are blended correctly (see for instance the "am" of the upper amenity.restaurant) but sometimes not (see the last "a" in the same text). Every street has the same z value while the text is drawn slightly above. The code for text drawing is here: https://github.com/planetsumo/sumo/blob/master/sumo/src/utils/gui/div/GLHelper.cpp#L458 Any help is welcome! grafik

suikki commented 7 years ago

I haven't looked at the code but judging just from the image this might be a draw order issue. With transparent objects just plain z-buffering is not enough to get correct blending (depending on the blend mode). You need to issue the draw commands in order so that the objects "further" away are drawn before the ones on top of them. Here is some basic info: https://www.khronos.org/opengl/wiki/Transparency_Sorting

behrisch commented 7 years ago

Thank you, I am using alpha testing now instead of blending and it looks just fine.