Webgl points / handle using short instead of int for indices

This is controlled by the availability of the OES_element_index_uint
webgl extension.
This commit is contained in:
Olivier Guyot
2019-05-18 16:23:42 +02:00
parent e0983cb1c6
commit 03e70bd10e
4 changed files with 56 additions and 26 deletions

View File

@@ -16,10 +16,13 @@ onmessage = event => {
const renderInstructions = new Float32Array(received.renderInstructions);
const customAttributesCount = received.customAttributesCount || 0;
const instructionsCount = POINT_INSTRUCTIONS_COUNT + customAttributesCount;
const useShort = received.useShortIndices;
const elementsCount = renderInstructions.length / instructionsCount;
const indexBuffer = new Uint32Array(elementsCount * 6);
const vertexBuffer = new Float32Array(elementsCount * 4 * (POINT_VERTEX_STRIDE + customAttributesCount));
const indicesCount = elementsCount * 6;
const verticesCount = elementsCount * 4 * (POINT_VERTEX_STRIDE + customAttributesCount);
const indexBuffer = useShort ? new Uint16Array(indicesCount) : new Uint32Array(indicesCount);
const vertexBuffer = new Float32Array(verticesCount);
let bufferPositions = null;
for (let i = 0; i < renderInstructions.length; i += instructionsCount) {