Don't mess with depth test when rendering fonts;

This commit is contained in:
bjorn 2017-04-01 15:33:32 -07:00
parent e8d8aceead
commit 3977db7249
3 changed files with 3 additions and 7 deletions

View File

@ -11,7 +11,7 @@
static int lovrFontAlignLine(vec_float_t* vertices, int index, float width, HorizontalAlign halign) {
while (index < vertices->length) {
if (halign == ALIGN_CENTER) {
vertices->data[index] -= width / 2;
vertices->data[index] -= width / 2.f;
} else if (halign == ALIGN_RIGHT) {
vertices->data[index] -= width;
}
@ -154,19 +154,14 @@ void lovrFontPrint(Font* font, const char* str, mat4 transform, float wrap, Hori
offsety = lineCount * font->fontData->height * font->lineHeight;
}
// We override the depth test to LEQUAL to prevent blending issues with glyphs, not great
CompareMode oldCompareMode = lovrGraphicsGetDepthTest();
// Render!
lovrGraphicsPush();
lovrGraphicsMatrixTransform(transform);
lovrGraphicsScale(scale, scale, scale);
lovrGraphicsTranslate(0, offsety, 0);
lovrGraphicsSetDepthTest(COMPARE_LEQUAL);
lovrGraphicsBindTexture(font->texture);
lovrGraphicsSetShapeData(font->vertices.data, font->vertices.length);
lovrGraphicsDrawPrimitive(GL_TRIANGLES, 0, 1, 0);
lovrGraphicsSetDepthTest(oldCompareMode);
lovrGraphicsPop();
}

View File

@ -78,6 +78,7 @@ void lovrGraphicsReset() {
lovrGraphicsSetShader(NULL);
lovrGraphicsBindTexture(NULL);
lovrGraphicsSetBackgroundColor(0, 0, 0, 0);
lovrGraphicsSetBlendMode(BLEND_ALPHA, BLEND_ALPHA_MULTIPLY);
lovrGraphicsSetColor(255, 255, 255, 255);
lovrGraphicsSetColorMask(1, 1, 1, 1);
lovrGraphicsSetScissorEnabled(0);

View File

@ -56,7 +56,7 @@ TextureData* lovrTextureDataFromFile(void* data, int size) {
int* w = &textureData->width;
int* h = &textureData->height;
int* c = &textureData->channels;
stbi_set_flip_vertically_on_load(1);
stbi_set_flip_vertically_on_load(0);
void* image = stbi_load_from_memory(data, size, w, h, c, 4);
if (image) {