From 0f8a466354426631a47ef25a51ddc37ff99c4dd2 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Fri, 5 May 2023 03:39:23 +0000 Subject: [PATCH] wk --- source/engine/font.c | 13 ++++++++++++- source/engine/sprite.c | 2 -- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/engine/font.c b/source/engine/font.c index f3f84b3..3fb13bb 100644 --- a/source/engine/font.c +++ b/source/engine/font.c @@ -74,6 +74,7 @@ void font_init(struct shader *textshader) { .fs.source = slurp_text("shaders/textfrag.glsl"), .vs.uniform_blocks[0] = { .size = sizeof(float)*16, + .layout = SG_UNIFORMLAYOUT_STD140, .uniforms = { [0] = { .name = "projection", .type = SG_UNIFORMTYPE_MAT4 } } @@ -81,10 +82,17 @@ void font_init(struct shader *textshader) { .fs.uniform_blocks[0] = { .size = sizeof(float)*3+sizeof(int), + .layout = SG_UNIFORMLAYOUT_STD140, .uniforms = { [0] = { .name = "textColor", .type = SG_UNIFORMTYPE_FLOAT3 }, [1] = { .name = "invert", .type = SG_UNIFORMTYPE_INT } } + }, + + .fs.images[0] = { + .name = "text", + .image_type = SG_IMAGETYPE_2D, + .sampler_type = SG_SAMPLERTYPE_FLOAT } }); @@ -100,7 +108,8 @@ void font_init(struct shader *textshader) { bind_text.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ .size = sizeof(float)*16, .type = SG_BUFFERTYPE_VERTEXBUFFER, - .usage = SG_USAGE_STREAM + .usage = SG_USAGE_STREAM, + .label = "text buffer" }); font = MakeFont("LessPerfectDOSVGA.ttf", 16); @@ -342,5 +351,7 @@ int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3] draw_char_box(font->Characters[69], cursor, scale, color); } + + return cursor[1] - pos[1]; } diff --git a/source/engine/sprite.c b/source/engine/sprite.c index e22583e..6adda9d 100644 --- a/source/engine/sprite.c +++ b/source/engine/sprite.c @@ -17,8 +17,6 @@ struct TextureOptions TEX_SPRITE = { 1, 0, 0 }; static struct sprite *sprites; static int first = -1; -static uint32_t VBO; - sg_pipeline pip_sprite; sg_bindings bind_sprite;