If I understand correctly, EGL_NOT_INITIALIZED should be raised when eglInitialize has not been called, or has failed. In current code, that corresponds to if (!EGL.defaultDisplayInitialized) { ... } path. Perhaps a more appropriate error on !Module.ctx would be EGL_BAD_ACCESS or EGL_BAD_CURRENT_SURFACE?