diff options
-rw-r--r-- | src/library_egl.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/library_egl.js b/src/library_egl.js index 69dd266d..e2d1df43 100644 --- a/src/library_egl.js +++ b/src/library_egl.js @@ -550,7 +550,21 @@ var LibraryEGL = { // EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); eglSwapBuffers: function() { - EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); + if (!EGL.defaultDisplayInitialized) { + EGL.setErrorCode(0x3001 /* EGL_NOT_INITIALIZED */); + } else if (!Module.ctx) { + EGL.setErrorCode(0x3002 /* EGL_BAD_ACCESS */); + } else if (Module.ctx.isContextLost()) { + EGL.setErrorCode(0x300E /* EGL_CONTEXT_LOST */); + } else { + // According to documentation this does an implicit flush. + // Due to discussion at https://github.com/kripken/emscripten/pull/1871 + // the flush was removed since this _may_ result in slowing code down. + //_glFlush(); + EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); + return 1; // EGL_TRUE + } + return 0; // EGL_FALSE }, eglGetProcAddress__deps: ['emscripten_GetProcAddress'], |