Skip to content

Commit

Permalink
export WebGLRenderingContext and add gl consts
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljherrmann authored and dhritzkiv committed Oct 7, 2022
1 parent ce1c08c commit 6ac66ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ if (typeof WebGLRenderingContext !== 'undefined') {
} else {
module.exports = require('./src/javascript/node-index')
}
module.exports.WebGLRenderingContext = require('./src/javascript/webgl-rendering-context').WebGLRenderingContext
8 changes: 8 additions & 0 deletions src/javascript/webgl-rendering-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3861,4 +3861,12 @@ class WebGLRenderingContext extends NativeWebGLRenderingContext {
}
}

// Make the gl consts available as static properties
for (const [key, value] of Object.entries(gl)) {
if (typeof value !== 'number') {
continue
}
Object.assign(WebGLRenderingContext, { [key]: value })
}

module.exports = { WebGLRenderingContext, wrapContext }
12 changes: 12 additions & 0 deletions test/webgl-rendering-context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

const tape = require('tape')
const WebGLRenderingContext = require('../index').WebGLRenderingContext

tape('use WebGLRenderingContext', function (t) {
t.equals(!!WebGLRenderingContext, true)
t.equals(!!WebGLRenderingContext.STATIC_DRAW, true)
t.equals(!!WebGLRenderingContext.STENCIL_TEST, true)
t.equals(!!WebGLRenderingContext.FRAMEBUFFER, true)
t.end()
})

0 comments on commit 6ac66ea

Please sign in to comment.