diff options
author | Andreas Bergmeier <abergmeier@gmx.net> | 2013-11-28 09:36:27 +0100 |
---|---|---|
committer | Andreas Bergmeier <abergmeier@gmx.net> | 2014-02-14 15:36:03 +0100 |
commit | 95f56fca115aa35bf30a240f9faf3534d8035136 (patch) | |
tree | 71db5ce69a5f99dd590bdde056a1cc3025216e04 | |
parent | 45c7d4caae4d6c0db336fb439da3dc75175bd182 (diff) |
Bring eglSwapBuffers closer to actual documentation.
Checks now whether ctx was initialized and not lost. Does a glFlush before returning.
And returns success codes from function.
-rw-r--r-- | src/library_egl.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/library_egl.js b/src/library_egl.js index 69dd266d..1aba9306 100644 --- a/src/library_egl.js +++ b/src/library_egl.js @@ -548,9 +548,20 @@ var LibraryEGL = { return EGL.currentContext ? 62000 /* Magic ID for Emscripten 'default display' */ : 0; }, + eglSwapBuffers__deps: ['glFlush', '$GL'], // EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); eglSwapBuffers: function() { - EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); + if (!Module.ctx) { + EGL.setErrorCode(0x3001 /* EGL_NOT_INITIALIZED */); + } else if (Module.ctx.isContextLost()) { + EGL.setErrorCode(0x300E /* EGL_CONTEXT_LOST */); + } else { + // According to documentation this does an implicit flush + _glFlush(); + EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); + return 1; // EGL_TRUE + } + return 0; // EGL_FALSE }, eglGetProcAddress__deps: ['emscripten_GetProcAddress'], |