OpenGL ES EGL eglDestroySurface

目錄

零基礎 OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES 基礎

零基礎 OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES 特效

零基礎 OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES 轉場

零基礎 OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES 函數

零基礎 OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES GPUImage 使用

零基礎 OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES GLSL 編程

一. EGL 前言

EGLNativeDisplayType – 系統顯示類型,標識你所開發設備的物理屏幕,DX/OPenGL ES/Metal/Vulkan….

EGLNativeWindowType – 系統窗口,渲染顯示的窗口句柄

EGLDisplay – 關聯 EGLNativeDisplayType 系統物理屏幕的通用數據類型,是平臺上 WGL / GLX / AGL 的等價物

EGLSurface – 渲染區域,相當於 OpenGL ES 繪圖的畫布 (一塊內存空間),用戶想繪製的信息首先都要先繪製到 EGLSurface 上,然後通過 EGLDisplay 顯示

EGLConfig – 對 EGLSurface 的 EGL 配置,可以理解爲繪製目標 framebuffer 的配置屬性

EGLContextOpenGL ES 圖形上下文

二. EGL 繪製流程簡介

  1. 獲取 EGL Display 對象:eglGetDisplay
  2. 初始化與 EGLDisplay 之間的連接:eglInitialize
  3. 獲取 EGLConfig 對象:eglChooseConfig / eglGetConfigs
  4. 創建 EGLContext 實例:eglCreateContext
  5. 創建 EGLSurface 實例:eglCreateWindowSurface / eglCreatePbufferSurface
  6. 連接 EGLContext 和 EGLSurface 上下文 eglMakeCurrent
  7. 使用 OpenGL ES API 繪製圖形:gl_*
  8. 切換 front buffer 和 back buffer 顯示:eglSwapBuffer
  9. 斷開並釋放與 EGLSurface 關聯的 EGLContext 對象:eglRelease
  10. 刪除 EGLSurface 對象 eglDestroySurface
  11. 刪除 EGLContext 對象 eglDestroyContext
  12. 終止與 EGLDisplay 之間的連接

三.eglDestroySurface 函數簡介

eglDestroySurface 用於銷燬渲染 EGLSurface(內存畫布),如果有其它線程使用這個 EGLSurface 時就要等到不使用時再銷燬,否則立即銷燬;

/*描述:用於銷燬渲染 EGLSurface
 *參數:
 *    display:指定顯示的連接
 *    context:EGLContext 上下文
 *
 *返回值:成功是返回 EGL_TRUE,失敗時返回 EGL_FALSE
 */

EGLAPI EGLBoolean eglDestroySurface(EGLDisplay display,
                                    EGLSurface surface);

可能返回錯誤:

EGL_FALSE is returned if destruction of the context fails, EGL_TRUE otherwise.

EGL_BAD_DISPLAY is generated if display is not an EGL display connection.

EGL_NOT_INITIALIZED is generated if display has not been initialized.

EGL_BAD_SURFACE is generated if surface is not an EGL surface.

類似 eglDestroyContext 摧毀上下文一樣 ,eglDestroySurface** 摧毀EGLSurface** 之前一定要記得通過 eglMakeCurrent 綁定當前上下文;

四.eglDestroySurface 使用

/******************************************************************************************/
//@Author:猿說編程
//@Blog(個人博客地址): www.codersrc.com
//@File:OpenGL ES EGL eglDestroySurface
//@Time:2022/08/04 07:30
//@Motto:不積跬步無以至千里,不積小流無以成江海,程序人生的精彩需要堅持不懈地積累!
/******************************************************************************************/

void egl_demo()
{
  EGLDisplay display = eglGetDisplay ( EGL_DEFAULT_DISPLAY );
    eglInitialize ( display , 0, 0);

  EGLConfig  config;
    eglChooseConfig ( display , attribs , & config , 1, & numConfigs );

  EGLSurface  surface = eglCreateWindowSurface ( display , config , ANativeWindow  , NULL );
  EGLContext  context = eglCreateContext ( display , config , NULL , NULL );
  eglMakeCurrent ( display , surface , surface , context )

  while(true){
    //opengl繪製
    glxx();

    eglSwapBuffers ( display , surface );
  }

  eglDestroyContext ( display , context );
  eglDestroySurface ( display , surface );
  eglTerminate ( display );
}

四.猜你喜歡

  1. OpenGL ES 簡介
  2. OpenGL ES 版本介紹
  3. OpenGL ES 2.0 和 3.0 區別
  4. OpenGL ES 名詞解釋(一)
  5. OpenGL ES 名詞解釋(二)
  6. OpenGL ES GLSL 着色器使用過程
  7. OpenGL ES EGL 簡介
  8. OpenGL ES EGL 名詞解釋
  9. OpenGL ES EGL eglGetDisplay
  10. OpenGL ES EGL eglInitialize
  11. OpenGL ES EGL eglGetConfigs
  12. OpenGL ES EGL eglChooseConfig
  13. OpenGL ES EGL eglGetError
  14. OpenGL ES EGL eglCreateContext
  15. OpenGL ES EGL eglCreateWindowSurface
  16. OpenGL ES EGL eglCreatePbufferSurface
  17. OpenGL ES EGL eglMakeCurrent
  18. OpenGL ES EGL eglSwapBuffer
  19. OpenGL ES EGL eglDestroySurface
  20. OpenGL ES EGL eglDestroyContext

本文由博客 - 猿說編程 猿說編程 發佈!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章