emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Treating OpenGL function colorMask as passthrough conflicts with WebGL spec

Open AlexPerrot opened this issue 10 years ago • 4 comments

Hi, I am using the OpenGL function colorMask, which in OpenGL takes GLBoolean (a.k.a. unsigned char), but in WebGL takes a GLboolean, which is a simple boolean (see here ).

Emscripten treats this function as a simple passthrough function, so it does not convert the args from Number to boolean. While this is not in line with the WebGL specification, it does work in every web browser I tested. But I want to use node-webgl, which is strictly enforcing the WebGL spec for colorMask (https://github.com/mikeseven/node-webgl/blob/master/lib/webgl.js#L186).

Any ideas to fix this ?

Edit : This is also valid for any other OpenGL function with a GLBoolean argument.

AlexPerrot avatar Nov 07 '16 15:11 AlexPerrot

I see. Ok, instead of a simple passthrough we could have a function that makes sure the type is correct, doing e.g. !!x on the boolean params. Pull request would be welcome.

kripken avatar Nov 07 '16 17:11 kripken

Ok, I'll see what I can do.

However, this is not limited to the passthrough functions. uniformMatrix4fv for instance has a boolean parameter transpose which is passed as-is to the WebGL function.

AlexPerrot avatar Nov 08 '16 09:11 AlexPerrot

Created #4703 with a fix

AlexPerrot avatar Nov 08 '16 10:11 AlexPerrot

Fixed by your PR.

kripken avatar Nov 10 '16 01:11 kripken