add background for F3 text, fix single-channel texture display

This commit is contained in:
2022-02-10 21:13:55 +08:00
parent a17a43505c
commit a628fdb434
7 changed files with 44 additions and 11 deletions

@ -87,7 +87,7 @@ func CreateFontsTexture() {
)
io.Fonts().SetTextureID(imgui.TextureID(tex))
igwrap.SetTextureFlag(tex, igwrap.TextureFlag_Red)
igwrap.SetTextureFlag(tex, igwrap.TextureFlag_ImGUIFont)
gl.BindTexture(gl.TEXTURE_2D, uint32(lastTexture))
}

@ -6,7 +6,8 @@
#define FLAG_ALPHA (1<<3)
#define FLAG_COLORS (FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA)
#define FLAG_LINEAR (1<<4)
#define FLAG_LINEAR (1<<4)
#define FLAG_IMGUI_FONT (1<<5)
uniform sampler2D tex;
uniform int flags;
@ -19,8 +20,10 @@ out vec4 outputColor;
const float gamma = 2.2;
void main() {
if ((flags & FLAG_COLORS) == FLAG_RED) {
if ((flags & FLAG_IMGUI_FONT) != 0) {
outputColor = vec4(fragColor.rgb, fragColor.a * texture(tex, fragUV.st).r);
} else if ((flags & FLAG_COLORS) == FLAG_RED) {
outputColor = vec4(vec3(texture(tex, fragUV.st).r), 1);
} else {
vec4 color = texture(tex, fragUV.st);
if ((flags & FLAG_LINEAR) != 0)