mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
b83f0acc4d
commit
f7757ae025
@ -121,6 +121,7 @@ func (g *Game) Update(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
func (g *Game) Draw(screen *ebiten.Image) {
|
func (g *Game) Draw(screen *ebiten.Image) {
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
|
op.Address = ebiten.AddressUnsafe
|
||||||
indices := []uint16{}
|
indices := []uint16{}
|
||||||
for i := 0; i < g.ngon; i++ {
|
for i := 0; i < g.ngon; i++ {
|
||||||
indices = append(indices, uint16(i), uint16(i+1)%uint16(g.ngon), uint16(g.ngon))
|
indices = append(indices, uint16(i), uint16(i+1)%uint16(g.ngon), uint16(g.ngon))
|
||||||
|
18
image.go
18
image.go
@ -234,6 +234,9 @@ const (
|
|||||||
|
|
||||||
// AddressRepeat means that texture coordinates wrap to the other side of the texture.
|
// AddressRepeat means that texture coordinates wrap to the other side of the texture.
|
||||||
AddressRepeat Address = Address(driver.AddressRepeat)
|
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.
|
// 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))
|
is := make([]uint16, len(indices))
|
||||||
copy(is, indices)
|
copy(is, indices)
|
||||||
|
|
||||||
b := img.Bounds()
|
var sr driver.Region
|
||||||
sr := driver.Region{
|
if options.Address != AddressUnsafe {
|
||||||
X: float32(b.Min.X),
|
b := img.Bounds()
|
||||||
Y: float32(b.Min.Y),
|
sr = driver.Region{
|
||||||
Width: float32(b.Dx()),
|
X: float32(b.Min.X),
|
||||||
Height: float32(b.Dy()),
|
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)
|
i.buffered.DrawTriangles(img.buffered, vs, is, options.ColorM.impl, mode, filter, driver.Address(options.Address), sr, nil, nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user