mirror of https://github.com/bjornbytes/lovr.git
Don't mess with depth test when rendering fonts;
This commit is contained in:
parent
e8d8aceead
commit
3977db7249
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue