[egl] alert: fix fuzzy font bug and make alerts a little more plesant

This commit is contained in:
Geoffrey McRae 2019-05-23 19:58:12 +10:00
parent ee5d6c7c3e
commit dba9764c5e
5 changed files with 23 additions and 13 deletions

View File

@ -1 +1 @@
a12-223-g1492196bbf+1
a12-224-gee5d6c7c3e+1

View File

@ -49,6 +49,7 @@ struct EGL_Alert
bool ready;
float width , height ;
float bgWidth, bgHeight;
float r, g, b, a;
// uniforms
@ -179,8 +180,13 @@ void egl_alert_render(EGL_Alert * alert, const float scaleX, const float scaleY)
egl_texture_update(alert->texture, alert->bmp->pixels);
alert->width = alert->bmp->width;
alert->height = alert->bmp->height;
alert->width = alert->bgWidth = alert->bmp->width;
alert->height = alert->bgHeight = alert->bmp->height;
if (alert->bgWidth < 200)
alert->bgWidth = 200;
alert->bgHeight += 4;
alert->ready = true;
alert->font->release(alert->fontObj, alert->bmp);
@ -198,14 +204,14 @@ void egl_alert_render(EGL_Alert * alert, const float scaleX, const float scaleY)
// render the background first
egl_shader_use(alert->shaderBG);
glUniform2f(alert->uScreenBG, scaleX , scaleY );
glUniform2f(alert->uSizeBG , alert->width, alert->height);
glUniform2i(alert->uSizeBG , alert->bgWidth, alert->bgHeight);
glUniform4f(alert->uColorBG , alert->r, alert->g, alert->b, alert->a);
egl_model_render(alert->model);
// render the texture over the background
egl_shader_use(alert->shader);
glUniform2f(alert->uScreen, scaleX , scaleY );
glUniform2f(alert->uSize , alert->width, alert->height);
glUniform2i(alert->uSize , alert->width, alert->height);
egl_model_render(alert->model);
glDisable(GL_BLEND);

View File

@ -156,7 +156,7 @@ bool egl_create(void ** opaque, const LG_RendererParams params)
this->screenScaleY = 1.0f;
this->font = LG_Fonts[0];
if (!this->font->create(&this->fontObj, NULL, 14))
if (!this->font->create(&this->fontObj, NULL, 16))
{
DEBUG_ERROR("Failed to create a font instance");
return false;

View File

@ -1,11 +1,12 @@
#version 300 es
in highp vec2 uv;
in highp vec2 sz;
out highp vec4 color;
uniform sampler2D sampler1;
void main()
{
color = texture(sampler1, uv);
color = texelFetch(sampler1, ivec2(uv * sz), 0);
}

View File

@ -4,17 +4,20 @@ layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec2 vertexUV;
uniform vec2 screen;
uniform vec2 size;
uniform ivec2 size;
uniform vec4 color;
out highp vec2 uv;
out highp vec2 sz;
out highp vec4 c;
void main()
{
sz = vec2(size) + 0.5;
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
gl_Position.xy *= screen.xy * size.xy;
gl_Position.xy *= screen.xy * sz;
uv = vertexUV;
c = color;