From 758b957b01fdd59f49ba20a73130f7622b2988c7 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 7 Jan 2019 11:20:29 +0900 Subject: [PATCH] graphicsdriver/opengl: Bug fix: filter is a preserved keyword (#771) --- internal/graphicsdriver/opengl/program.go | 2 +- internal/graphicsdriver/opengl/shader.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/graphicsdriver/opengl/program.go b/internal/graphicsdriver/opengl/program.go index 94611cbfa..3a3f5aa67 100644 --- a/internal/graphicsdriver/opengl/program.go +++ b/internal/graphicsdriver/opengl/program.go @@ -292,7 +292,7 @@ func (d *Driver) useProgram(mode graphics.CompositeMode, colorM *affine.ColorM, } if d.state.lastFilter == nil || *d.state.lastFilter != filter { - d.context.uniformInt(program, "filter", int(filter)) + d.context.uniformInt(program, "filter_type", int(filter)) d.state.lastFilter = &filter } if d.state.lastAddress == nil || *d.state.lastAddress != address { diff --git a/internal/graphicsdriver/opengl/shader.go b/internal/graphicsdriver/opengl/shader.go index 3277b6e77..0c86d4f44 100644 --- a/internal/graphicsdriver/opengl/shader.go +++ b/internal/graphicsdriver/opengl/shader.go @@ -94,7 +94,7 @@ uniform sampler2D texture; uniform mat4 color_matrix_body; uniform vec4 color_matrix_translation; -uniform int filter; +uniform int filter_type; uniform highp vec2 source_size; uniform int address; @@ -146,7 +146,7 @@ void main(void) { vec4 color; - if (filter == FILTER_NEAREST) { + if (filter_type == FILTER_NEAREST) { pos = adjustTexelByAddress(pos, varying_tex_region, address); color = texture2D(texture, pos); if (pos.x < varying_tex_region[0] || @@ -155,7 +155,7 @@ void main(void) { (varying_tex_region[3] - texel_size.y / 512.0) <= pos.y) { color = vec4(0, 0, 0, 0); } - } else if (filter == FILTER_LINEAR) { + } else if (filter_type == FILTER_LINEAR) { highp vec2 p0 = pos - texel_size / 2.0; highp vec2 p1 = pos + texel_size / 2.0; @@ -186,7 +186,7 @@ void main(void) { vec2 rate = fract(p0 * source_size); color = mix(mix(c0, c1, rate.x), mix(c2, c3, rate.x), rate.y); - } else if (filter == FILTER_SCREEN) { + } else if (filter_type == FILTER_SCREEN) { highp vec2 p0 = pos - texel_size / 2.0 / scale; highp vec2 p1 = pos + texel_size / 2.0 / scale;