This commit is contained in:
John Alanbrook 2023-05-05 03:39:23 +00:00
parent ae0f41539b
commit 0f8a466354
2 changed files with 12 additions and 3 deletions

View file

@ -74,6 +74,7 @@ void font_init(struct shader *textshader) {
.fs.source = slurp_text("shaders/textfrag.glsl"), .fs.source = slurp_text("shaders/textfrag.glsl"),
.vs.uniform_blocks[0] = { .vs.uniform_blocks[0] = {
.size = sizeof(float)*16, .size = sizeof(float)*16,
.layout = SG_UNIFORMLAYOUT_STD140,
.uniforms = { .uniforms = {
[0] = { .name = "projection", .type = SG_UNIFORMTYPE_MAT4 } [0] = { .name = "projection", .type = SG_UNIFORMTYPE_MAT4 }
} }
@ -81,10 +82,17 @@ void font_init(struct shader *textshader) {
.fs.uniform_blocks[0] = { .fs.uniform_blocks[0] = {
.size = sizeof(float)*3+sizeof(int), .size = sizeof(float)*3+sizeof(int),
.layout = SG_UNIFORMLAYOUT_STD140,
.uniforms = { .uniforms = {
[0] = { .name = "textColor", .type = SG_UNIFORMTYPE_FLOAT3 }, [0] = { .name = "textColor", .type = SG_UNIFORMTYPE_FLOAT3 },
[1] = { .name = "invert", .type = SG_UNIFORMTYPE_INT } [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){ bind_text.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){
.size = sizeof(float)*16, .size = sizeof(float)*16,
.type = SG_BUFFERTYPE_VERTEXBUFFER, .type = SG_BUFFERTYPE_VERTEXBUFFER,
.usage = SG_USAGE_STREAM .usage = SG_USAGE_STREAM,
.label = "text buffer"
}); });
font = MakeFont("LessPerfectDOSVGA.ttf", 16); 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); draw_char_box(font->Characters[69], cursor, scale, color);
} }
return cursor[1] - pos[1]; return cursor[1] - pos[1];
} }

View file

@ -17,8 +17,6 @@ struct TextureOptions TEX_SPRITE = { 1, 0, 0 };
static struct sprite *sprites; static struct sprite *sprites;
static int first = -1; static int first = -1;
static uint32_t VBO;
sg_pipeline pip_sprite; sg_pipeline pip_sprite;
sg_bindings bind_sprite; sg_bindings bind_sprite;