fix font texture switching

This commit is contained in:
Alessandro Mauri 2023-03-06 13:18:59 +01:00
parent c9c58ca410
commit 988c36a50a
2 changed files with 4 additions and 1 deletions

View File

@ -14,8 +14,10 @@ SDL_Window *win;
void draw(void) void draw(void)
{ {
static unsigned int frame = 0;
printf("frame: %d\n", frame++);
ren_clear(); ren_clear();
if (ren_render_text(str, 0, 0, 100, 50, 20)) if (ren_render_text(str, 10, 10, 100, 50, 20))
printf("text: %s\n", ren_strerror()); printf("text: %s\n", ren_strerror());
ren_render_text("altro font", 200, 40, 300, 300, 40); ren_render_text("altro font", 200, 40, 300, 300, 40);
ren_render_box(100, 300, 50, 50, 0xffff0000); ren_render_box(100, 300, 50, 50, 0xffff0000);

View File

@ -446,6 +446,7 @@ static int ren_draw_font_stack(int idx)
{ {
GL(glUseProgram(ren.font_prog)) GL(glUseProgram(ren.font_prog))
GL(glBindBuffer(GL_ARRAY_BUFFER, ren.font_buffer)) GL(glBindBuffer(GL_ARRAY_BUFFER, ren.font_buffer))
GL(glBindTexture(GL_TEXTURE_RECTANGLE, ren.fonts[idx].texture))
GL(glViewport(0, 0, ren.width, ren.height)) GL(glViewport(0, 0, ren.width, ren.height))
// this has caused me some trouble, convert from image coordiates to viewport // this has caused me some trouble, convert from image coordiates to viewport