Search code examples
javascriptwebglblending

Alternative approach for gl.blendFunci function that is missing from WebGL spec


I'm busy converting some OpenGL to WebGL but unable to get a workaround for the OpenGL function gl.BlendFunci(...) inside WebGL.

My browser console simply reports:

gl.blendFunci is not a function

What can I use as an alternative to set different blending functions when drawing to multiple buffers?


Solution

  • What worked for me was the WebGL function gl.blendFuncSeparate(...).

    Even though it doesn't do exactly what BlendFunci(...) does, it still worked for me because it allowed me to set the rgb and alpha blending functions separately. (which is what I was doing with BlendFunci(...) anyway)

    Found my answer by carefully examining these two files:

    https://github.com/tsherif/webgl2examples/blob/master/oit.html

    https://github.com/endavid/webGL-tests/blob/master/OIT/oit.js