Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,6 @@ jobs:
browser64.test_idbstore
browser64.test_idbstore_sync_asyncify
browser64.test_idbstore_sync_jspi
browser64.test_egl
browser64.test_egl_width_height
browser64.test_egl_createcontext_error
browser64.test_glgears_animation
browser64.test_glgears_deriv
browser64.test_anisotropic
browser64.test_webgpu_get_device
browser64.test_fetch_*
Expand All @@ -794,6 +789,11 @@ jobs:
browser64.test_emscripten_async_wget_*
browser64.test_wasm_worker_*
browser64.test_sdl_*
browser64.test_egl*
browser64.test_gl_*
browser64.test_glgears*
browser64.test_glfw*
browser64.test_glew
"
test-browser-firefox:
executor: bionic
Expand Down
2 changes: 1 addition & 1 deletion src/library_glew.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var LibraryGLEW = {

extensionIsSupported(name) {
if (!GLEW.extensions) {
GLEW.extensions = UTF8ToString(_glGetString(0x1F03)).split(' ');
GLEW.extensions = GL.getExtensions();
}

if (GLEW.extensions.includes(name))
Expand Down
62 changes: 32 additions & 30 deletions src/library_glfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ var LibraryGLFW = {
this.domKeys = new Array();
this.shouldClose = 0;
this.title = null;
this.windowPosFunc = null; // GLFWwindowposfun
this.windowSizeFunc = null; // GLFWwindowsizefun
this.windowCloseFunc = null; // GLFWwindowclosefun
this.windowRefreshFunc = null; // GLFWwindowrefreshfun
this.windowFocusFunc = null; // GLFWwindowfocusfun
this.windowIconifyFunc = null; // GLFWwindowiconifyfun
this.windowMaximizeFunc = null; // GLFWwindowmaximizefun
this.framebufferSizeFunc = null; // GLFWframebuffersizefun
this.windowContentScaleFunc = null; // GLFWwindowcontentscalefun
this.mouseButtonFunc = null; // GLFWmousebuttonfun
this.cursorPosFunc = null; // GLFWcursorposfun
this.cursorEnterFunc = null; // GLFWcursorenterfun
this.scrollFunc = null; // GLFWscrollfun
this.dropFunc = null; // GLFWdropfun
this.keyFunc = null; // GLFWkeyfun
this.charFunc = null; // GLFWcharfun
this.userptr = null;
this.windowPosFunc = 0; // GLFWwindowposfun
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is because null cannot be converted to BigInt when we return these as pointers.

this.windowSizeFunc = 0; // GLFWwindowsizefun
this.windowCloseFunc = 0; // GLFWwindowclosefun
this.windowRefreshFunc = 0; // GLFWwindowrefreshfun
this.windowFocusFunc = 0; // GLFWwindowfocusfun
this.windowIconifyFunc = 0; // GLFWwindowiconifyfun
this.windowMaximizeFunc = 0; // GLFWwindowmaximizefun
this.framebufferSizeFunc = 0; // GLFWframebuffersizefun
this.windowContentScaleFunc = 0; // GLFWwindowcontentscalefun
this.mouseButtonFunc = 0; // GLFWmousebuttonfun
this.cursorPosFunc = 0; // GLFWcursorposfun
this.cursorEnterFunc = 0; // GLFWcursorenterfun
this.scrollFunc = 0; // GLFWscrollfun
this.dropFunc = 0; // GLFWdropfun
this.keyFunc = 0; // GLFWkeyfun
this.charFunc = 0; // GLFWcharfun
this.userptr = 0;
},

$GLFW__deps: ['emscripten_get_now', '$GL', '$Browser', '$GLFW_Window',
Expand All @@ -94,9 +94,9 @@ var LibraryGLFW = {
return GLFW.windows[id - 1];
},

joystickFunc: null, // GLFWjoystickfun
errorFunc: null, // GLFWerrorfun
monitorFunc: null, // GLFWmonitorfun
joystickFunc: 0, // GLFWjoystickfun
errorFunc: 0, // GLFWerrorfun
monitorFunc: 0, // GLFWmonitorfun
active: null, // active window
scale: null,
windows: null,
Expand Down Expand Up @@ -372,7 +372,7 @@ var LibraryGLFW = {
{{{ makeDynCall('vii', 'GLFW.active.charFunc') }}}(charCode, 1);
#endif
#if USE_GLFW == 3
{{{ makeDynCall('vii', 'GLFW.active.charFunc') }}}(GLFW.active.id, charCode);
{{{ makeDynCall('vpi', 'GLFW.active.charFunc') }}}(GLFW.active.id, charCode);
#endif
},

Expand All @@ -394,7 +394,7 @@ var LibraryGLFW = {
#endif
#if USE_GLFW == 3
if (repeat) status = 2; // GLFW_REPEAT
{{{ makeDynCall('viiiii', 'GLFW.active.keyFunc') }}}(GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active));
{{{ makeDynCall('vpiiii', 'GLFW.active.keyFunc') }}}(GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active));
#endif
}
},
Expand Down Expand Up @@ -510,7 +510,7 @@ var LibraryGLFW = {
{{{ makeDynCall('vii', 'GLFW.active.mouseButtonFunc') }}}(eventButton, status);
#endif
#if USE_GLFW == 3
{{{ makeDynCall('viiii', 'GLFW.active.mouseButtonFunc') }}}(GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active));
{{{ makeDynCall('vpiii', 'GLFW.active.mouseButtonFunc') }}}(GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active));
#endif
}
},
Expand Down Expand Up @@ -601,7 +601,7 @@ var LibraryGLFW = {
{{{ makeDynCall('vii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.width, GLFW.active.height);
#endif
#if USE_GLFW == 3
{{{ makeDynCall('viii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
{{{ makeDynCall('vpii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
#endif
}
},
Expand All @@ -611,7 +611,7 @@ var LibraryGLFW = {

#if USE_GLFW == 3
if (GLFW.active.framebufferSizeFunc) {
{{{ makeDynCall('viii', 'GLFW.active.framebufferSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
{{{ makeDynCall('vpii', 'GLFW.active.framebufferSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
}
#endif
},
Expand Down Expand Up @@ -642,8 +642,10 @@ var LibraryGLFW = {
},

setJoystickCallback: (cbfun) => {
var prevcbfun = GLFW.joystickFunc;
GLFW.joystickFunc = cbfun;
GLFW.refreshJoysticks();
return prevcbfun;
},

joys: {}, // glfw joystick data
Expand Down Expand Up @@ -780,7 +782,7 @@ var LibraryGLFW = {
var data = e.target.result;
FS.writeFile(path, new Uint8Array(data));
if (++written === count) {
{{{ makeDynCall('viii', 'GLFW.active.dropFunc') }}}(GLFW.active.id, count, filenames);
{{{ makeDynCall('vpii', 'GLFW.active.dropFunc') }}}(GLFW.active.id, count, filenames);

for (var i = 0; i < filenamesArray.length; ++i) {
_free(filenamesArray[i]);
Expand Down Expand Up @@ -994,7 +996,7 @@ var LibraryGLFW = {
{{{ makeDynCall('vii', 'win.windowSizeFunc') }}}(width, height);
#endif
#if USE_GLFW == 3
{{{ makeDynCall('viii', 'win.windowSizeFunc') }}}(win.id, width, height);
{{{ makeDynCall('vpii', 'win.windowSizeFunc') }}}(win.id, width, height);
#endif
}
},
Expand Down Expand Up @@ -1064,7 +1066,7 @@ var LibraryGLFW = {

#if USE_GLFW == 3
if (win.windowCloseFunc) {
{{{ makeDynCall('vi', 'win.windowCloseFunc') }}}(win.id);
{{{ makeDynCall('vp', 'win.windowCloseFunc') }}}(win.id);
}
#endif

Expand Down Expand Up @@ -1220,7 +1222,7 @@ var LibraryGLFW = {
glfwExtensionSupported__deps: ['glGetString'],
glfwExtensionSupported: (extension) => {
if (!GLFW.extensions) {
GLFW.extensions = UTF8ToString(_glGetString(0x1F03)).split(' ');
GLFW.extensions = GL.getExtensions();
}

if (GLFW.extensions.includes(extension)) return 1;
Expand Down Expand Up @@ -1758,7 +1760,7 @@ var LibraryGLFW = {
},

glfwCreateThread: (fun, arg) => {
{{{ makeDynCall('vi', 'fun') }}}(arg);
{{{ makeDynCall('vp', 'fun') }}}(arg);
// One single thread
return 0;
},
Expand Down
14 changes: 9 additions & 5 deletions src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,14 @@ var LibraryGL = {
});
},
#endif

getExtensions() {
var exts = GLctx.getSupportedExtensions() || []; // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
exts = exts.concat(exts.map((e) => "GL_" + e));
#endif
return exts;
},
},

glPixelStorei: (pname, param) => {
Expand All @@ -1141,11 +1149,7 @@ var LibraryGL = {
if (!ret) {
switch (name_) {
case 0x1F03 /* GL_EXTENSIONS */:
var exts = GLctx.getSupportedExtensions() || []; // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
exts = exts.concat(exts.map((e) => "GL_" + e));
#endif
ret = stringToNewUTF8(exts.join(' '));
ret = stringToNewUTF8(GL.getExtensions().join(' '));
break;
case 0x1F00 /* GL_VENDOR */:
case 0x1F01 /* GL_RENDERER */:
Expand Down
7 changes: 1 addition & 6 deletions src/library_webgl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ var LibraryWebGL2 = {
}
switch (name) {
case 0x1F03 /* GL_EXTENSIONS */:
var exts = GLctx.getSupportedExtensions() || []; // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
exts = exts.concat(exts.map(function(e) { return "GL_" + e; }));
#endif
exts = exts.map(function(e) { return stringToNewUTF8(e); });

var exts = GL.getExtensions().map((e) => stringToNewUTF8(e));
stringiCache = GL.stringiCache[name] = exts;
if (index < 0 || index >= stringiCache.length) {
GL.recordError(0x501/*GL_INVALID_VALUE*/);
Expand Down
7 changes: 7 additions & 0 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,7 @@ def _test_egl_base(self, *args):
def test_egl(self):
self._test_egl_base()

@no_wasm64('TODO: wasm64 + OFB')
@requires_threads
@requires_graphics_hardware
def test_egl_with_proxy_to_pthread(self):
Expand Down Expand Up @@ -2017,26 +2018,32 @@ def test_gl_glteximage(self):
@requires_graphics_hardware
@requires_threads
def test_gl_textures(self, args):
if args and self.is_wasm64():
self.skipTest('TODO: wasm64 + OFB')
self.btest_exit('gl_textures.cpp', args=['-lGL'] + args)

@requires_graphics_hardware
@no_wasm64('TODO: wasm64 + LEGACY_GL_EMULATION')
def test_gl_ps(self):
# pointers and a shader
shutil.copyfile(test_file('screenshot.png'), 'screenshot.png')
self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins'], reference_slack=1)

@requires_graphics_hardware
@no_wasm64('TODO: wasm64 + LEGACY_GL_EMULATION')
def test_gl_ps_packed(self):
# packed data that needs to be strided
shutil.copyfile(test_file('screenshot.png'), 'screenshot.png')
self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins'], reference_slack=1)

@requires_graphics_hardware
@no_wasm64('TODO: wasm64 + LEGACY_GL_EMULATION')
def test_gl_ps_strides(self):
shutil.copyfile(test_file('screenshot.png'), 'screenshot.png')
self.btest('gl_ps_strides.c', reference='gl_ps_strides.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins'])

@requires_graphics_hardware
@no_wasm64('TODO: wasm64 + LEGACY_GL_EMULATION')
def test_gl_ps_worker(self):
shutil.copyfile(test_file('screenshot.png'), 'screenshot.png')
self.btest('gl_ps_worker.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins'], reference_slack=1, also_proxied=True)
Expand Down