r/webgl • • 15h ago

Error when not directly calling gl function

1 Upvotes

This code works:

(gl.uniformMatrix3fv)(
    uMatrix, true,
    [
    	1, 0, 0,
    	0, 1, 0,
    	0, 0, 1
    ])

But this code gives the error "Uncaught TypeError: 'uniformMatrix3fv' called on an object that does not implement interface WebGL2RenderingContext"

(true && gl.uniformMatrix3fv)(
    uMatrix, true,
    [
    	1, 0, 0,
    	0, 1, 0,
    	0, 0, 1
    ])

I have never seen javascript act like this. Is there some kind of typing or macro I don't know about?