swiftwasm/JavaScriptKit

Are JSValue bitmasks possible?

TeamPuzel opened this issue · 2 comments

Hey, is it possible to use the OR operator somehow?
I can call this webgl function:

context.clear(context.COLOR_BUFFER_BIT)

however this does not work:

context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT)

Please cast JSValue to Int and apply OR in Swift, then pass it to JS method like below:

let COLOR_BUFFER_BIT = Int(context.COLOR_BUFFER_BIT.number!)
let DEPTH_BUFFER_BIT = Int(context.DEPTH_BUFFER_BIT.number!)
context.clear(COLOR_BUFFER_BIT | DEPTH_BUFFER_BIT)

Thanks, I couldn't figure out the .number! part 🙂