Bug fix (#85): The limit of the size of vertices was wrong

This commit is contained in:
Hajime Hoshi 2015-01-14 23:29:14 +09:00
parent f27ba0ea03
commit cb26342b3d
4 changed files with 5 additions and 7 deletions

View File

@ -92,7 +92,7 @@ func (s Sprites) Src(i int) (x0, y0, x1, y1 int) {
return s[i].Src()
}
var sprites = make(Sprites, 2500)
var sprites = make(Sprites, 10000)
func update(screen *ebiten.Image) error {
sprites.Update()

View File

@ -58,9 +58,7 @@ func DrawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4
if quads.Len() == 0 {
return nil
}
// TODO: Change this panic if image.DrawImage allows more than quadsMaxNum parts.
// TODO: Kinder message
if quadsMaxNum < 4*quads.Len() {
if quadsMaxNum < quads.Len() {
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", quadsMaxNum))
}

View File

@ -23,7 +23,7 @@ var (
programRect opengl.Program
)
const quadsMaxNum = 10000
const quadsMaxNum = 65536 / 6
func initialize(c *opengl.Context) error {
const uint16Size = 2
@ -63,7 +63,8 @@ func initialize(c *opengl.Context) error {
}
const stride = 4 * 4
c.NewBuffer(c.ArrayBuffer, stride*quadsMaxNum, c.DynamicDraw)
const float32Size = 4
c.NewBuffer(c.ArrayBuffer, float32Size*stride*quadsMaxNum, c.DynamicDraw)
indices := make([]uint16, 6*quadsMaxNum)
for i := uint16(0); i < quadsMaxNum; i++ {

View File

@ -267,7 +267,6 @@ func (c *Context) NewBuffer(bufferType BufferType, v interface{}, bufferUsageTyp
func (c *Context) BufferSubData(bufferType BufferType, data []float32) {
gl := c.gl
const float32Size = 4
gl.BufferSubData(int(bufferType), 0, data)
}