graphics: Check the number of vertices

This commit is contained in:
Hajime Hoshi 2016-06-05 03:17:53 +09:00
parent 1ccdfd9a35
commit aa83167e56

View File

@ -49,10 +49,12 @@ func (q *commandQueue) Flush(context *opengl.Context) error {
vertices = append(vertices, c.vertices...)
}
}
// TODO: Check if len(vertices) is too big
if 0 < len(vertices) {
context.BufferSubData(context.ArrayBuffer, vertices)
}
if MaxQuads < len(vertices)/16 {
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", MaxQuads))
}
for _, c := range q.commands {
if err := c.Exec(context); err != nil {
return err
@ -101,9 +103,6 @@ func (c *drawImageCommand) Exec(context *opengl.Context) error {
if n == 0 {
return nil
}
if MaxQuads < n/16 {
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", MaxQuads))
}
p := programContext{
state: &theOpenGLState,