| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| var LibraryGLFW = { |
| $GLFW_Window__docs: '/** @constructor */', |
| $GLFW_Window: function(id, width, height, framebufferWidth, framebufferHeight, title, monitor, share) { |
| this.id = id; |
| this.x = 0; |
| this.y = 0; |
| this.fullscreen = false; |
| this.storedX = 0; |
| this.storedY = 0; |
| this.width = width; |
| this.height = height; |
| this.framebufferWidth = framebufferWidth; |
| this.framebufferHeight = framebufferHeight; |
| this.storedWidth = width; |
| this.storedHeight = height; |
| this.title = title; |
| this.monitor = monitor; |
| this.share = share; |
| this.attributes = {...GLFW.hints}; |
| this.inputModes = { |
| 0x00033001:0x00034001, |
| 0x00033002:0, |
| 0x00033003:0, |
| }; |
| this.buttons = 0; |
| this.keys = new Array(); |
| this.domKeys = new Array(); |
| this.shouldClose = 0; |
| this.title = null; |
| this.windowPosFunc = 0; |
| this.windowSizeFunc = 0; |
| this.windowCloseFunc = 0; |
| this.windowRefreshFunc = 0; |
| this.windowFocusFunc = 0; |
| this.windowIconifyFunc = 0; |
| this.windowMaximizeFunc = 0; |
| this.framebufferSizeFunc = 0; |
| this.windowContentScaleFunc = 0; |
| this.mouseButtonFunc = 0; |
| this.cursorPosFunc = 0; |
| this.cursorEnterFunc = 0; |
| this.scrollFunc = 0; |
| this.dropFunc = 0; |
| this.keyFunc = 0; |
| this.charFunc = 0; |
| this.userptr = 0; |
| }, |
|
|
| $GLFW__deps: ['emscripten_get_now', '$GL', '$Browser', '$GLFW_Window', |
| 'malloc', 'free', |
| '$MainLoop', |
| '$stringToNewUTF8', |
| '$getFullscreenElement', |
| 'emscripten_set_window_title', |
| #if FILESYSTEM |
| '$FS', |
| #endif |
| ], |
| $GLFW: { |
| WindowFromId: (id) => { |
| if (id <= 0 || !GLFW.windows) return null; |
| return GLFW.windows[id - 1]; |
| }, |
|
|
| joystickFunc: 0, |
| errorFunc: 0, |
| monitorFunc: 0, |
| active: null, |
| scale: null, |
| windows: null, |
| monitors: null, |
| monitorString: null, |
| versionString: null, |
| initialTime: null, |
| extensions: null, |
| devicePixelRatioMQL: null, |
| hints: null, |
| primaryTouchId: null, |
| defaultHints: { |
| 0x00020001:0, |
| 0x00020002:0, |
| 0x00020003:1, |
| 0x00020004:1, |
| 0x00020005:1, |
| 0x0002000A:0, |
| 0x0002200C:0, |
|
|
| 0x00021001:8, |
| 0x00021002:8, |
| 0x00021003:8, |
| 0x00021004:8, |
| 0x00021005:24, |
| 0x00021006:8, |
| 0x00021007:0, |
| 0x00021008:0, |
| 0x00021009:0, |
| 0x0002100A:0, |
| 0x0002100B:0, |
| 0x0002100C:0, |
| 0x0002100D:0, |
| 0x0002100E:0, |
| 0x0002100F:0, |
|
|
| 0x00022001:0x00030001, |
| 0x00022002:1, |
| 0x00022003:0, |
| 0x00022004:0, |
| 0x00022005:0, |
| 0x00022006:0, |
| 0x00022007:0, |
| 0x00022008:0, |
| }, |
|
|
| |
| |
| |
|
|
| |
| DOMToGLFWKeyCode: (keycode) => { |
| switch (keycode) { |
| |
| case 0x20:return 32; |
| case 0xDE:return 39; |
| case 0xBC:return 44; |
| case 0xAD:return 45; |
| case 0xBD:return 45; |
| case 0xBE:return 46; |
| case 0xBF:return 47; |
| case 0x30:return 48; |
| case 0x31:return 49; |
| case 0x32:return 50; |
| case 0x33:return 51; |
| case 0x34:return 52; |
| case 0x35:return 53; |
| case 0x36:return 54; |
| case 0x37:return 55; |
| case 0x38:return 56; |
| case 0x39:return 57; |
| case 0x3B:return 59; |
| case 0x3D:return 61; |
| case 0xBB:return 61; |
| case 0x41:return 65; |
| case 0x42:return 66; |
| case 0x43:return 67; |
| case 0x44:return 68; |
| case 0x45:return 69; |
| case 0x46:return 70; |
| case 0x47:return 71; |
| case 0x48:return 72; |
| case 0x49:return 73; |
| case 0x4A:return 74; |
| case 0x4B:return 75; |
| case 0x4C:return 76; |
| case 0x4D:return 77; |
| case 0x4E:return 78; |
| case 0x4F:return 79; |
| case 0x50:return 80; |
| case 0x51:return 81; |
| case 0x52:return 82; |
| case 0x53:return 83; |
| case 0x54:return 84; |
| case 0x55:return 85; |
| case 0x56:return 86; |
| case 0x57:return 87; |
| case 0x58:return 88; |
| case 0x59:return 89; |
| case 0x5a:return 90; |
| case 0xDB:return 91; |
| case 0xDC:return 92; |
| case 0xDD:return 93; |
| case 0xC0:return 96; |
|
|
| #if USE_GLFW == 2 |
| |
| case 0x1B:return (256+1); |
| case 0x70:return (256+2); |
| case 0x71:return (256+3); |
| case 0x72:return (256+4); |
| case 0x73:return (256+5); |
| case 0x74:return (256+6); |
| case 0x75:return (256+7); |
| case 0x76:return (256+8); |
| case 0x77:return (256+9); |
| case 0x78:return (256+10); |
| case 0x79:return (256+11); |
| case 0x7A:return (256+12); |
| case 0x7B:return (256+13); |
| case 0x7C:return (256+14); |
| case 0x7D:return (256+15); |
| case 0x7E:return (256+16); |
| case 0x7F:return (256+17); |
| case 0x80:return (256+18); |
| case 0x81:return (256+19); |
| case 0x82:return (256+20); |
| case 0x83:return (256+21); |
| case 0x84:return (256+22); |
| case 0x85:return (256+23); |
| case 0x86:return (256+24); |
| case 0x87:return (256+25); |
| case 0x88:return (256+26); |
| case 0x27:return (256+30); |
| case 0x25:return (256+29); |
| case 0x28:return (256+28); |
| case 0x26:return (256+27); |
| case 0x10:return (256+31); |
| |
| case 0x11:return (256+33); |
| |
| case 0x12:return (256+35); |
| |
| case 0x09:return (256+37); |
| case 0x0D:return (256+38); |
| case 0x08:return (256+39); |
| case 0x2D:return (256+40); |
| case 0x2E:return (256+41); |
| case 0x21:return (256+42); |
| case 0x22:return (256+43); |
| case 0x24:return (256+44); |
| case 0x23:return (256+45); |
| case 0x60:return (256+46); |
| case 0x61:return (256+47); |
| case 0x62:return (256+48); |
| case 0x63:return (256+49); |
| case 0x64:return (256+50); |
| case 0x65:return (256+51); |
| case 0x66:return (256+52); |
| case 0x67:return (256+53); |
| case 0x68:return (256+54); |
| case 0x69:return (256+55); |
| case 0x6F:return (256+56); |
| case 0x6A:return (256+57); |
| case 0x6D:return (256+58); |
| case 0x6B:return (256+59); |
| case 0x6E:return (256+60); |
| |
| |
| case 0x90:return (256+63); |
| case 0x14:return (256+64); |
| case 0x91:return (256+65); |
| case 0x13:return (256+66); |
| case 0x5B:return (256+67); |
| |
| case 0x5D:return (256+69); |
| #endif |
|
|
| #if USE_GLFW == 3 |
| case 0x1B:return 256; |
| case 0x0D:return 257; |
| case 0x09:return 258; |
| case 0x08:return 259; |
| case 0x2D:return 260; |
| case 0x2E:return 261; |
| case 0x27:return 262; |
| case 0x25:return 263; |
| case 0x28:return 264; |
| case 0x26:return 265; |
| case 0x21:return 266; |
| case 0x22:return 267; |
| case 0x24:return 268; |
| case 0x23:return 269; |
| case 0x14:return 280; |
| case 0x91:return 281; |
| case 0x90:return 282; |
| case 0x2C:return 283; |
| case 0x13:return 284; |
| case 0x70:return 290; |
| case 0x71:return 291; |
| case 0x72:return 292; |
| case 0x73:return 293; |
| case 0x74:return 294; |
| case 0x75:return 295; |
| case 0x76:return 296; |
| case 0x77:return 297; |
| case 0x78:return 298; |
| case 0x79:return 299; |
| case 0x7A:return 300; |
| case 0x7B:return 301; |
| case 0x7C:return 302; |
| case 0x7D:return 303; |
| case 0x7E:return 304; |
| case 0x7F:return 305; |
| case 0x80:return 306; |
| case 0x81:return 307; |
| case 0x82:return 308; |
| case 0x83:return 309; |
| case 0x84:return 310; |
| case 0x85:return 311; |
| case 0x86:return 312; |
| case 0x87:return 313; |
| case 0x88:return 314; |
| case 0x60:return 320; |
| case 0x61:return 321; |
| case 0x62:return 322; |
| case 0x63:return 323; |
| case 0x64:return 324; |
| case 0x65:return 325; |
| case 0x66:return 326; |
| case 0x67:return 327; |
| case 0x68:return 328; |
| case 0x69:return 329; |
| case 0x6E:return 330; |
| case 0x6F:return 331; |
| case 0x6A:return 332; |
| case 0x6D:return 333; |
| case 0x6B:return 334; |
| |
| |
| case 0x10:return 340; |
| case 0x11:return 341; |
| case 0x12:return 342; |
| case 0x5B:return 343; |
| case 0xE0:return 343; |
| |
| |
| |
| |
| case 0x5D:return 348; |
| |
| #endif |
| default:return -1; |
| }; |
| }, |
|
|
| getModBits: (win) => { |
| var mod = 0; |
| if (win.keys[340]) mod |= 0x0001; |
| if (win.keys[341]) mod |= 0x0002; |
| if (win.keys[342]) mod |= 0x0004; |
| if (win.keys[343] || win.keys[348]) mod |= 0x0008; |
| |
| return mod; |
| }, |
|
|
| onKeyPress: (event) => { |
| if (!GLFW.active || !GLFW.active.charFunc) return; |
| if (event.ctrlKey || event.metaKey) return; |
|
|
| |
| var charCode = event.charCode; |
| if (charCode == 0 || (charCode >= 0x00 && charCode <= 0x1F)) return; |
|
|
| #if USE_GLFW == 2 |
| {{{ makeDynCall('vii', 'GLFW.active.charFunc') }}}(charCode, 1); |
| #endif |
| #if USE_GLFW == 3 |
| {{{ makeDynCall('vpi', 'GLFW.active.charFunc') }}}(GLFW.active.id, charCode); |
| #endif |
| }, |
|
|
| onKeyChanged: (keyCode, status) => { |
| if (!GLFW.active) return; |
|
|
| var key = GLFW.DOMToGLFWKeyCode(keyCode); |
| if (key == -1) return; |
|
|
| #if USE_GLFW == 3 |
| var repeat = status && GLFW.active.keys[key]; |
| #endif |
| GLFW.active.keys[key] = status; |
| GLFW.active.domKeys[keyCode] = status; |
|
|
| if (GLFW.active.keyFunc) { |
| #if USE_GLFW == 2 |
| {{{ makeDynCall('vii', 'GLFW.active.keyFunc') }}}(key, status); |
| #endif |
| #if USE_GLFW == 3 |
| if (repeat) status = 2; |
| {{{ makeDynCall('vpiiii', 'GLFW.active.keyFunc') }}}(GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active)); |
| #endif |
| } |
| }, |
|
|
| onGamepadConnected: (event) => { |
| GLFW.refreshJoysticks(); |
| }, |
|
|
| onGamepadDisconnected: (event) => { |
| GLFW.refreshJoysticks(); |
| }, |
|
|
| onKeydown: (event) => { |
| GLFW.onKeyChanged(event.keyCode, 1); |
|
|
| |
| |
| |
| if (event.key == 'Backspace' || event.key == 'Tab') { |
| event.preventDefault(); |
| } |
| }, |
|
|
| onKeyup: (event) => { |
| GLFW.onKeyChanged(event.keyCode, 0); |
| }, |
|
|
| onBlur: (event) => { |
| if (!GLFW.active) return; |
|
|
| for (var i = 0; i < GLFW.active.domKeys.length; ++i) { |
| if (GLFW.active.domKeys[i]) { |
| GLFW.onKeyChanged(i, 0); |
| } |
| } |
| }, |
|
|
| onMousemove: (event) => { |
| if (!GLFW.active) return; |
|
|
| if (event.type === 'touchmove') { |
| |
|
|
| |
| event.preventDefault(); |
|
|
| let primaryChanged = false; |
| for (let i of event.changedTouches) { |
| |
| if (GLFW.primaryTouchId === i.identifier) { |
| Browser.setMouseCoords(i.pageX, i.pageY); |
| primaryChanged = true; |
| break; |
| } |
| } |
|
|
| if (!primaryChanged) { |
| |
| return; |
| } |
|
|
| } else { |
| |
| Browser.calculateMouseEvent(event); |
| } |
|
|
| if (event.target != Browser.getCanvas() || !GLFW.active.cursorPosFunc) return; |
|
|
| if (GLFW.active.cursorPosFunc) { |
| #if USE_GLFW == 2 |
| {{{ makeDynCall('vii', 'GLFW.active.cursorPosFunc') }}}(Browser.mouseX, Browser.mouseY); |
| #endif |
| #if USE_GLFW == 3 |
| {{{ makeDynCall('vpdd', 'GLFW.active.cursorPosFunc') }}}(GLFW.active.id, Browser.mouseX, Browser.mouseY); |
| #endif |
| } |
| }, |
|
|
| DOMToGLFWMouseButton: (event) => { |
| |
| |
| var eventButton = event['button']; |
| if (eventButton > 0) { |
| if (eventButton == 1) { |
| eventButton = 2; |
| } else { |
| eventButton = 1; |
| } |
| } |
| return eventButton; |
| }, |
|
|
| onMouseenter: (event) => { |
| if (!GLFW.active) return; |
|
|
| if (event.target != Browser.getCanvas()) return; |
|
|
| #if USE_GLFW == 3 |
| if (GLFW.active.cursorEnterFunc) { |
| {{{ makeDynCall('vpi', 'GLFW.active.cursorEnterFunc') }}}(GLFW.active.id, 1); |
| } |
| #endif |
| }, |
|
|
| onMouseleave: (event) => { |
| if (!GLFW.active) return; |
|
|
| if (event.target != Browser.getCanvas()) return; |
|
|
| #if USE_GLFW == 3 |
| if (GLFW.active.cursorEnterFunc) { |
| {{{ makeDynCall('vpi', 'GLFW.active.cursorEnterFunc') }}}(GLFW.active.id, 0); |
| } |
| #endif |
| }, |
|
|
| onMouseButtonChanged: (event, status) => { |
| if (!GLFW.active) return; |
|
|
| if (event.target != Browser.getCanvas()) return; |
|
|
| |
| const isTouchType = event.type === 'touchstart' || event.type === 'touchend' || event.type === 'touchcancel'; |
|
|
| |
| let eventButton = 0; |
| if (isTouchType) { |
| |
|
|
| |
| event.preventDefault(); |
|
|
| let primaryChanged = false; |
|
|
| |
| if (GLFW.primaryTouchId === null && event.type === 'touchstart' && event.targetTouches.length > 0) { |
| |
| const chosenTouch = event.targetTouches[0]; |
| GLFW.primaryTouchId = chosenTouch.identifier; |
|
|
| Browser.setMouseCoords(chosenTouch.pageX, chosenTouch.pageY); |
| primaryChanged = true; |
| } else if (event.type === 'touchend' || event.type === 'touchcancel') { |
| |
| for (let i of event.changedTouches) { |
| |
| if (GLFW.primaryTouchId === i.identifier) { |
| GLFW.primaryTouchId = null; |
| primaryChanged = true; |
| break; |
| } |
| } |
| } |
|
|
| if (!primaryChanged) { |
| |
| return; |
| } |
|
|
| } else { |
| |
| Browser.calculateMouseEvent(event); |
| eventButton = GLFW.DOMToGLFWMouseButton(event); |
| } |
|
|
| if (status == 1) { |
| GLFW.active.buttons |= (1 << eventButton); |
| try { |
| event.target.setCapture(); |
| } catch (e) {} |
| } else { |
| GLFW.active.buttons &= ~(1 << eventButton); |
| } |
|
|
| |
| if (GLFW.active.mouseButtonFunc) { |
| #if USE_GLFW == 2 |
| {{{ makeDynCall('vii', 'GLFW.active.mouseButtonFunc') }}}(eventButton, status); |
| #endif |
| #if USE_GLFW == 3 |
| {{{ makeDynCall('vpiii', 'GLFW.active.mouseButtonFunc') }}}(GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active)); |
| #endif |
| } |
| }, |
|
|
| onMouseButtonDown: (event) => { |
| if (!GLFW.active) return; |
| GLFW.onMouseButtonChanged(event, 1); |
| }, |
|
|
| onMouseButtonUp: (event) => { |
| if (!GLFW.active) return; |
| GLFW.onMouseButtonChanged(event, 0); |
| }, |
|
|
| onMouseWheel: (event) => { |
| |
| var delta = -Browser.getMouseWheelDelta(event); |
| delta = (delta == 0) ? 0 : (delta > 0 ? Math.max(delta, 1) : Math.min(delta, -1)); |
| GLFW.wheelPos += delta; |
|
|
| if (!GLFW.active || !GLFW.active.scrollFunc || event.target != Browser.getCanvas()) return; |
| #if USE_GLFW == 2 |
| {{{ makeDynCall('vi', 'GLFW.active.scrollFunc') }}}(GLFW.wheelPos); |
| #endif |
| #if USE_GLFW == 3 |
| var sx = 0; |
| var sy = delta; |
| if (event.type == 'mousewheel') { |
| sx = event.wheelDeltaX; |
| } else { |
| sx = event.deltaX; |
| } |
|
|
| {{{ makeDynCall('vpdd', 'GLFW.active.scrollFunc') }}}(GLFW.active.id, sx, sy); |
| #endif |
|
|
| event.preventDefault(); |
| }, |
|
|
| |
| |
| |
| onCanvasResize: (width, height, framebufferWidth, framebufferHeight) => { |
| if (!GLFW.active) return; |
|
|
| var resizeNeeded = false; |
|
|
| |
| if (getFullscreenElement()) { |
| if (!GLFW.active.fullscreen) { |
| resizeNeeded = width != screen.width || height != screen.height; |
| GLFW.active.storedX = GLFW.active.x; |
| GLFW.active.storedY = GLFW.active.y; |
| GLFW.active.storedWidth = GLFW.active.width; |
| GLFW.active.storedHeight = GLFW.active.height; |
| GLFW.active.x = GLFW.active.y = 0; |
| GLFW.active.width = screen.width; |
| GLFW.active.height = screen.height; |
| GLFW.active.fullscreen = true; |
| } |
| |
| } else if (GLFW.active.fullscreen == true) { |
| resizeNeeded = width != GLFW.active.storedWidth || height != GLFW.active.storedHeight; |
| GLFW.active.x = GLFW.active.storedX; |
| GLFW.active.y = GLFW.active.storedY; |
| GLFW.active.width = GLFW.active.storedWidth; |
| GLFW.active.height = GLFW.active.storedHeight; |
| GLFW.active.fullscreen = false; |
| } |
|
|
| if (resizeNeeded) { |
| |
| |
| Browser.setCanvasSize(GLFW.active.width, GLFW.active.height); |
| } else if (GLFW.active.width != width || |
| GLFW.active.height != height || |
| GLFW.active.framebufferWidth != framebufferWidth || |
| GLFW.active.framebufferHeight != framebufferHeight) { |
| GLFW.active.width = width; |
| GLFW.active.height = height; |
| GLFW.active.framebufferWidth = framebufferWidth; |
| GLFW.active.framebufferHeight = framebufferHeight; |
| GLFW.onWindowSizeChanged(); |
| GLFW.onFramebufferSizeChanged(); |
| } |
| }, |
|
|
| onWindowSizeChanged: () => { |
| if (!GLFW.active) return; |
|
|
| if (GLFW.active.windowSizeFunc) { |
| #if USE_GLFW == 2 |
| {{{ makeDynCall('vii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.width, GLFW.active.height); |
| #endif |
| #if USE_GLFW == 3 |
| {{{ makeDynCall('vpii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height); |
| #endif |
| } |
| }, |
|
|
| onFramebufferSizeChanged: () => { |
| if (!GLFW.active) return; |
|
|
| #if USE_GLFW == 3 |
| if (GLFW.active.framebufferSizeFunc) { |
| {{{ makeDynCall('vpii', 'GLFW.active.framebufferSizeFunc') }}}(GLFW.active.id, GLFW.active.framebufferWidth, GLFW.active.framebufferHeight); |
| } |
| #endif |
| }, |
|
|
| onWindowContentScaleChanged: (scale) => { |
| GLFW.scale = scale; |
| if (!GLFW.active) return; |
|
|
| #if USE_GLFW == 3 |
| if (GLFW.active.windowContentScaleFunc) { |
| {{{ makeDynCall('vpff', 'GLFW.active.windowContentScaleFunc') }}}(GLFW.active.id, GLFW.scale, GLFW.scale); |
| } |
| #endif |
| }, |
|
|
| getTime: () => _emscripten_get_now() / 1000, |
|
|
| |
|
|
| setWindowTitle: (winid, title) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
|
|
| win.title = title; |
| if (GLFW.active.id == win.id) { |
| _emscripten_set_window_title(title); |
| } |
| }, |
|
|
| setJoystickCallback: (cbfun) => { |
| var prevcbfun = GLFW.joystickFunc; |
| GLFW.joystickFunc = cbfun; |
| GLFW.refreshJoysticks(); |
| return prevcbfun; |
| }, |
|
|
| joys: {}, |
| lastGamepadState: [], |
| lastGamepadStateFrame: null, |
|
|
| refreshJoysticks: () => { |
| |
| if (MainLoop.currentFrameNumber !== GLFW.lastGamepadStateFrame || !MainLoop.currentFrameNumber) { |
| GLFW.lastGamepadState = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads || []); |
| GLFW.lastGamepadStateFrame = MainLoop.currentFrameNumber; |
|
|
| for (var joy = 0; joy < GLFW.lastGamepadState.length; ++joy) { |
| var gamepad = GLFW.lastGamepadState[joy]; |
|
|
| if (gamepad) { |
| if (!GLFW.joys[joy]) { |
| out('glfw joystick connected:',joy); |
| GLFW.joys[joy] = { |
| id: stringToNewUTF8(gamepad.id), |
| buttonsCount: gamepad.buttons.length, |
| axesCount: gamepad.axes.length, |
| buttons: _malloc(gamepad.buttons.length), |
| axes: _malloc(gamepad.axes.length*4), |
| }; |
|
|
| if (GLFW.joystickFunc) { |
| {{{ makeDynCall('vii', 'GLFW.joystickFunc') }}}(joy, 0x00040001); |
| } |
| } |
|
|
| var data = GLFW.joys[joy]; |
|
|
| for (var i = 0; i < gamepad.buttons.length; ++i) { |
| {{{ makeSetValue('data.buttons + i', '0', 'gamepad.buttons[i].pressed', 'i8') }}}; |
| } |
|
|
| for (var i = 0; i < gamepad.axes.length; ++i) { |
| {{{ makeSetValue('data.axes + i*4', '0', 'gamepad.axes[i]', 'float') }}}; |
| } |
| } else { |
| if (GLFW.joys[joy]) { |
| out('glfw joystick disconnected',joy); |
|
|
| if (GLFW.joystickFunc) { |
| {{{ makeDynCall('vii', 'GLFW.joystickFunc') }}}(joy, 0x00040002); |
| } |
|
|
| _free(GLFW.joys[joy].id); |
| _free(GLFW.joys[joy].buttons); |
| _free(GLFW.joys[joy].axes); |
|
|
| delete GLFW.joys[joy]; |
| } |
| } |
| } |
| } |
| }, |
|
|
| setKeyCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.keyFunc; |
| win.keyFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| setCharCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.charFunc; |
| win.charFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| setMouseButtonCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.mouseButtonFunc; |
| win.mouseButtonFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| setCursorPosCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.cursorPosFunc; |
| win.cursorPosFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| setScrollCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.scrollFunc; |
| win.scrollFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| setDropCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.dropFunc; |
| win.dropFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| onDrop: (event) => { |
| if (!GLFW.active || !GLFW.active.dropFunc) return; |
| if (!event.dataTransfer || !event.dataTransfer.files || event.dataTransfer.files.length == 0) return; |
|
|
| event.preventDefault(); |
|
|
| #if FILESYSTEM |
| var drop_dir = '.glfw_dropped_files'; |
| var filenames = _malloc(event.dataTransfer.files.length * {{{ POINTER_SIZE }}}); |
| var filenamesArray = []; |
| for (var i = 0; i < event.dataTransfer.files.length; ++i) { |
| var path = `/${drop_dir}/${event.dataTransfer.files[i].name.replace(/\//g, "_")}`; |
| var filename = stringToNewUTF8(path); |
| filenamesArray.push(filename); |
| {{{ makeSetValue('filenames', `i*${POINTER_SIZE}` , 'filename', '*') }}}; |
| } |
|
|
| |
| var written = 0; |
| FS.createPath('/', drop_dir); |
|
|
| function save(file, in_path, numfiles) { |
| var path = '/' + drop_dir + in_path + '/' + file.name.replace(/\//g, '_'); |
| var reader = new FileReader(); |
| reader.onloadend = (e) => { |
| if (reader.readyState != 2) { |
| ++written; |
| err(`failed to read dropped file: ${in_path}/${file.name}: ${reader.error}`); |
| return; |
| } |
|
|
| var data = e.target.result; |
| FS.writeFile(path, new Uint8Array(data)); |
| if (++written === numfiles) { |
| {{{ makeDynCall('vpip', 'GLFW.active.dropFunc') }}}(GLFW.active.id, filenamesArray.length, filenames); |
|
|
| for (var i = 0; i < filenamesArray.length; ++i) { |
| _free(filenamesArray[i]); |
| } |
| _free(filenames); |
| } |
| }; |
| reader.readAsArrayBuffer(file); |
| } |
|
|
| let filesQ = []; |
| function finalize() { |
| var count = filesQ.length; |
| for (var i = 0; i < count; ++i) { |
| save(filesQ[i].file, filesQ[i].path, count); |
| } |
| } |
|
|
| if (DataTransferItem.prototype.webkitGetAsEntry) { |
| let entriesTree = {}; |
| function markDone(fullpath, recursive) { |
| if (entriesTree[fullpath].subpaths.length != 0) return; |
| delete entriesTree[fullpath]; |
| let parentpath = fullpath.substring(0, fullpath.lastIndexOf('/')); |
| if (!entriesTree.hasOwnProperty(parentpath)) { |
| if (Object.keys(entriesTree).length == 0) finalize(); |
| return; |
| } |
| const fpIndex = entriesTree[parentpath].subpaths.indexOf(fullpath); |
| if (fpIndex > -1) entriesTree[parentpath].subpaths.splice(fpIndex, 1); |
| if (recursive) markDone(parentpath, true); |
| if (Object.keys(entriesTree).length == 0) finalize(); |
| } |
| function processEntry(entry) { |
| let fp = entry.fullPath; |
| let pp = fp.substring(0, fp.lastIndexOf('/')); |
| entriesTree[fp] = { subpaths: [] }; |
| if (entry.isFile) { |
| entry.file((f) => { filesQ.push({ file: f, path: pp }); markDone(fp, false); }) |
| } else if (entry.isDirectory) { |
| if (entriesTree.hasOwnProperty(pp)) entriesTree[pp].subpaths.push(fp); |
| FS.createPath("/" + drop_dir + pp, entry.name); |
| var reader = entry.createReader(); |
| var rRead = function (dirEntries) { |
| if (dirEntries.length == 0) { |
| markDone(fp, true); |
| return; |
| } |
| for (const ent of dirEntries) processEntry(ent); |
| reader.readEntries(rRead); |
| }; |
| reader.readEntries(rRead); |
| } |
| } |
| for (const item of event.dataTransfer.items) { |
| processEntry(item.webkitGetAsEntry()); |
| } |
| } else { |
| |
| for (const file of event.dataTransfer.files) { |
| filesQ.push({ file: file, path: "" }); |
| } |
| finalize(); |
| } |
| #endif |
|
|
| return false; |
| }, |
|
|
| onDragover: (event) => { |
| if (!GLFW.active || !GLFW.active.dropFunc) return; |
|
|
| event.preventDefault(); |
| return false; |
| }, |
|
|
| setWindowSizeCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowSizeFunc; |
| win.windowSizeFunc = cbfun; |
|
|
| #if USE_GLFW == 2 |
| |
| |
| |
| |
| if (!win.windowSizeFunc) return null; |
| {{{ makeDynCall('vii', 'win.windowSizeFunc') }}}(win.width, win.height); |
| #endif |
|
|
| return prevcbfun; |
| }, |
|
|
| setWindowCloseCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowCloseFunc; |
| win.windowCloseFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| setWindowRefreshCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowRefreshFunc; |
| win.windowRefreshFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| onClickRequestPointerLock: (e) => { |
| var canvas = Browser.getCanvas(); |
| if (!Browser.pointerLock && canvas.requestPointerLock) { |
| canvas.requestPointerLock(); |
| e.preventDefault(); |
| } |
| }, |
|
|
| setInputMode: (winid, mode, value) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
|
|
| switch (mode) { |
| case 0x00033001: { |
| var canvas = Browser.getCanvas(); |
| switch (value) { |
| case 0x00034001: { |
| win.inputModes[mode] = value; |
| canvas.removeEventListener('click', GLFW.onClickRequestPointerLock, true); |
| document.exitPointerLock(); |
| break; |
| } |
| case 0x00034002: { |
| err('glfwSetInputMode called with GLFW_CURSOR_HIDDEN value not implemented'); |
| break; |
| } |
| case 0x00034003: { |
| win.inputModes[mode] = value; |
| canvas.addEventListener('click', GLFW.onClickRequestPointerLock, true); |
| canvas.requestPointerLock(); |
| break; |
| } |
| default: { |
| err(`glfwSetInputMode called with unknown value parameter value: ${value}`); |
| break; |
| } |
| } |
| break; |
| } |
| case 0x00033002: { |
| err('glfwSetInputMode called with GLFW_STICKY_KEYS mode not implemented'); |
| break; |
| } |
| case 0x00033003: { |
| err('glfwSetInputMode called with GLFW_STICKY_MOUSE_BUTTONS mode not implemented'); |
| break; |
| } |
| case 0x00033004: { |
| err('glfwSetInputMode called with GLFW_LOCK_KEY_MODS mode not implemented'); |
| break; |
| } |
| case 0x00033005: { |
| err('glfwSetInputMode called with GLFW_RAW_MOUSE_MOTION mode not implemented'); |
| break; |
| } |
| default: { |
| err(`glfwSetInputMode called with unknown mode parameter value: ${mode}`); |
| break; |
| } |
| } |
| }, |
|
|
| getKey: (winid, key) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return 0; |
| return win.keys[key]; |
| }, |
|
|
| getMouseButton: (winid, button) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return 0; |
| return (win.buttons & (1 << button)) > 0; |
| }, |
|
|
| getCursorPos: (winid, x, y) => { |
| {{{ makeSetValue('x', '0', 'Browser.mouseX', 'double') }}}; |
| {{{ makeSetValue('y', '0', 'Browser.mouseY', 'double') }}}; |
| }, |
|
|
| getMousePos: (winid, x, y) => { |
| {{{ makeSetValue('x', '0', 'Browser.mouseX', 'i32') }}}; |
| {{{ makeSetValue('y', '0', 'Browser.mouseY', 'i32') }}}; |
| }, |
|
|
| setCursorPos: (winid, x, y) => { |
| }, |
|
|
| getWindowPos: (winid, x, y) => { |
| var wx = 0; |
| var wy = 0; |
|
|
| var win = GLFW.WindowFromId(winid); |
| if (win) { |
| wx = win.x; |
| wy = win.y; |
| } |
|
|
| if (x) { |
| {{{ makeSetValue('x', '0', 'wx', 'i32') }}}; |
| } |
|
|
| if (y) { |
| {{{ makeSetValue('y', '0', 'wy', 'i32') }}}; |
| } |
| }, |
|
|
| setWindowPos: (winid, x, y) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
| win.x = x; |
| win.y = y; |
| }, |
|
|
| getWindowSize: (winid, width, height) => { |
| var ww = 0; |
| var wh = 0; |
|
|
| var win = GLFW.WindowFromId(winid); |
| if (win) { |
| ww = win.width; |
| wh = win.height; |
| } |
|
|
| if (width) { |
| {{{ makeSetValue('width', '0', 'ww', 'i32') }}}; |
| } |
|
|
| if (height) { |
| {{{ makeSetValue('height', '0', 'wh', 'i32') }}}; |
| } |
| }, |
|
|
| setWindowSize: (winid, width, height) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
|
|
| if (GLFW.active.id == win.id) { |
| Browser.setCanvasSize(width, height); |
| } |
| }, |
|
|
| defaultWindowHints: () => { |
| GLFW.hints = {...GLFW.defaultHints}; |
| }, |
|
|
| createWindow: (width, height, title, monitor, share) => { |
| var i, id; |
| for (i = 0; i < GLFW.windows.length && GLFW.windows[i] !== null; i++) { |
| |
| } |
| if (i > 0) abort("glfwCreateWindow only supports one window at time currently"); |
|
|
| |
| id = i + 1; |
|
|
| |
| if (width <= 0 || height <= 0) return 0; |
|
|
| if (monitor) { |
| Browser.requestFullscreen(); |
| } else { |
| Browser.setCanvasSize(width, height); |
| } |
|
|
| |
| for (i = 0; i < GLFW.windows.length && GLFW.windows[i] == null; i++) { |
| |
| } |
|
|
| const canvas = Browser.getCanvas(); |
|
|
| var useWebGL = GLFW.hints[0x00022001] > 0; |
| if (i == GLFW.windows.length) { |
| if (useWebGL) { |
| var contextAttributes = { |
| antialias: (GLFW.hints[0x0002100D] > 1), |
| depth: (GLFW.hints[0x00021005] > 0), |
| stencil: (GLFW.hints[0x00021006] > 0), |
| alpha: (GLFW.hints[0x00021004] > 0) |
| } |
| #if OFFSCREEN_FRAMEBUFFER |
| |
| GL.enableOffscreenFramebufferAttributes(contextAttributes); |
| #endif |
| Browser.createContext(canvas, true, true, contextAttributes); |
| } else { |
| Browser.init(); |
| } |
| } |
|
|
| |
| if (!Module['ctx'] && useWebGL) return 0; |
|
|
| |
| var win = new GLFW_Window(id, width, height, canvas.width, canvas.height, title, monitor, share); |
|
|
| |
| if (id - 1 == GLFW.windows.length) { |
| GLFW.windows.push(win); |
| } else { |
| GLFW.windows[id - 1] = win; |
| } |
|
|
| GLFW.active = win; |
| GLFW.adjustCanvasDimensions(); |
| return win.id; |
| }, |
|
|
| destroyWindow: (winid) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
|
|
| #if USE_GLFW == 3 |
| if (win.windowCloseFunc) { |
| {{{ makeDynCall('vp', 'win.windowCloseFunc') }}}(win.id); |
| } |
| #endif |
|
|
| GLFW.windows[win.id - 1] = null; |
| if (GLFW.active.id == win.id) { |
| GLFW.active = null; |
| } |
|
|
| |
| for (win of GLFW.windows) { |
| if (win !== null) return; |
| } |
|
|
| delete Module['ctx']; |
| }, |
|
|
| swapBuffers: (winid) => { |
| }, |
|
|
| |
| requestFullscreen(lockPointer, resizeCanvas) { |
| Browser.lockPointer = lockPointer; |
| Browser.resizeCanvas = resizeCanvas; |
| if (typeof Browser.lockPointer == 'undefined') Browser.lockPointer = true; |
| if (typeof Browser.resizeCanvas == 'undefined') Browser.resizeCanvas = false; |
|
|
| var canvas = Browser.getCanvas(); |
| function fullscreenChange() { |
| Browser.isFullscreen = false; |
| var canvasContainer = canvas.parentNode; |
| if (getFullscreenElement() === canvasContainer) { |
| canvas.exitFullscreen = Browser.exitFullscreen; |
| if (Browser.lockPointer) canvas.requestPointerLock(); |
| Browser.isFullscreen = true; |
| if (Browser.resizeCanvas) { |
| Browser.setFullscreenCanvasSize(); |
| } else { |
| Browser.updateCanvasDimensions(canvas); |
| Browser.updateResizeListeners(); |
| } |
| } else { |
| |
| canvasContainer.parentNode.insertBefore(canvas, canvasContainer); |
| canvasContainer.parentNode.removeChild(canvasContainer); |
|
|
| if (Browser.resizeCanvas) { |
| Browser.setWindowedCanvasSize(); |
| } else { |
| Browser.updateCanvasDimensions(canvas); |
| Browser.updateResizeListeners(); |
| } |
| } |
| Module['onFullScreen']?.(Browser.isFullscreen); |
| Module['onFullscreen']?.(Browser.isFullscreen); |
| } |
|
|
| if (!Browser.fullscreenHandlersInstalled) { |
| Browser.fullscreenHandlersInstalled = true; |
| document.addEventListener('fullscreenchange', fullscreenChange, false); |
| document.addEventListener('mozfullscreenchange', fullscreenChange, false); |
| document.addEventListener('webkitfullscreenchange', fullscreenChange, false); |
| document.addEventListener('MSFullscreenChange', fullscreenChange, false); |
| } |
|
|
| |
| var canvasContainer = document.createElement("div"); |
| canvas.parentNode.insertBefore(canvasContainer, canvas); |
| canvasContainer.appendChild(canvas); |
|
|
| |
| canvasContainer.requestFullscreen = canvasContainer['requestFullscreen'] || |
| canvasContainer['mozRequestFullScreen'] || |
| canvasContainer['msRequestFullscreen'] || |
| (canvasContainer['webkitRequestFullscreen'] ? () => canvasContainer['webkitRequestFullscreen'](Element['ALLOW_KEYBOARD_INPUT']) : null) || |
| (canvasContainer['webkitRequestFullScreen'] ? () => canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) : null); |
|
|
| canvasContainer.requestFullscreen(); |
| }, |
|
|
| |
| updateCanvasDimensions(canvas, wNative, hNative) { |
| const scale = GLFW.getHiDPIScale(); |
|
|
| if (wNative && hNative) { |
| canvas.widthNative = wNative; |
| canvas.heightNative = hNative; |
| } else { |
| wNative = canvas.widthNative; |
| hNative = canvas.heightNative; |
| } |
| var w = wNative; |
| var h = hNative; |
| if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) { |
| if (w/h < Module['forcedAspectRatio']) { |
| w = Math.round(h * Module['forcedAspectRatio']); |
| } else { |
| h = Math.round(w / Module['forcedAspectRatio']); |
| } |
| } |
| if ((getFullscreenElement() === canvas.parentNode) && (typeof screen != 'undefined')) { |
| var factor = Math.min(screen.width / w, screen.height / h); |
| w = Math.round(w * factor); |
| h = Math.round(h * factor); |
| } |
| if (Browser.resizeCanvas) { |
| wNative = w; |
| hNative = h; |
| } |
| const wNativeScaled = Math.floor(wNative * scale); |
| const hNativeScaled = Math.floor(hNative * scale); |
| if (canvas.width != wNativeScaled) canvas.width = wNativeScaled; |
| if (canvas.height != hNativeScaled) canvas.height = hNativeScaled; |
| if (typeof canvas.style != 'undefined') { |
| if (!GLFW.isCSSScalingEnabled()) { |
| canvas.style.setProperty( "width", wNative + "px", "important"); |
| canvas.style.setProperty("height", hNative + "px", "important"); |
| } else { |
| canvas.style.removeProperty( "width"); |
| canvas.style.removeProperty("height"); |
| } |
| } |
| }, |
|
|
| |
| calculateMouseCoords(pageX, pageY) { |
| |
| |
| const rect = Browser.getCanvas().getBoundingClientRect(); |
|
|
| var adjustedX = pageX - (window.scrollX + rect.left); |
| var adjustedY = pageY - (window.scrollY + rect.top); |
|
|
| |
| |
| |
| |
| if (GLFW.isCSSScalingEnabled() && GLFW.active) { |
| adjustedX = adjustedX * (GLFW.active.width / rect.width); |
| adjustedY = adjustedY * (GLFW.active.height / rect.height); |
| } |
|
|
| return { x: adjustedX, y: adjustedY }; |
| }, |
|
|
| setWindowAttrib: (winid, attrib, value) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
| const isHiDPIAware = GLFW.isHiDPIAware(); |
| win.attributes[attrib] = value; |
| if (isHiDPIAware !== GLFW.isHiDPIAware()) |
| GLFW.adjustCanvasDimensions(); |
| }, |
|
|
| getDevicePixelRatio() { |
| return (typeof devicePixelRatio == 'number' && devicePixelRatio) || 1.0; |
| }, |
|
|
| isHiDPIAware() { |
| if (GLFW.active) |
| return GLFW.active.attributes[0x0002200C] > 0; |
| else |
| return false; |
| }, |
|
|
| |
| |
| |
| |
| isCSSScalingEnabled() { |
| return !GLFW.isHiDPIAware(); |
| }, |
|
|
| adjustCanvasDimensions() { |
| if (GLFW.active) { |
| Browser.updateCanvasDimensions(Browser.getCanvas(), GLFW.active.width, GLFW.active.height); |
| Browser.updateResizeListeners(); |
| } |
| }, |
|
|
| getHiDPIScale() { |
| return GLFW.isHiDPIAware() ? GLFW.scale : 1.0; |
| }, |
|
|
| onDevicePixelRatioChange() { |
| GLFW.onWindowContentScaleChanged(GLFW.getDevicePixelRatio()); |
| GLFW.adjustCanvasDimensions(); |
| }, |
|
|
| GLFW2ParamToGLFW3Param: (param) => { |
| var table = { |
| 0x00030001:0, |
| 0x00030002:0, |
| 0x00030003:0, |
| 0x00030004:0, |
| 0x00030005:0, |
| 0x00030006:0, |
| 0x00020001:0, |
| 0x00020002:0, |
| 0x00020003:0, |
| 0x00020004:0, |
| 0x00020005:0x00021001, |
| 0x00020006:0x00021002, |
| 0x00020007:0x00021003, |
| 0x00020008:0x00021004, |
| 0x00020009:0x00021005, |
| 0x0002000A:0x00021006, |
| 0x0002000B:0x0002100F, |
| 0x0002000C:0x00021007, |
| 0x0002000D:0x00021008, |
| 0x0002000E:0x00021009, |
| 0x0002000F:0x0002100A, |
| 0x00020010:0x0002100B, |
| 0x00020011:0x0002100C, |
| 0x00020012:0, |
| 0x00020013:0x0002100D, |
| 0x00020014:0x00022002, |
| 0x00020015:0x00022003, |
| 0x00020016:0x00022006, |
| 0x00020017:0x00022007, |
| 0x00020018:0x00022008, |
| }; |
| return table[param]; |
| } |
| }, |
|
|
| |
| |
| |
| glfwInit: () => { |
| if (GLFW.windows) return 1; |
|
|
| GLFW.initialTime = GLFW.getTime(); |
| GLFW.defaultWindowHints(); |
| GLFW.windows = new Array() |
| GLFW.active = null; |
| GLFW.scale = GLFW.getDevicePixelRatio(); |
|
|
|
|
| window.addEventListener('gamepadconnected', GLFW.onGamepadConnected, true); |
| window.addEventListener('gamepaddisconnected', GLFW.onGamepadDisconnected, true); |
| window.addEventListener('keydown', GLFW.onKeydown, true); |
| window.addEventListener('keypress', GLFW.onKeyPress, true); |
| window.addEventListener('keyup', GLFW.onKeyup, true); |
| window.addEventListener('blur', GLFW.onBlur, true); |
|
|
| |
| GLFW.devicePixelRatioMQL = window.matchMedia('(resolution: ' + GLFW.getDevicePixelRatio() + 'dppx)'); |
| GLFW.devicePixelRatioMQL.addEventListener('change', GLFW.onDevicePixelRatioChange); |
|
|
| var canvas = Browser.getCanvas(); |
| canvas.addEventListener('touchmove', GLFW.onMousemove, true); |
| canvas.addEventListener('touchstart', GLFW.onMouseButtonDown, true); |
| canvas.addEventListener('touchcancel', GLFW.onMouseButtonUp, true); |
| canvas.addEventListener('touchend', GLFW.onMouseButtonUp, true); |
| canvas.addEventListener('mousemove', GLFW.onMousemove, true); |
| canvas.addEventListener('mousedown', GLFW.onMouseButtonDown, true); |
| canvas.addEventListener("mouseup", GLFW.onMouseButtonUp, true); |
| canvas.addEventListener('wheel', GLFW.onMouseWheel, true); |
| canvas.addEventListener('mousewheel', GLFW.onMouseWheel, true); |
| canvas.addEventListener('mouseenter', GLFW.onMouseenter, true); |
| canvas.addEventListener('mouseleave', GLFW.onMouseleave, true); |
| canvas.addEventListener('drop', GLFW.onDrop, true); |
| canvas.addEventListener('dragover', GLFW.onDragover, true); |
|
|
| |
| Browser.requestFullscreen = GLFW.requestFullscreen; |
| Browser.calculateMouseCoords = GLFW.calculateMouseCoords; |
| Browser.updateCanvasDimensions = GLFW.updateCanvasDimensions; |
|
|
| Browser.resizeListeners.push((width, height) => { |
| if (GLFW.isHiDPIAware()) { |
| var canvas = Browser.getCanvas(); |
| GLFW.onCanvasResize(canvas.clientWidth, canvas.clientHeight, width, height); |
| } else { |
| GLFW.onCanvasResize(width, height, width, height); |
| } |
| }); |
|
|
| return 1; |
| }, |
|
|
| glfwTerminate: () => { |
| window.removeEventListener('gamepadconnected', GLFW.onGamepadConnected, true); |
| window.removeEventListener('gamepaddisconnected', GLFW.onGamepadDisconnected, true); |
| window.removeEventListener('keydown', GLFW.onKeydown, true); |
| window.removeEventListener('keypress', GLFW.onKeyPress, true); |
| window.removeEventListener('keyup', GLFW.onKeyup, true); |
| window.removeEventListener('blur', GLFW.onBlur, true); |
| var canvas = Browser.getCanvas(); |
| canvas.removeEventListener('touchmove', GLFW.onMousemove, true); |
| canvas.removeEventListener('touchstart', GLFW.onMouseButtonDown, true); |
| canvas.removeEventListener('touchcancel', GLFW.onMouseButtonUp, true); |
| canvas.removeEventListener('touchend', GLFW.onMouseButtonUp, true); |
| canvas.removeEventListener('mousemove', GLFW.onMousemove, true); |
| canvas.removeEventListener('mousedown', GLFW.onMouseButtonDown, true); |
| canvas.removeEventListener('mouseup', GLFW.onMouseButtonUp, true); |
| canvas.removeEventListener('wheel', GLFW.onMouseWheel, true); |
| canvas.removeEventListener('mousewheel', GLFW.onMouseWheel, true); |
| canvas.removeEventListener('mouseenter', GLFW.onMouseenter, true); |
| canvas.removeEventListener('mouseleave', GLFW.onMouseleave, true); |
| canvas.removeEventListener('drop', GLFW.onDrop, true); |
| canvas.removeEventListener('dragover', GLFW.onDragover, true); |
|
|
| if (GLFW.devicePixelRatioMQL) |
| GLFW.devicePixelRatioMQL.removeEventListener('change', GLFW.onDevicePixelRatioChange); |
|
|
| canvas.width = canvas.height = 1; |
| GLFW.windows = null; |
| GLFW.active = null; |
| }, |
|
|
| glfwGetVersion: (major, minor, rev) => { |
| #if USE_GLFW == 2 |
| {{{ makeSetValue('major', '0', '2', 'i32') }}}; |
| {{{ makeSetValue('minor', '0', '7', 'i32') }}}; |
| {{{ makeSetValue('rev', '0', '7', 'i32') }}}; |
| #endif |
|
|
| #if USE_GLFW == 3 |
| {{{ makeSetValue('major', '0', '3', 'i32') }}}; |
| {{{ makeSetValue('minor', '0', '2', 'i32') }}}; |
| {{{ makeSetValue('rev', '0', '1', 'i32') }}}; |
| #endif |
| }, |
|
|
| glfwPollEvents: () => 0, |
|
|
| glfwWaitEvents: () => 0, |
|
|
| glfwGetTime: () => GLFW.getTime() - GLFW.initialTime, |
|
|
| glfwSetTime: (time) => { |
| GLFW.initialTime = GLFW.getTime() - time; |
| }, |
|
|
| glfwExtensionSupported__deps: ['glGetString', '$webglGetExtensions'], |
| glfwExtensionSupported: (extension) => { |
| GLFW.extensions ||= webglGetExtensions(); |
|
|
| if (GLFW.extensions.includes(extension)) return 1; |
|
|
| |
| |
| return (GLFW.extensions.includes("GL_" + extension)); |
| }, |
|
|
| glfwSwapInterval__deps: ['emscripten_set_main_loop_timing'], |
| glfwSwapInterval: (interval) => { |
| interval = Math.abs(interval); |
| if (interval == 0) _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_SETTIMEOUT }}}, 0); |
| else _emscripten_set_main_loop_timing({{{ cDefs.EM_TIMING_RAF }}}, interval); |
| }, |
|
|
| #if USE_GLFW == 3 |
| glfwGetVersionString: () => { |
| GLFW.versionString ||= stringToNewUTF8("3.2.1 JS WebGL Emscripten"); |
| return GLFW.versionString; |
| }, |
|
|
| glfwSetErrorCallback: (cbfun) => { |
| var prevcbfun = GLFW.errorFunc; |
| GLFW.errorFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwWaitEventsTimeout: (timeout) => 0, |
|
|
| glfwPostEmptyEvent: () => 0, |
|
|
| glfwGetMonitors__deps: ['malloc'], |
| glfwGetMonitors: (count) => { |
| {{{ makeSetValue('count', '0', '1', 'i32') }}}; |
| if (!GLFW.monitors) { |
| GLFW.monitors = _malloc({{{ POINTER_SIZE }}}); |
| {{{ makeSetValue('GLFW.monitors', '0', '1', 'i32') }}}; |
| } |
| return GLFW.monitors; |
| }, |
|
|
| glfwGetPrimaryMonitor: () => 1, |
|
|
| glfwGetMonitorPos: (monitor, x, y) => { |
| {{{ makeSetValue('x', '0', '0', 'i32') }}}; |
| {{{ makeSetValue('y', '0', '0', 'i32') }}}; |
| }, |
|
|
| glfwGetMonitorWorkarea: (monitor, x, y, w, h) => { |
| {{{ makeSetValue('x', '0', '0', 'i32') }}}; |
| {{{ makeSetValue('y', '0', '0', 'i32') }}}; |
|
|
| {{{ makeSetValue('w', '0', 'screen.availWidth', 'i32') }}}; |
| {{{ makeSetValue('h', '0', 'screen.availHeight', 'i32') }}}; |
| }, |
|
|
| glfwGetMonitorPhysicalSize: (monitor, width, height) => { |
| |
| |
| |
| |
| {{{ makeSetValue('width', '0', '0', 'i32') }}}; |
| {{{ makeSetValue('height', '0', '0', 'i32') }}}; |
| }, |
|
|
| glfwGetMonitorContentScale: (monitor, x, y) => { |
| {{{ makeSetValue('x', '0', 'GLFW.scale', 'float') }}}; |
| {{{ makeSetValue('y', '0', 'GLFW.scale', 'float') }}}; |
| }, |
|
|
| glfwGetMonitorName: (mon) => { |
| GLFW.monitorString ||= stringToNewUTF8("HTML5 WebGL Canvas"); |
| return GLFW.monitorString; |
| }, |
|
|
| glfwSetMonitorCallback: (cbfun) => { |
| var prevcbfun = GLFW.monitorFunc; |
| GLFW.monitorFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| |
| glfwGetVideoModes: (monitor, count) => { |
| {{{ makeSetValue('count', '0', '0', 'i32') }}}; |
| return 0; |
| }, |
|
|
| |
| glfwGetVideoMode: (monitor) => 0, |
|
|
| |
| glfwSetGamma: (monitor, gamma) => 0, |
|
|
| glfwGetGammaRamp: (monitor) => abort("glfwGetGammaRamp not implemented."), |
|
|
| glfwSetGammaRamp: (monitor, ramp) => abort("glfwSetGammaRamp not implemented."), |
|
|
| glfwDefaultWindowHints: () => GLFW.defaultWindowHints(), |
|
|
| glfwWindowHint: (target, hint) => { |
| GLFW.hints[target] = hint; |
| }, |
|
|
| glfwWindowHintString: (hint, value) => { |
| |
| |
| |
| }, |
|
|
| glfwCreateWindow: (width, height, title, monitor, share) => GLFW.createWindow(width, height, title, monitor, share), |
|
|
| glfwDestroyWindow: (winid) => GLFW.destroyWindow(winid), |
|
|
| glfwWindowShouldClose: (winid) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return 0; |
| return win.shouldClose; |
| }, |
|
|
| glfwSetWindowShouldClose: (winid, value) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
| win.shouldClose = value; |
| }, |
|
|
| glfwSetWindowTitle: (winid, title) => GLFW.setWindowTitle(winid, title), |
|
|
| glfwGetWindowPos: (winid, x, y) => GLFW.getWindowPos(winid, x, y), |
|
|
| glfwSetWindowPos: (winid, x, y) => GLFW.setWindowPos(winid, x, y), |
|
|
| glfwGetWindowSize: (winid, width, height) => GLFW.getWindowSize(winid, width, height), |
|
|
| glfwSetWindowSize: (winid, width, height) => GLFW.setWindowSize(winid, width, height), |
|
|
| glfwGetFramebufferSize: (winid, width, height) => { |
| var ww = 0; |
| var wh = 0; |
|
|
| var win = GLFW.WindowFromId(winid); |
| if (win) { |
| ww = win.framebufferWidth; |
| wh = win.framebufferHeight; |
| } |
|
|
| if (width) { |
| {{{ makeSetValue('width', '0', 'ww', 'i32') }}}; |
| } |
|
|
| if (height) { |
| {{{ makeSetValue('height', '0', 'wh', 'i32') }}}; |
| } |
| }, |
|
|
| glfwGetWindowContentScale: (winid, x, y) => { |
| |
| |
| {{{ makeSetValue('x', '0', 'GLFW.scale', 'float') }}}; |
| {{{ makeSetValue('y', '0', 'GLFW.scale', 'float') }}}; |
| }, |
|
|
| glfwGetWindowOpacity: (winid) => 1.0, |
|
|
| glfwSetWindowOpacity: (winid, opacity) => { }, |
|
|
| glfwIconifyWindow: (winid) => { |
| #if ASSERTIONS |
| warnOnce('glfwIconifyWindow is not implemented'); |
| #endif |
| }, |
|
|
| glfwRestoreWindow: (winid) => { |
| #if ASSERTIONS |
| warnOnce('glfwRestoreWindow is not implemented'); |
| #endif |
| }, |
|
|
| glfwShowWindow: (winid) => 0, |
|
|
| glfwHideWindow: (winid) => 0, |
|
|
| glfwGetWindowMonitor: (winid) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return 0; |
| return win.monitor; |
| }, |
|
|
| glfwGetWindowAttrib: (winid, attrib) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return 0; |
| return win.attributes[attrib]; |
| }, |
|
|
| glfwSetWindowAttrib: (winid, attrib, value) => GLFW.setWindowAttrib(winid, attrib, value), |
|
|
| glfwSetWindowUserPointer: (winid, ptr) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
| win.userptr = ptr; |
| }, |
|
|
| glfwGetWindowUserPointer: (winid) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return 0; |
| return win.userptr; |
| }, |
|
|
| glfwSetWindowPosCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowPosFunc; |
| win.windowPosFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwSetWindowSizeCallback: (winid, cbfun) => GLFW.setWindowSizeCallback(winid, cbfun), |
|
|
| glfwSetWindowCloseCallback: (winid, cbfun) => GLFW.setWindowCloseCallback(winid, cbfun), |
|
|
| glfwSetWindowRefreshCallback: (winid, cbfun) => GLFW.setWindowRefreshCallback(winid, cbfun), |
|
|
| glfwSetWindowFocusCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowFocusFunc; |
| win.windowFocusFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwSetWindowIconifyCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowIconifyFunc; |
| win.windowIconifyFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwSetWindowMaximizeCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowMaximizeFunc; |
| win.windowMaximizeFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwSetWindowIcon: (winid, count, images) => 0, |
|
|
| glfwSetWindowSizeLimits: (winid, minwidth, minheight, maxwidth, maxheight) => 0, |
|
|
| glfwSetWindowAspectRatio: (winid, numer, denom) => 0, |
|
|
| glfwGetWindowFrameSize: (winid, left, top, right, bottom) => abort("glfwGetWindowFrameSize not implemented."), |
|
|
| glfwMaximizeWindow: (winid) => 0, |
|
|
| glfwFocusWindow: (winid) => 0, |
|
|
| glfwRequestWindowAttention: (winid) => 0, |
|
|
| glfwSetWindowMonitor: (winid, monitor, xpos, ypos, width, height, refreshRate) => abort("glfwSetWindowMonitor not implemented."), |
|
|
| glfwCreateCursor: (image, xhot, yhot) => 0, |
|
|
| glfwCreateStandardCursor: (shape) => 0, |
|
|
| glfwDestroyCursor: (cursor) => 0, |
|
|
| glfwSetCursor: (winid, cursor) => 0, |
|
|
| glfwSetFramebufferSizeCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.framebufferSizeFunc; |
| win.framebufferSizeFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwSetWindowContentScaleCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.windowContentScaleFunc; |
| win.windowContentScaleFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwGetInputMode: (winid, mode) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return; |
|
|
| switch (mode) { |
| case 0x00033001: { |
| if (Browser.pointerLock) { |
| win.inputModes[mode] = 0x00034003; |
| } else { |
| win.inputModes[mode] = 0x00034001; |
| } |
| } |
| } |
|
|
| return win.inputModes[mode]; |
| }, |
|
|
| glfwSetInputMode: (winid, mode, value) => { |
| GLFW.setInputMode(winid, mode, value); |
| }, |
|
|
| glfwRawMouseMotionSupported: () => 0, |
|
|
| glfwGetKey: (winid, key) => GLFW.getKey(winid, key), |
|
|
| glfwGetKeyName: (key, scancode) => abort("glfwGetKeyName not implemented."), |
|
|
| glfwGetKeyScancode: (key) => abort("glfwGetKeyScancode not implemented."), |
|
|
| glfwGetMouseButton: (winid, button) => GLFW.getMouseButton(winid, button), |
|
|
| glfwGetCursorPos: (winid, x, y) => GLFW.getCursorPos(winid, x, y), |
|
|
| |
| glfwSetCursorPos: (winid, x, y) => GLFW.setCursorPos(winid, x, y), |
|
|
| glfwSetKeyCallback: (winid, cbfun) => GLFW.setKeyCallback(winid, cbfun), |
|
|
| glfwSetCharCallback: (winid, cbfun) => GLFW.setCharCallback(winid, cbfun), |
|
|
| glfwSetCharModsCallback: (winid, cbfun) => abort("glfwSetCharModsCallback not implemented."), |
|
|
| glfwSetMouseButtonCallback: (winid, cbfun) => GLFW.setMouseButtonCallback(winid, cbfun), |
|
|
| glfwSetCursorPosCallback: (winid, cbfun) => GLFW.setCursorPosCallback(winid, cbfun), |
|
|
| glfwSetCursorEnterCallback: (winid, cbfun) => { |
| var win = GLFW.WindowFromId(winid); |
| if (!win) return null; |
| var prevcbfun = win.cursorEnterFunc; |
| win.cursorEnterFunc = cbfun; |
| return prevcbfun; |
| }, |
|
|
| glfwSetScrollCallback: (winid, cbfun) => GLFW.setScrollCallback(winid, cbfun), |
|
|
| glfwVulkanSupported: () => 0, |
|
|
| glfwSetDropCallback: (winid, cbfun) => GLFW.setDropCallback(winid, cbfun), |
|
|
| glfwGetTimerValue: () => abort("glfwGetTimerValue is not implemented."), |
|
|
| glfwGetTimerFrequency: () => abort("glfwGetTimerFrequency is not implemented."), |
|
|
| glfwGetRequiredInstanceExtensions: (count) => abort("glfwGetRequiredInstanceExtensions is not implemented."), |
|
|
| glfwJoystickPresent: (joy) => { |
| GLFW.refreshJoysticks(); |
|
|
| return GLFW.joys[joy] !== undefined; |
| }, |
|
|
| glfwGetJoystickAxes: (joy, count) => { |
| GLFW.refreshJoysticks(); |
|
|
| var state = GLFW.joys[joy]; |
| if (!state || !state.axes) { |
| {{{ makeSetValue('count', '0', '0', 'i32') }}}; |
| return; |
| } |
|
|
| {{{ makeSetValue('count', '0', 'state.axesCount', 'i32') }}}; |
| return state.axes; |
| }, |
|
|
| glfwGetJoystickButtons: (joy, count) => { |
| GLFW.refreshJoysticks(); |
|
|
| var state = GLFW.joys[joy]; |
| if (!state || !state.buttons) { |
| {{{ makeSetValue('count', '0', '0', 'i32') }}}; |
| return; |
| } |
|
|
| {{{ makeSetValue('count', '0', 'state.buttonsCount', 'i32') }}}; |
| return state.buttons; |
| }, |
|
|
| glfwGetJoystickHats: (joy, count) => abort("glfwGetJoystickHats is not implemented"), |
|
|
| glfwGetJoystickName: (joy) => { |
| if (GLFW.joys[joy]) { |
| return GLFW.joys[joy].id; |
| } |
| return 0; |
| }, |
|
|
| glfwGetJoystickGUID: (jid) => abort("glfwGetJoystickGUID not implemented"), |
|
|
| glfwSetJoystickUserPointer: (jid, ptr) => abort("glfwSetJoystickUserPointer not implemented"), |
|
|
| glfwGetJoystickUserPointer: (jid) => abort("glfwGetJoystickUserPointer not implemented"), |
|
|
| glfwJoystickIsGamepad: (jid) => abort("glfwJoystickIsGamepad not implemented"), |
|
|
| glfwSetJoystickCallback: (cbfun) => GLFW.setJoystickCallback(cbfun), |
|
|
| glfwSetClipboardString: (win, string) => 0, |
|
|
| glfwGetClipboardString: (win) => 0, |
|
|
| glfwMakeContextCurrent: (winid) => 0, |
|
|
| glfwGetCurrentContext: () => GLFW.active ? GLFW.active.id : 0, |
|
|
| glfwSwapBuffers: (winid) => GLFW.swapBuffers(winid), |
|
|
| #elif USE_GLFW == 2 |
| glfwOpenWindow: (width, height, redbits, greenbits, bluebits, alphabits, depthbits, stencilbits, mode) => { |
| GLFW.hints[0x00021001] = redbits; |
| GLFW.hints[0x00021002] = greenbits; |
| GLFW.hints[0x00021003] = bluebits; |
| GLFW.hints[0x00021004] = alphabits; |
| GLFW.hints[0x00021005] = depthbits; |
| GLFW.hints[0x00021006] = stencilbits; |
| GLFW.createWindow(width, height, "GLFW2 Window", 0, 0); |
| return 1; |
| }, |
|
|
| glfwCloseWindow: () => GLFW.destroyWindow(GLFW.active.id), |
|
|
| glfwOpenWindowHint: (target, hint) => { |
| target = GLFW.GLFW2ParamToGLFW3Param(target); |
| GLFW.hints[target] = hint; |
| }, |
|
|
| glfwGetWindowSize_v2: (width, height) => GLFW.getWindowSize(GLFW.active.id, width, height), |
|
|
| glfwSetWindowSize_v2: (width, height) => GLFW.setWindowSize(GLFW.active.id, width, height), |
|
|
| glfwSetWindowPos_v2: (x, y) => GLFW.setWindowPos(GLFW.active.id, x, y), |
|
|
| glfwSetWindowTitle_v2: (title) => GLFW.setWindowTitle(GLFW.active.id, title), |
|
|
| glfwIconifyWindow_v2: () => { |
| #if ASSERTIONS |
| warnOnce('glfwIconifyWindow is not implemented'); |
| #endif |
| }, |
|
|
| glfwRestoreWindow_v2: () => { |
| #if ASSERTIONS |
| warnOnce('glfwRestoreWindow is not implemented'); |
| #endif |
| }, |
|
|
| glfwSwapBuffers_v2: () => GLFW.swapBuffers(GLFW.active.id), |
|
|
| glfwGetWindowParam: (param) => { |
| param = GLFW.GLFW2ParamToGLFW3Param(param); |
| return GLFW.hints[param]; |
| }, |
|
|
| glfwSetWindowSizeCallback_v2: (cbfun) => { |
| GLFW.setWindowSizeCallback(GLFW.active.id, cbfun); |
| }, |
|
|
| glfwSetWindowCloseCallback_v2: (cbfun) => { |
| GLFW.setWindowCloseCallback(GLFW.active.id, cbfun); |
| }, |
|
|
| glfwSetWindowRefreshCallback_v2: (cbfun) => GLFW.setWindowRefreshCallback(GLFW.active.id, cbfun), |
|
|
| glfwGetKey_v2: (key) => GLFW.getKey(GLFW.active.id, key), |
|
|
| glfwGetMouseButton_v2: (button) => GLFW.getMouseButton(GLFW.active.id, button), |
|
|
| glfwGetMousePos: (x, y) => { |
| GLFW.getMousePos(GLFW.active.id, x, y); |
| }, |
|
|
| glfwSetMousePos: (x, y) => { |
| GLFW.setCursorPos(GLFW.active.id, x, y); |
| }, |
|
|
| glfwGetMouseWheel: () => 0, |
|
|
| glfwSetMouseWheel: (pos) => 0, |
|
|
| glfwSetKeyCallback_v2: (cbfun) => { |
| GLFW.setKeyCallback(GLFW.active.id, cbfun); |
| }, |
|
|
| glfwSetCharCallback_v2: (cbfun) => { |
| GLFW.setCharCallback(GLFW.active.id, cbfun); |
| }, |
|
|
| glfwSetMouseButtonCallback_v2: (cbfun) => { |
| GLFW.setMouseButtonCallback(GLFW.active.id, cbfun); |
| }, |
|
|
| glfwSetMousePosCallback: (cbfun) => { |
| GLFW.setCursorPosCallback(GLFW.active.id, cbfun); |
| }, |
|
|
| glfwSetMouseWheelCallback: (cbfun) => { |
| GLFW.setScrollCallback(GLFW.active.id, cbfun); |
| }, |
|
|
| glfwGetDesktopMode: (mode) => abort("glfwGetDesktopMode is not implemented."), |
|
|
| glfwSleep__deps: ['sleep'], |
| glfwSleep: (time) => _sleep(time), |
|
|
| glfwEnable: (target) => { |
| target = GLFW.GLFW2ParamToGLFW3Param(target); |
| GLFW.hints[target] = false; |
| }, |
|
|
| glfwDisable: (target) => { |
| target = GLFW.GLFW2ParamToGLFW3Param(target); |
| GLFW.hints[target] = true; |
| }, |
|
|
| glfwGetGLVersion: (major, minor, rev) => { |
| {{{ makeSetValue('major', '0', '0', 'i32') }}}; |
| {{{ makeSetValue('minor', '0', '0', 'i32') }}}; |
| {{{ makeSetValue('rev', '0', '1', 'i32') }}}; |
| }, |
|
|
| glfwCreateThread: (fun, arg) => { |
| {{{ makeDynCall('vp', 'fun') }}}(arg); |
| |
| return 0; |
| }, |
|
|
| glfwDestroyThread: (ID) => 0, |
|
|
| glfwWaitThread: (ID, waitmode) => 0, |
|
|
| |
| glfwGetThreadID: () => 0, |
|
|
| glfwCreateMutex: () => abort("glfwCreateMutex is not implemented."), |
|
|
| glfwDestroyMutex: (mutex) => abort("glfwDestroyMutex is not implemented."), |
|
|
| glfwLockMutex: (mutex) => abort("glfwLockMutex is not implemented."), |
|
|
| glfwUnlockMutex: (mutex) => abort("glfwUnlockMutex is not implemented."), |
|
|
| glfwCreateCond: () => abort("glfwCreateCond is not implemented."), |
|
|
| glfwDestroyCond: (cond) => abort("glfwDestroyCond is not implemented."), |
|
|
| glfwWaitCond: (cond, mutex, timeout) => abort("glfwWaitCond is not implemented."), |
|
|
| glfwSignalCond: (cond) => abort("glfwSignalCond is not implemented."), |
|
|
| glfwBroadcastCond: (cond) => abort("glfwBroadcastCond is not implemented."), |
|
|
| glfwGetNumberOfProcessors: () => 1, |
|
|
| glfwReadImage: (name, img, flags) => abort("glfwReadImage is not implemented."), |
|
|
| glfwReadMemoryImage: (data, size, img, flags) => abort("glfwReadMemoryImage is not implemented."), |
|
|
| glfwFreeImage: (img) => abort("glfwFreeImage is not implemented."), |
|
|
| glfwLoadTexture2D: (name, flags) => abort("glfwLoadTexture2D is not implemented."), |
|
|
| glfwLoadMemoryTexture2D: (data, size, flags) => abort("glfwLoadMemoryTexture2D is not implemented."), |
|
|
| glfwLoadTextureImage2D: (img, flags) => abort("glfwLoadTextureImage2D is not implemented."), |
| #endif |
| }; |
|
|
| autoAddDeps(LibraryGLFW, '$GLFW'); |
| addToLibrary(LibraryGLFW); |
|
|