glText
glText copied to clipboard
Black background
Hello MrVallentin,
Nice and useful library! Just one quick question: how to set transparent background for text instead of black ?
Thanks, Jev.
Currently you can change the text color with gltColor
. If you change the color, then it is only applied to the fill of the text, however changing the transparency would also affect the outline. Since the color is only multiplied with the font texels in the shader.
https://github.com/MrVallentin/glText/blob/2a2802ad161d30356413fbeb0e591e27ff7a565a/gltext.h#L523-L527
What is the exact use case? Do you simply want to be be able to apply different fill and outline colors? I'll at least look into that in the near future, have a few other ideas I want to implement as well.
Sorry it took a month to respond, didn't realize my mail filtering meant I wouldn't get notifications.
Nice lib, and easy to use. Thanks. But same here, just want the text background can set to transparent.
just figure it out
#define _gltDrawText() \
glUseProgram(_gltText2DShader); \
\
glActiveTexture(GL_TEXTURE0); \
glBindTexture(GL_TEXTURE_2D, _gltText2DFontTexture); \
\
glUniformMatrix4fv(_gltText2DShaderMVPUniformLocation, 1, GL_FALSE, mvp); \
\
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);\
glEnable(GL_BLEND);\
glBlendEquation(GL_FUNC_ADD);\
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\
\
glBindVertexArray(text->_vao); \
glDrawArrays(GL_TRIANGLES, 0, text->vertexCount); \
glBindVertexArray(0); \
\
if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
Thank you, trlsmax, nice method
@vallentin Any news on this?