r/webgl • u/AnimalJust6413 • 1h ago
Error when not directly calling gl function
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?
1
Upvotes
1
u/Minute-Project-7200 10m ago
When you do
(true && gl.uniformMatrix3fv), it evaluates totrue, so you are really doingIt is calling
trueof which is not a function. I dont know how you got that specific type error though. It should be saying something different. The first one is valid asis equivalent to calling the function directly.