graphics: Speed improvement by returning single value

This commit is contained in:
Hajime Hoshi 2016-02-17 00:21:39 +09:00
parent 7ab04167d7
commit 169d57936c
3 changed files with 5 additions and 8 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -22,7 +22,7 @@ import (
type TextureQuads interface {
Len() int
SetVertices(vertices []int16) (int, error)
SetVertices(vertices []int16) int
}
type Lines interface {