mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 03:58:55 +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()
|
return t.parts.Len()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *textureQuads) SetVertices(vertices []int16) (int, error) {
|
func (t *textureQuads) SetVertices(vertices []int16) int {
|
||||||
l := t.Len()
|
l := t.Len()
|
||||||
if len(vertices) < l*16 {
|
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
|
p := t.parts
|
||||||
w, h := t.width, t.height
|
w, h := t.width, t.height
|
||||||
@ -123,5 +123,5 @@ func (t *textureQuads) SetVertices(vertices []int16) (int, error) {
|
|||||||
vertices[16*n+15] = int16(v1)
|
vertices[16*n+15] = int16(v1)
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
return n, nil
|
return n
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,7 @@ func drawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4
|
|||||||
}
|
}
|
||||||
p.begin()
|
p.begin()
|
||||||
defer p.end()
|
defer p.end()
|
||||||
n, err := quads.SetVertices(vertices)
|
n := quads.SetVertices(vertices)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
type TextureQuads interface {
|
type TextureQuads interface {
|
||||||
Len() int
|
Len() int
|
||||||
SetVertices(vertices []int16) (int, error)
|
SetVertices(vertices []int16) int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Lines interface {
|
type Lines interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user