mirror of https://github.com/bjornbytes/lovr.git
Fix bugs with font textures;
This commit is contained in:
parent
d78e986a05
commit
059c5d3ef2
|
@ -50,6 +50,7 @@ Font* lovrFontCreate(FontData* fontData) {
|
|||
// Texture
|
||||
TextureData* textureData = lovrTextureDataGetBlank(font->atlas.width, font->atlas.height, 0x0, FORMAT_RGB);
|
||||
font->texture = lovrTextureCreate(textureData);
|
||||
lovrTextureSetFilter(font->texture, FILTER_BILINEAR, 1.);
|
||||
lovrTextureSetWrap(font->texture, WRAP_CLAMP, WRAP_CLAMP);
|
||||
|
||||
return font;
|
||||
|
|
|
@ -76,7 +76,7 @@ const char* lovrFontFragmentShader = ""
|
|||
" float w = fwidth(sdf); \n"
|
||||
" float alpha = smoothstep(.5 - w, .5 + w, sdf); \n"
|
||||
" if (alpha < .001) { discard; } \n"
|
||||
" return vec4(graphicsColor.rgb, alpha); \n"
|
||||
" return vec4(graphicsColor.rgb, graphicsColor.a * alpha); \n"
|
||||
"}";
|
||||
|
||||
const char* lovrNoopVertexShader = ""
|
||||
|
|
|
@ -193,6 +193,7 @@ void lovrTextureGetFilter(Texture* texture, FilterMode* filter, float* anisotrop
|
|||
}
|
||||
|
||||
void lovrTextureSetFilter(Texture* texture, FilterMode filter, float anisotropy) {
|
||||
int hasMipmaps = texture->textureData->format.compressed || texture->textureData->mipmaps.generated;
|
||||
lovrGraphicsBindTexture(texture);
|
||||
texture->filter = filter;
|
||||
texture->anisotropy = filter == FILTER_ANISOTROPIC ? anisotropy : 1;
|
||||
|
@ -204,14 +205,24 @@ void lovrTextureSetFilter(Texture* texture, FilterMode filter, float anisotropy)
|
|||
break;
|
||||
|
||||
case FILTER_BILINEAR:
|
||||
if (hasMipmaps) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
} else {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
break;
|
||||
|
||||
case FILTER_TRILINEAR:
|
||||
case FILTER_ANISOTROPIC:
|
||||
if (hasMipmaps) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
} else {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue