Semi-Working Text

This commit is contained in:
2024-02-16 15:43:35 -05:00
parent f676ef5332
commit 29a64160e9
2 changed files with 24 additions and 18 deletions

View File

@@ -68,7 +68,7 @@ public:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glEnable(GL_CULL_FACE);
//glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
@@ -79,10 +79,15 @@ public:
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
//JGL::RenderText("WHATS BOPPIN muth ~~~ niger ~~~ aphuqqa____?", 0.f, -100.f, 2.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
JGL::J2D::FillRect2D(JGL::Colors::Yellow, {32, 32}, {100.5, 100.5});
JGL::RenderText("WHATS BOPPIN muth ~~~ niger ~~~ aphuqqa____?", 0.f, -100.f, 2.f);
JGL::RenderText("Chinese characters don't work", 0.f, -120.f, 1.f);
JGL::J2D::FillRect2D(JGL::Colors::Yellow, {32, 32}, {100.5, 100.5});
JGL::Triangle2D tri
{
{10, -200},
@@ -90,7 +95,6 @@ public:
{-105, 10}
};
JGL::J2D::FillTriangle2D(JGL::Colors::Yellow, tri);
JGL::J2D::FillRect2D(JGL::Colors::Yellow, {32, 32}, {100.5, 100.5});
//glFlush();
}

View File

@@ -73,12 +73,15 @@ namespace JGL
FT_GlyphSlot g = face->glyph;
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, g->bitmap.width, g->bitmap.rows, 0, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap.buffer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, g->bitmap.width, g->bitmap.rows, 0, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap.buffer);
float x2 = x + g->bitmap_left * scale;
float y2 = -y - g->bitmap_top * scale; // Adjust y-coordinate
@@ -87,23 +90,23 @@ namespace JGL
glBegin(GL_TRIANGLES);
glTexCoord2f(0, 0);
glVertex2f(x2, y2);
glTexCoord2f(0, 0);
glVertex2f(x2, y2);
glTexCoord2f(0, 1);
glVertex2f(x2, y2 + h);
glTexCoord2f(0, 1);
glVertex2f(x2, y2 + h);
glTexCoord2f(1, 1);
glVertex2f(x2 + w, y2 + h);
glTexCoord2f(1, 1);
glVertex2f(x2 + w, y2 + h);
glTexCoord2f(0, 0);
glVertex2f(x2, y2);
glTexCoord2f(0, 0);
glVertex2f(x2, y2);
glTexCoord2f(1, 1);
glVertex2f(x2 + w, y2 + h);
glTexCoord2f(1, 1);
glVertex2f(x2 + w, y2 + h);
glTexCoord2f(1, 0);
glVertex2f(x2 + w, y2);
glTexCoord2f(1, 0);
glVertex2f(x2 + w, y2);
glEnd();
@@ -111,7 +114,6 @@ namespace JGL
y += (g->advance.y >> 6) * scale;
}
glBindTexture(GL_TEXTURE_2D, 0); // Unbind texture
}