{"id":10933,"date":"2021-10-07T14:56:14","date_gmt":"2021-10-07T06:56:14","guid":{"rendered":"https:\/\/www.bookcard.net\/wordpress\/?p=10933"},"modified":"2021-10-07T15:04:21","modified_gmt":"2021-10-07T07:04:21","slug":"android_studio_ndk_opengl_eglswapbuffers_egl_bad_surface","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/android_studio_ndk_opengl_eglswapbuffers_egl_bad_surface\/","title":{"rendered":"Android Studio NDK-OpenGL-\u4ea4\u63db\u7de9\u5b58\u756b\u9762eglSwapBuffers()\u8fd4\u56deEGL_BAD_SURFACE"},"content":{"rendered":"<figure id=\"attachment_10934\" aria-describedby=\"caption-attachment-10934\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/10\/Android_Studio_NDK_OpenGL_eglSwapBuffers_EGL_BAD_SURFACE.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10934\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/10\/Android_Studio_NDK_OpenGL_eglSwapBuffers_EGL_BAD_SURFACE.jpg\" alt=\"Android Studio NDK-OpenGL-\u4ea4\u6362\u7de9\u5b58\u753b\u9762eglSwapBuffers()\u8fd4\u56deEGL_BAD_SURFACE\" width=\"1280\" height=\"800\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/10\/Android_Studio_NDK_OpenGL_eglSwapBuffers_EGL_BAD_SURFACE.jpg 1280w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/10\/Android_Studio_NDK_OpenGL_eglSwapBuffers_EGL_BAD_SURFACE-300x188.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/10\/Android_Studio_NDK_OpenGL_eglSwapBuffers_EGL_BAD_SURFACE-768x480.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><figcaption id=\"caption-attachment-10934\" class=\"wp-caption-text\">Android Studio NDK-OpenGL-\u4ea4\u6362\u7de9\u5b58\u753b\u9762eglSwapBuffers()\u8fd4\u56deEGL_BAD_SURFACE<\/figcaption><\/figure>\n<p>\u5c07\u300e\u98a8\u6c34\u7f85\u76e4\u300f\u7531\u300eWindows\u300f\u79fb\u7a19\u904e\u300eAndord\u300f. \u4fc2\u4ea4\u63db\u7de9\u5b58\u756b\u9762\u300eeglSwapBuffers()\u300f\u8fd4\u56de\u300eEGL_FALSE\u300f, \u300eeglGetError()\u300f\u8fd4\u56de\u300eEGL_BAD_SURFACE\u300f.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">EGLBoolean ret = eglSwapBuffers(display,surface);<\/p>\n<p>if(ret == EGL_FALSE){<\/p>\n<p>GLint error = eglGetError();<\/p>\n<p>if(error == EGL_BAD_SURFACE){<\/p>\n<p>}<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4fc2\u300eWindows\u300f\u6709\u300eWinmain()\u300f\u5165\u53e3. \u53ef\u4ee5\u63a7\u5236\u519a\u500b\u6574\u6e38\u6232\u904b\u4f5c, \u4fc2 \u300eWinmain()\u300f \u6e38\u6232\u300e\u904b\u884c\u300f\u300e\u6e32\u67d3\u300f\u90fd\u4fc2\u4e3b\u7dda\u7a0b\u884c.<\/p>\n<p>\u800c \u300eAndord\u300f\u5187\u300eWinmain()\u300f. \u6e38\u6232\u300e\u904b\u884c\u300f\u300e\u6e32\u67d3\u300f\u8981\u4fc2\u65b0\u7dda\u7a0b\u300eThread()\u300f\u884c. \u800c\u300eEGLContext\u300f\u540c\u300eEGLSurface\u300f\u9700\u4fc2\u540c\u58f9\u7dda\u7a0b\u300eThread()\u300f\u751f\u6210, \u5514\u4fc2\u300eeglSwapBuffers()\u300f\u6295\u300eEGL_BAD_SURFACE\u300f\u932f\u8aa4\u78bc.<\/p>\n<p>\u77e5\u932f\u4fc2\u908a\u5c31\u6613\u6574, \u5c07egl()\u7a0b\u5f0f\u64fa\u4fc2\u65b0\u7dda\u7a0b\u300eThread()\u300f\u884c,\u800c\u975e\u300e onSurfaceCreated()\u300f.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">\u65b0\u7dda\u7a0b\u300eThread()\u300f<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c07\u300e\u98a8\u6c34\u7f85\u76e4\u300f\u7531\u300eWindows\u300f\u79fb\u7a19\u904e\u300eAndord\u300f. \u4fc2\u4ea4\u63db\u7de9\u5b58\u756b\u9762\u300eeglSwapBuffers()\u300f &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/android_studio_ndk_opengl_eglswapbuffers_egl_bad_surface\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">Android Studio NDK-OpenGL-\u4ea4\u63db\u7de9\u5b58\u756b\u9762eglSwapBuffers()\u8fd4\u56deEGL_BAD_SURFACE<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,62],"tags":[2,50],"class_list":["post-10933","post","type-post","status-publish","format-standard","hentry","category-android","category-opengl","tag-android","tag-opengl","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/10933","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/comments?post=10933"}],"version-history":[{"count":2,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/10933\/revisions"}],"predecessor-version":[{"id":10936,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/10933\/revisions\/10936"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=10933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=10933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=10933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}