graphics: Hide MaxQuads

This commit is contained in:
Hajime Hoshi 2016-07-16 02:07:16 +09:00
parent bc43614c25
commit 7a96f31b1f
2 changed files with 6 additions and 6 deletions

View File

@ -77,8 +77,8 @@ func (q *commandQueue) Flush(context *opengl.Context) error {
}
// NOTE: WebGL doesn't seem to have Check gl.MAX_ELEMENTS_VERTICES or gl.MAX_ELEMENTS_INDICES so far.
// Let's use them to compare to len(quads) in the future.
if MaxQuads < len(vertices)/16 {
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", MaxQuads))
if maxQuads < len(vertices)/16 {
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", maxQuads))
}
numc := len(q.commands)
for _, c := range q.commands {

View File

@ -42,7 +42,7 @@ var (
const (
indicesNum = 1 << 16
MaxQuads = indicesNum / 6
maxQuads = indicesNum / 6
)
// unsafe.SizeOf can't be used because unsafe doesn't work with GopherJS.
@ -94,10 +94,10 @@ func (s *openGLState) reset(context *opengl.Context) error {
}
const stride = 8 // (2 [vertices] + 2 [texels]) * 2 [sizeof(int16)/bytes]
s.arrayBuffer = context.NewBuffer(opengl.ArrayBuffer, 4*stride*MaxQuads, opengl.DynamicDraw)
s.arrayBuffer = context.NewBuffer(opengl.ArrayBuffer, 4*stride*maxQuads, opengl.DynamicDraw)
indices := make([]uint16, 6*MaxQuads)
for i := uint16(0); i < MaxQuads; i++ {
indices := make([]uint16, 6*maxQuads)
for i := uint16(0); i < maxQuads; i++ {
indices[6*i+0] = 4*i + 0
indices[6*i+1] = 4*i + 1
indices[6*i+2] = 4*i + 2