From be08d003c9163b93db6f73e192b10b32ab80f3e7 Mon Sep 17 00:00:00 2001 From: ToadKing Date: Thu, 22 Aug 2013 23:21:52 -0400 Subject: [PATCH] [GL] fix OSD messages breaking if one was too long --- gfx/fonts/gl_raster_font.c | 6 ++++++ gfx/gl_common.h | 1 + 2 files changed, 7 insertions(+) diff --git a/gfx/fonts/gl_raster_font.c b/gfx/fonts/gl_raster_font.c index 644184e20e..657ad4a96c 100644 --- a/gfx/fonts/gl_raster_font.c +++ b/gfx/fonts/gl_raster_font.c @@ -35,6 +35,7 @@ static bool gl_init_font(void *data, const char *font_path, float font_size) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl->max_font_size); } else { @@ -124,6 +125,11 @@ static void adjust_power_of_two(gl_t *gl, struct font_rect *geom) geom->pot_width = next_pow2(geom->width); geom->pot_height = next_pow2(geom->height); + if (geom->pot_width > gl->max_font_size) + geom->pot_width = gl->max_font_size; + if (geom->pot_height > gl->max_font_size) + geom->pot_height = gl->max_font_size; + if ((geom->pot_width > gl->font_tex_w) || (geom->pot_height > gl->font_tex_h)) { gl->font_tex_buf = (uint32_t*)realloc(gl->font_tex_buf, diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 5e97a0a540..1d5f308d92 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -207,6 +207,7 @@ typedef struct gl const gl_font_renderer_t *font_ctx; const font_renderer_driver_t *font_driver; GLuint font_tex; + GLint max_font_size; int font_tex_w, font_tex_h; uint32_t *font_tex_buf; char font_last_msg[256];