Skip to content

Commit 15453b2

Browse files
Agamnentzardhritzkiv
authored andcommitted
Add EXT_blend_minmax extension
1 parent aedc404 commit 15453b2

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Only the following for now:
218218
* [`OES_element_index_uint`](https://www.khronos.org/registry/webgl/extensions/OES_element_index_uint/)
219219
* [`OES_texture_float`](https://www.khronos.org/registry/webgl/extensions/OES_texture_float/)
220220
* [`WEBGL_draw_buffers`](https://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/)
221+
* [`EXT_blend_minmax`](https://www.khronos.org/registry/webgl/extensions/EXT_blend_minmax/)
221222

222223
### How can I keep up to date with what has changed in headless-gl?
223224

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class EXTBlendMinMax {
2+
constructor () {
3+
this.MIN_EXT = 0x8007
4+
this.MAX_EXT = 0x8008
5+
}
6+
}
7+
8+
function getEXTBlendMinMax (context) {
9+
let result = null
10+
const exts = context.getSupportedExtensions()
11+
12+
if (exts && exts.indexOf('EXT_blend_minmax') >= 0) {
13+
result = new EXTBlendMinMax()
14+
}
15+
16+
return result
17+
}
18+
19+
module.exports = { getEXTBlendMinMax, EXTBlendMinMax }

src/javascript/webgl-rendering-context.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { getOESTextureFloat } = require('./extensions/oes-texture-float')
99
const { getSTACKGLDestroyContext } = require('./extensions/stackgl-destroy-context')
1010
const { getSTACKGLResizeDrawingBuffer } = require('./extensions/stackgl-resize-drawing-buffer')
1111
const { getWebGLDrawBuffers } = require('./extensions/webgl-draw-buffers')
12+
const { getEXTBlendMinMax } = require('./extensions/ext-blend-minmax')
1213
const {
1314
bindPublics,
1415
checkObject,
@@ -57,7 +58,8 @@ const availableExtensions = {
5758
oes_standard_derivatives: getOESStandardDerivatives,
5859
stackgl_destroy_context: getSTACKGLDestroyContext,
5960
stackgl_resize_drawingbuffer: getSTACKGLResizeDrawingBuffer,
60-
webgl_draw_buffers: getWebGLDrawBuffers
61+
webgl_draw_buffers: getWebGLDrawBuffers,
62+
ext_blend_minmax: getEXTBlendMinMax
6163
}
6264

6365
const privateMethods = [
@@ -769,7 +771,10 @@ class WebGLRenderingContext extends NativeWebGLRenderingContext {
769771
_validBlendMode (mode) {
770772
return mode === gl.FUNC_ADD ||
771773
mode === gl.FUNC_SUBTRACT ||
772-
mode === gl.FUNC_REVERSE_SUBTRACT
774+
mode === gl.FUNC_REVERSE_SUBTRACT ||
775+
(this._extensions.ext_blend_minmax && (
776+
mode === this._extensions.ext_blend_minmax.MIN_EXT ||
777+
mode === this._extensions.ext_blend_minmax.MAX_EXT))
773778
}
774779

775780
_validCubeTarget (target) {
@@ -1211,6 +1216,10 @@ class WebGLRenderingContext extends NativeWebGLRenderingContext {
12111216
exts.push('WEBGL_draw_buffers')
12121217
}
12131218

1219+
if (supportedExts.indexOf('EXT_blend_minmax') >= 0) {
1220+
exts.push('EXT_blend_minmax')
1221+
}
1222+
12141223
return exts
12151224
}
12161225

0 commit comments

Comments
 (0)