mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
62210c89f3
commit
b48d501bc0
8
image.go
8
image.go
@ -440,10 +440,15 @@ type DrawTrianglesOptions struct {
|
|||||||
Filter Filter
|
Filter Filter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaxIndicesNum is the maximum number of indices for DrawTriangles.
|
||||||
|
const MaxIndicesNum = graphics.IndicesNum
|
||||||
|
|
||||||
// DrawTriangles draws a triangle with the specified vertices and their indices.
|
// DrawTriangles draws a triangle with the specified vertices and their indices.
|
||||||
//
|
//
|
||||||
// If len(indices) is not multiple of 3, DrawTriangles panics.
|
// If len(indices) is not multiple of 3, DrawTriangles panics.
|
||||||
//
|
//
|
||||||
|
// If len(indices) is more than MaxIndicesNum, DrawTriangles panics.
|
||||||
|
//
|
||||||
// The rule in which DrawTriangles works effectively is same as DrawImage's.
|
// The rule in which DrawTriangles works effectively is same as DrawImage's.
|
||||||
//
|
//
|
||||||
// In contrast to DrawImage, DrawTriangles doesn't care source image edges.
|
// In contrast to DrawImage, DrawTriangles doesn't care source image edges.
|
||||||
@ -473,6 +478,9 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
|
|||||||
if len(indices)%3 != 0 {
|
if len(indices)%3 != 0 {
|
||||||
panic("ebiten: len(indices) % 3 must be 0")
|
panic("ebiten: len(indices) % 3 must be 0")
|
||||||
}
|
}
|
||||||
|
if len(indices) > MaxIndicesNum {
|
||||||
|
panic("ebiten: len(indices) must be <= MaxIndicesNum")
|
||||||
|
}
|
||||||
// TODO: Check the maximum value of indices and len(vertices)?
|
// TODO: Check the maximum value of indices and len(vertices)?
|
||||||
|
|
||||||
if options == nil {
|
if options == nil {
|
||||||
|
@ -89,7 +89,7 @@ func (q *commandQueue) appendIndices(indices []uint16, offset uint16) {
|
|||||||
|
|
||||||
func (q *commandQueue) doEnqueueDrawImageCommand(dst, src *Image, nvertices, nindices int, color *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, forceNewCommand bool) {
|
func (q *commandQueue) doEnqueueDrawImageCommand(dst, src *Image, nvertices, nindices int, color *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, forceNewCommand bool) {
|
||||||
if nindices > graphics.IndicesNum {
|
if nindices > graphics.IndicesNum {
|
||||||
panic("not implemented for too many indices")
|
panic("not reached")
|
||||||
}
|
}
|
||||||
if !forceNewCommand && 0 < len(q.commands) {
|
if !forceNewCommand && 0 < len(q.commands) {
|
||||||
if last := q.commands[len(q.commands)-1]; last.CanMerge(dst, src, color, mode, filter) {
|
if last := q.commands[len(q.commands)-1]; last.CanMerge(dst, src, color, mode, filter) {
|
||||||
|
Loading…
Reference in New Issue
Block a user