Webgl2 instance draw using TWGL.js divisor error

261 views Asked by At

I'm using Twgl.js library for using webgl2

I had a array like below and I was making buffers from it with createBufferInfoFromArrays and use drawObjectList with VAO to draw it but after I changed my array for using some unsigned byte values instead of float, I got into trouble which chrome make this error

GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to draw with all attributes having non-zero divisors

arrays before changed:

EdgeArrays = {
    pos:{
        numComponents: 2,
        data: [-1,.01, -1,-.01 , 1,.01 , 1,-.01]
    },
    center: {
        numComponents: 2,
        data: new Float32Array( Lines.CenterBuffer ),
        divisor: 1,
    },
    size: {
        numComponents: 2,
        data: new Float32Array( Lines.SizeBuffer ),
        divisor: 1,
    },
    rotate: {
        numComponents: 4,
        data: new Float32Array( Lines.RotateBuffer ),
        divisor: 1,
    },
    appear: {
        numComponents: 1,
        data: new Float32Array( Lines.AppearBuffer ),
        divisor: 1,
    },
    Active: {
        numComponents: 1,
        data: new Float32Array( Lines.ActiveBuffer ),
        divisor: 1,
    },
};

arrays after changed

let Arrays = {
        Pos:{
            numComponents: 2,
            data: [-1,.01, -1,-.01 , 1,.01 , 1,-.01]
        },
        Center: {
            numComponents: 2,
            data: new Float32Array( Buffers.Center ),
            divisor: 1,
        },
        Size: {
            numComponents: 2,
            data: new Float32Array( Buffers.Size ),
            divisor: 1,
        },
        Rotate: {
            numComponents: 4,
            data: new Float32Array( Buffers.Rotate ),
            divisor: 1,
        },
        Appear: {
            numComponents: 1,
            data: new Uint8Array( Buffers.Appear ),
            type: gl.UNSIGNED_BYTE ,
            normalize: false,
            divisor: 1,
        },
        Active: {
            numComponents: 1,
            data: new Uint8Array( Buffers.Active ),
            type: gl.UNSIGNED_BYTE ,
            normalize: false,
            divisor: 1,
        },
        InstInfo:{
            numComponents: 2,
            data: new Uint8Array( Buffers.InstInfo ),
            type: gl.UNSIGNED_BYTE ,
            normalize: false,
            divisor: 1,
        }
    };

error is saying that there is no buffer without divisor but the first one (pos buffer) has no divisor! what am I wrong?

thanks in advance

0

There are 0 answers