將『風水羅盤』由『Windows』移稙過『Andord』. 係交換緩存畫面『eglSwapBuffers()』返回『EGL_FALSE』, 『eglGetError()』返回『EGL_BAD_SURFACE』.
EGLBoolean ret = eglSwapBuffers(display,surface);
if(ret == EGL_FALSE){ GLint error = eglGetError(); if(error == EGL_BAD_SURFACE){ } } |
係『Windows』有『Winmain()』入口. 可以控制冚個整游戲運作, 係 『Winmain()』 游戲『運行』『渲染』都係主線程行.
而 『Andord』冇『Winmain()』. 游戲『運行』『渲染』要係新線程『Thread()』行. 而『EGLContext』同『EGLSurface』需係同壹線程『Thread()』生成, 唔係『eglSwapBuffers()』投『EGL_BAD_SURFACE』錯誤碼.
知錯係邊就易整, 將egl()程式擺係新線程『Thread()』行,而非『 onSurfaceCreated()』.
新線程『Thread()』 |
EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id); |
EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor); |
EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); |
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface); |
EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); |
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); |
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); |