mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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))
|
||||||
|
8
image.go
8
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,13 +326,16 @@ 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)
|
||||||
|
|
||||||
|
var sr driver.Region
|
||||||
|
if options.Address != AddressUnsafe {
|
||||||
b := img.Bounds()
|
b := img.Bounds()
|
||||||
sr := driver.Region{
|
sr = driver.Region{
|
||||||
X: float32(b.Min.X),
|
X: float32(b.Min.X),
|
||||||
Y: float32(b.Min.Y),
|
Y: float32(b.Min.Y),
|
||||||
Width: float32(b.Dx()),
|
Width: float32(b.Dx()),
|
||||||
Height: float32(b.Dy()),
|
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