mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
graphics: Speed improvement by returning single value
This commit is contained in:
parent
7ab04167d7
commit
169d57936c
@ -87,10 +87,10 @@ func (t *textureQuads) Len() int {
|
||||
return t.parts.Len()
|
||||
}
|
||||
|
||||
func (t *textureQuads) SetVertices(vertices []int16) (int, error) {
|
||||
func (t *textureQuads) SetVertices(vertices []int16) int {
|
||||
l := t.Len()
|
||||
if len(vertices) < l*16 {
|
||||
return 0, fmt.Errorf("grphics: vertices size must be greater than %d but %d", l*16, len(vertices))
|
||||
panic(fmt.Sprintf("grphics: vertices size must be greater than %d but %d", l*16, len(vertices)))
|
||||
}
|
||||
p := t.parts
|
||||
w, h := t.width, t.height
|
||||
@ -123,5 +123,5 @@ func (t *textureQuads) SetVertices(vertices []int16) (int, error) {
|
||||
vertices[16*n+15] = int16(v1)
|
||||
n++
|
||||
}
|
||||
return n, nil
|
||||
return n
|
||||
}
|
||||
|
@ -65,10 +65,7 @@ func drawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4
|
||||
}
|
||||
p.begin()
|
||||
defer p.end()
|
||||
n, err := quads.SetVertices(vertices)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n := quads.SetVertices(vertices)
|
||||
if n == 0 {
|
||||
return nil
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
|
||||
type TextureQuads interface {
|
||||
Len() int
|
||||
SetVertices(vertices []int16) (int, error)
|
||||
SetVertices(vertices []int16) int
|
||||
}
|
||||
|
||||
type Lines interface {
|
||||
|
Loading…
Reference in New Issue
Block a user