GL buffer limits?

Hello. I’m using Lime next to create my own OpenGL framework and I’m trying to make a bitmap font rendering engine but the fields seem to stop rendering at 64 characters in. I’ve traced this back to my draw call batching which collects up vertices and indexes until a different shader or texture is required and then triggers a drawElements call with all the data.

Before I buffer the data, I know the vertex and index arrays have all of the information but as soon as they are buffered and passed to the draw call, they seem to be cropped. I’m wondering if the index buffer or the vertex buffer have a limit on how many items they can hold? Is this because of it being a UInt8Array? Does anyone else have any ideas?

I’m trying to draw 111 quads as triangles, each has 4 vertices made up of 9 floats each and 6 indexes.

EDIT: More information I have tried getting the buffer size parameter and it matches with what I’d expect. The index buffer size is 666 and the vertex buffer size is 15984 (11149*4)

I think I just found a fix. I was using a UInt8Array for the index buffer but after changing this to a UInt16Array I now have all of my characters displaying.

Does this work differently on native vs html5? Maybe the size of the array just needs to be larger?

I am using a standard dynamic size Haxe array of floats/ints and then in the bufferData call I am converting them to a Float32Array or Int8Array by passing them as the first parameter of the constructor.

The behaviour is the same in native vs html. Using a UInt16Array and the UNSIGNED_SHORT type for indexes with drawElements seems to lift the limit.

An Uint8 can only hold values from 0 to 255 so if your indexes are higher than that it will be clamped to 255

1 Like

That makes sense. Thanks mrcdk.