Skip to content

Commit 897e5be

Browse files
committed
go.mobile/gl/glutil: use correct image bounds in translation
I have included the gl.LINEAR bugfix here as it changes the images substantially. Based on Nigel's excellent analysis in cl/160710043. LGTM=nigeltao R=nigeltao CC=golang-codereviews https://golang.org/cl/168820043
1 parent 50e85e8 commit 897e5be

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

gl/glutil/glimage.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ func NewImage(size geom.Point) *Image {
9090
// runtime.SetFinalizer(img, func(img *Image) { gl.DeleteTexture(img.Texture) })
9191
gl.BindTexture(gl.TEXTURE_2D, img.Texture)
9292
gl.TexImage2D(gl.TEXTURE_2D, 0, dx, dy, gl.RGBA, gl.UNSIGNED_BYTE, nil)
93-
9493
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
9594
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
9695
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
@@ -206,8 +205,8 @@ func (img *Image) Draw(dstBounds geom.Rectangle, srcBounds image.Rectangle) {
206205
a.Identity()
207206
a.Translate(
208207
&a,
209-
float32(srcBounds.Min.X)/float32(img.Rect.Dx()),
210-
float32(srcBounds.Min.Y)/float32(img.Rect.Dy()),
208+
float32(srcBounds.Min.X)/float32(img.texWidth),
209+
float32(srcBounds.Min.Y)/float32(img.texHeight),
211210
)
212211
a.Scale(
213212
&a,
@@ -218,8 +217,6 @@ func (img *Image) Draw(dstBounds geom.Rectangle, srcBounds image.Rectangle) {
218217

219218
gl.ActiveTexture(gl.TEXTURE0)
220219
gl.BindTexture(gl.TEXTURE_2D, img.Texture)
221-
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
222-
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
223220
gl.Uniform1i(glimage.textureSample, 0)
224221

225222
gl.BindBuffer(gl.ARRAY_BUFFER, glimage.quadXY)

testdata/gopherwindow.png

17.8 KB
Loading

0 commit comments

Comments
 (0)