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
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ jobs:
browser64.test_idbstore*
browser64.test_fs_idbfs*
browser64.test_webgl*
browser64.test_glbook
browser64.test_gles2_emulation*
"
test-browser-firefox:
executor: bionic
Expand Down
19 changes: 7 additions & 12 deletions src/library_egl.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,13 @@ var LibraryEGL = {
eglGetDisplay__proxy: 'sync',
eglGetDisplay: (nativeDisplayType) => {
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
// Note: As a 'conformant' implementation of EGL, we would prefer to init here only if the user
// calls this function with EGL_DEFAULT_DISPLAY. Other display IDs would be preferred to be unsupported
// and EGL_NO_DISPLAY returned. Uncomment the following code lines to do this.
// Instead, an alternative route has been preferred, namely that the Emscripten EGL implementation
// "emulates" X11, and eglGetDisplay is expected to accept/receive a pointer to an X11 Display object.
// Therefore, be lax and allow anything to be passed in, and return the magic handle to our default EGLDisplay object.

// if (nativeDisplayType == 0 /* EGL_DEFAULT_DISPLAY */) {
return {{{ eglDefaultDisplay }}};
// }
// else
// return 0; // EGL_NO_DISPLAY
// Emscripten EGL implementation "emulates" X11, and eglGetDisplay is
// expected to accept/receive a pointer to an X11 Display object (or
// EGL_DEFAULT_DISPLAY).
if (nativeDisplayType != 0 /* EGL_DEFAULT_DISPLAY */ && nativeDisplayType != 1 /* see library_xlib.js */) {
return 0; // EGL_NO_DISPLAY
}
return {{{ eglDefaultDisplay }}};
},

// EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
Expand Down
2 changes: 1 addition & 1 deletion src/library_sigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ sigs = {
eglGetCurrentContext__sig: 'p',
eglGetCurrentDisplay__sig: 'p',
eglGetCurrentSurface__sig: 'pi',
eglGetDisplay__sig: 'pi',
eglGetDisplay__sig: 'pp',
eglGetError__sig: 'i',
eglInitialize__sig: 'ippp',
eglMakeCurrent__sig: 'ipppp',
Expand Down
2 changes: 1 addition & 1 deletion system/include/EGL/eglplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ typedef HWND EGLNativeWindowType;

#elif defined(__EMSCRIPTEN__)

typedef int EGLNativeDisplayType;
typedef void* EGLNativeDisplayType;
typedef int EGLNativePixmapType;
typedef int EGLNativeWindowType;

Expand Down
27 changes: 13 additions & 14 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1839,19 +1839,19 @@ def test_glbook(self):
'Chapter_13/ParticleSystem/CH13_ParticleSystem.o',
], configure=None)

def book_path(*pathelems):
return test_file('third_party/glbook', *pathelems)
def book_path(path):
return test_file('third_party/glbook', path)

for program in programs:
print(program)
basename = os.path.basename(program)
args = ['-lGL', '-lEGL', '-lX11']
if basename == 'CH10_MultiTexture.o':
shutil.copyfile(book_path('Chapter_10', 'MultiTexture', 'basemap.tga'), 'basemap.tga')
shutil.copyfile(book_path('Chapter_10', 'MultiTexture', 'lightmap.tga'), 'lightmap.tga')
shutil.copyfile(book_path('Chapter_10/MultiTexture/basemap.tga'), 'basemap.tga')
shutil.copyfile(book_path('Chapter_10/MultiTexture/lightmap.tga'), 'lightmap.tga')
args += ['--preload-file', 'basemap.tga', '--preload-file', 'lightmap.tga']
elif basename == 'CH13_ParticleSystem.o':
shutil.copyfile(book_path('Chapter_13', 'ParticleSystem', 'smoke.tga'), 'smoke.tga')
shutil.copyfile(book_path('Chapter_13/ParticleSystem/smoke.tga'), 'smoke.tga')
args += ['--preload-file', 'smoke.tga', '-O2'] # test optimizations and closure here as well for more coverage

self.btest(program,
Expand All @@ -1865,23 +1865,22 @@ def book_path(*pathelems):
'full_es3': (['-sFULL_ES3'],)
})
def test_gles2_emulation(self, args):
print(args)
shutil.copyfile(test_file('third_party/glbook/Chapter_10/MultiTexture/basemap.tga'), 'basemap.tga')
shutil.copyfile(test_file('third_party/glbook/Chapter_10/MultiTexture/lightmap.tga'), 'lightmap.tga')
shutil.copyfile(test_file('third_party/glbook/Chapter_13/ParticleSystem/smoke.tga'), 'smoke.tga')

for source, reference in [
(Path('third_party/glbook/Chapter_2', 'Hello_Triangle', 'Hello_Triangle_orig.c'), test_file('third_party/glbook/CH02_HelloTriangle.png')),
# (Path('third_party/glbook/Chapter_8', 'Simple_VertexShader', 'Simple_VertexShader_orig.c'), test_file('third_party/glbook/CH08_SimpleVertexShader.png')), # XXX needs INT extension in WebGL
(Path('third_party/glbook/Chapter_9', 'TextureWrap', 'TextureWrap_orig.c'), test_file('third_party/glbook/CH09_TextureWrap.png')),
# (Path('third_party/glbook/Chapter_9', 'Simple_TextureCubemap', 'Simple_TextureCubemap_orig.c'), test_file('third_party/glbook/CH09_TextureCubemap.png')), # XXX needs INT extension in WebGL
(Path('third_party/glbook/Chapter_9', 'Simple_Texture2D', 'Simple_Texture2D_orig.c'), test_file('third_party/glbook/CH09_SimpleTexture2D.png')),
(Path('third_party/glbook/Chapter_10', 'MultiTexture', 'MultiTexture_orig.c'), test_file('third_party/glbook/CH10_MultiTexture.png')),
(Path('third_party/glbook/Chapter_13', 'ParticleSystem', 'ParticleSystem_orig.c'), test_file('third_party/glbook/CH13_ParticleSystem.png')),
('third_party/glbook/Chapter_2/Hello_Triangle/Hello_Triangle_orig.c', 'third_party/glbook/CH02_HelloTriangle.png'),
# ('third_party/glbook/Chapter_8/Simple_VertexShader/Simple_VertexShader_orig.c', 'third_party/glbook/CH08_SimpleVertexShader.png'), # XXX needs INT extension in WebGL
('third_party/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c', 'third_party/glbook/CH09_TextureWrap.png'),
# ('third_party/glbook/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap_orig.c', 'third_party/glbook/CH09_TextureCubemap.png'), # XXX needs INT extension in WebGL
('third_party/glbook/Chapter_9/Simple_Texture2D/Simple_Texture2D_orig.c', 'third_party/glbook/CH09_SimpleTexture2D.png'),
('third_party/glbook/Chapter_10/MultiTexture/MultiTexture_orig.c', 'third_party/glbook/CH10_MultiTexture.png'),
('third_party/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c', 'third_party/glbook/CH13_ParticleSystem.png'),
]:
print(source)
self.btest(source,
reference=reference,
reference=test_file(reference),
args=['-I' + test_file('third_party/glbook/Common'),
test_file('third_party/glbook/Common/esUtil.c'),
test_file('third_party/glbook/Common/esShader.c'),
Expand Down