diff --git a/examples/polygons/main.go b/examples/polygons/main.go index f21d9b6ec..9cd7a31c2 100644 --- a/examples/polygons/main.go +++ b/examples/polygons/main.go @@ -121,6 +121,7 @@ func (g *Game) Update(screen *ebiten.Image) error { func (g *Game) Draw(screen *ebiten.Image) { op := &ebiten.DrawTrianglesOptions{} + op.Address = ebiten.AddressUnsafe indices := []uint16{} for i := 0; i < g.ngon; i++ { indices = append(indices, uint16(i), uint16(i+1)%uint16(g.ngon), uint16(g.ngon)) diff --git a/image.go b/image.go index 0651520b4..ccdccd09e 100644 --- a/image.go +++ b/image.go @@ -234,6 +234,9 @@ const ( // AddressRepeat means that texture coordinates wrap to the other side of the texture. AddressRepeat Address = Address(driver.AddressRepeat) + + // AddressUnsafe means there is no guarantee when the texture coodinates are out of range. + AddressUnsafe Address = Address(driver.AddressUnsafe) ) // DrawTrianglesOptions represents options to render triangles on an image. @@ -323,12 +326,15 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o is := make([]uint16, len(indices)) copy(is, indices) - b := img.Bounds() - sr := driver.Region{ - X: float32(b.Min.X), - Y: float32(b.Min.Y), - Width: float32(b.Dx()), - Height: float32(b.Dy()), + var sr driver.Region + if options.Address != AddressUnsafe { + b := img.Bounds() + sr = driver.Region{ + X: float32(b.Min.X), + Y: float32(b.Min.Y), + Width: float32(b.Dx()), + Height: float32(b.Dy()), + } } i.buffered.DrawTriangles(img.buffered, vs, is, options.ColorM.impl, mode, filter, driver.Address(options.Address), sr, nil, nil)