目錄
- 一. EGL 前言
- 二. EGL 繪制流程簡介
- 三.eglQueryContext 函式簡介
- 四.eglQueryContext 使用
- 四.猜你喜歡
零基礎 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 的配置屬性
EGLContext – OpenGL ES 圖形背景關系
二. EGL 繪制流程簡介
- 獲取 EGL Display 物件:eglGetDisplay
- 初始化與 EGLDisplay 之間的連接:eglInitialize
- 獲取 EGLConfig 物件:eglChooseConfig / eglGetConfigs
- 創建 EGLContext 實體:eglCreateContext
- 創建 EGLSurface 實體:eglCreateWindowSurface / eglCreatePbufferSurface
- 連接 EGLContext 和 EGLSurface 背景關系 eglMakeCurrent
- 使用 OpenGL ES API 繪制圖形:gl_*
- 切換 front buffer 和 back buffer 顯示:eglSwapBuffer
- 斷開并釋放與 EGLSurface 關聯的 EGLContext 物件:eglRelease
- 洗掉 EGLSurface 物件 eglDestroySurface
- 洗掉 EGLContext 物件 eglDestroyContext
- 終止與 EGLDisplay 之間的連接

三.eglQueryContext 函式簡介
eglQueryContext 用于查詢渲染背景關系相關資訊,函式宣告如下:
/*描述:用于查詢渲染背景關系相關資訊
*引數:
* display:指定顯示的連接
* context:EGLContext 背景關系
* attribute:查詢渲染背景關系相關資訊 EGL_CONFIG_ID、EGL_CONTEXT_CLIENT_TYPE、EGL_CONTEXT_CLIENT_VERSION
* value:(輸出引數)回傳查詢結果
*回傳值:成功是回傳 EGL_TRUE,失敗時回傳 EGL_FALSE
*/
EGLBoolean eglQueryContext( EGLDisplay display,
EGLContext context,
EGLint attribute,
EGLint * value);
attribute 可以為下面值:
EGL_CONFIG_ID
Returns the ID of the EGL frame buffer configuration with respect to which the context was created.
EGL_CONTEXT_CLIENT_TYPE
Returns the type of client API which the context supports (one of EGL_OPENGL_API, EGL_OPENGL_ES_API, or EGL_OPENVG_API).
EGL_CONTEXT_CLIENT_VERSION
Returns the version of the client API which the context supports, as specified at context creation time. The resulting value is only meaningful for an OpenGL ES context.
EGL_RENDER_BUFFER
Returns the buffer which client API rendering via the context will use. The value returned depends on properties of both the context, and the surface to which the context is bound:
If the context is bound to a pixmap surface, then EGL_SINGLE_BUFFER will be returned.
If the context is bound to a pbuffer surface, then EGL_BACK_BUFFER will be returned.
If the context is bound to a window surface, then either EGL_BACK_BUFFER or EGL_SINGLE_BUFFER may be returned. The value returned depends on both the buffer requested by the setting of the EGL_RENDER_BUFFER property of the surface (which may be queried by calling eglQuerySurface), and on the client API (not all client APIs support single-buffer rendering to window surfaces).
If the context is not bound to a surface, such as an OpenGL ES context bound to a framebuffer object, then EGL_NONE will be returned.
Notes
Attributes EGL_CONTEXT_CLIENT_TYPE and EGL_RENDER_BUFFER are supported only if the EGL version is 1.2 or greater.
Attribute EGL_CONTEXT_CLIENT_VERSION is supported only if the EGL version is 1.3 or greater.
可能回傳錯誤:
EGL_FALSE is returned on failure, EGL_TRUE otherwise. value is not modified when EGL_FALSE is returned.
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_CONTEXT is generated if context is not an EGL rendering context.
EGL_BAD_ATTRIBUTE is generated if attribute is not a valid context attribute.
類似 eglDestroyContext 摧毀背景關系一樣 ,eglQueryContext** 使用**之前一定要記得通過 eglMakeCurrent 系結當前背景關系;
四.eglQueryContext 使用
/******************************************************************************************/
//@Author:猿說編程
//@Blog(個人博客地址): www.codersrc.com
//@File:OpenGL ES EGL eglQueryContext
//@Time:2022/08/04 07:30
//@Motto:不積跬步無以至千里,不積小流無以成江海,程式人生的精彩需要堅持不懈地積累!
/******************************************************************************************/
//創建背景關系
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
EGLContext context = eglCreateContext ( display , config , EGL_NO_CONTEXT, contextAttribs );
//系結背景關系
eglMakeCurrent ( display , surface , surface , context )
//查詢 OpenGL 版本
int clientVersion;
eglQueryContext(m_eglDisplay, m_eglContext, EGL_CONTEXT_CLIENT_VERSION, &clientVersion);
//clientVersion = 3
printf("EGLContext created, client version %d\n", clientVersion);
//摧毀背景關系
eglDestroyContext ( display , context );
eglDestroySurface ( display , surface );
eglTerminate ( display );
四.猜你喜歡
- OpenGL ES 簡介
- OpenGL ES 版本介紹
- OpenGL ES 2.0 和 3.0 區別
- OpenGL ES 名詞解釋(一)
- OpenGL ES 名詞解釋(二)
- OpenGL ES GLSL 著色器使用程序
- OpenGL ES EGL 簡介
- OpenGL ES EGL 名詞解釋
- OpenGL ES EGL eglGetDisplay
- OpenGL ES EGL eglInitialize
- OpenGL ES EGL eglGetConfigs
- OpenGL ES EGL eglChooseConfig
- OpenGL ES EGL eglGetError
- OpenGL ES EGL eglCreateContext
- OpenGL ES EGL eglCreateWindowSurface
- OpenGL ES EGL eglCreatePbufferSurface
- OpenGL ES EGL eglMakeCurrent
- OpenGL ES EGL eglSwapBuffer
- OpenGL ES EGL eglDestroySurface
- OpenGL ES EGL eglDestroyContext
- OpenGL ES EGL eglQueryContext
本文由博客 - 猿說編程 猿說編程 發布!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/531874.html
標籤:C
