regl-project / regl

👑 Functional WebGL
https://regl-project.github.io/
MIT License
5.22k stars 322 forks source link

uint32 attribute GL_INVALID_ENUM: glVertexAttribPointer: type was GL_UNSIGNED_INT #458

Open dy opened 6 years ago

dy commented 6 years ago
'use strict'

const regl = require('regl')()

let draw = regl({
    vert: `
        attribute float c;

        void main() {
            gl_Position = vec4(c,0,0,1);
            gl_PointSize = 100.;
        }
    `,

    frag: `
        void main() {
            gl_FragColor = vec4(0,0,0,1);
        }
    `,

    attributes: {
        c: regl.buffer({type:'uint32', data: [0.]})
    },

    primitive: 'points',
    count: 1
})

draw()

gives image

Changing type to uint16 works fine.

grovesNL commented 6 years ago

That extension is for elements (the index buffer) in drawElements/drawElementsInstanced, not attributes. So you can't use uint32 as the type there. Even when using the other integer types, they will be converted to floating-point in the shader.

WebGL2 does allow true integer types though.

dy commented 6 years ago

Makes sense. The documentation needs updating then.