aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-10-17 17:13:04 -0400
committerJack Jamison <jackqjamison@gmail.com>2025-10-17 17:13:04 -0400
commit7abba4bd6aea943870bfd571866e36a6167c80a2 (patch)
tree9e8c1f48263534f7a70139a479964305698f8e27
parent3de5c6c87bb4b73b67e8aef7ef534dcb9bd4c129 (diff)
line height
-rw-r--r--font.c1
-rw-r--r--graphics.c11
-rw-r--r--state.h1
3 files changed, 10 insertions, 3 deletions
diff --git a/font.c b/font.c
index bbd7d33..50fe3d0 100644
--- a/font.c
+++ b/font.c
@@ -61,6 +61,7 @@ bool freetype_init(client_state* state, const char* file) {
return false;
}
state->load_flags = FT_LOAD_RENDER | FT_LOAD_TARGET_(FT_RENDER_MODE_SDF);
+ state->line_height = (float)(state->ft_face->size->metrics.height >> 6);
return true;
}
diff --git a/graphics.c b/graphics.c
index 1ee8b08..f8b85ea 100644
--- a/graphics.c
+++ b/graphics.c
@@ -123,15 +123,15 @@ bool init_gl(client_state* state) {
}
void render_frame(client_state *state) {
+ // set up frame
glViewport(0, 0, state->width, state->height);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ // draw text
glBindVertexArray(state->input_buffer_text.vao);
- glBindBuffer(GL_ARRAY_BUFFER, state->input_buffer_text.vbo);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, state->input_buffer_text.ebo);
-
glActiveTexture(GL_TEXTURE0);
+
glBindTexture(GL_TEXTURE_2D, state->atlas.texture);
glUseProgram(state->text_shader);
@@ -139,6 +139,11 @@ void render_frame(client_state *state) {
glUniform2f(state->offset_uniform, 0.0f, 0.0f);
glDrawElements(GL_TRIANGLES, state->input_buffer_text.num_elements, GL_UNSIGNED_INT, 0);
+ // draw second text a line higher
+ glUniform2f(state->offset_uniform, 0.0f, state->line_height);
+ glDrawElements(GL_TRIANGLES, state->input_buffer_text.num_elements, GL_UNSIGNED_INT, 0);
+
+ // present screen
eglSwapBuffers(state->egl_display, state->egl_surface);
}
diff --git a/state.h b/state.h
index 29eac02..e3640fd 100644
--- a/state.h
+++ b/state.h
@@ -84,6 +84,7 @@ typedef struct {
FT_Face ft_face;
FT_Int32 load_flags;
atlas_t atlas;
+ float line_height;
// state
char* input_buffer;