graphics: Bug fix: Outside texels are used (#317)

This commit is contained in:
Hajime Hoshi 2017-02-06 09:10:44 +09:00
parent d216a04cb6
commit bb993a481b
3 changed files with 8 additions and 0 deletions

View File

@ -154,6 +154,8 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (
if err := c.runOnContextThread(func() error {
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, int32(filter))
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, int32(filter))
//gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP)
//gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP)
var p interface{}
if pixels != nil {

View File

@ -56,6 +56,9 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
continue
}
u0, v0, u1, v1 := float64(sx0)/wf, float64(sy0)/hf, float64(sx1)/wf, float64(sy1)/hf
// Adjust texels to fix a problem that outside texels are used (#317).
u1 -= 1.0 / 16384.0
v1 -= 1.0 / 16384.0
vs.SetIndex(n, dx0)
vs.SetIndex(n+1, dy0)
vs.SetIndex(n+2, u0)

View File

@ -55,6 +55,9 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 {
continue
}
u0, v0, u1, v1 := float32(sx0)/wf, float32(sy0)/hf, float32(sx1)/wf, float32(sy1)/hf
// Adjust texels to fix a problem that outside texels are used (#317).
u1 -= 1.0 / 16384.0
v1 -= 1.0 / 16384.0
vs[n] = x0
vs[n+1] = y0
vs[n+2] = u0