欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

OpenGL ES EGL eglCreateContext

目錄

創(chuàng)新互聯(lián)建站從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目做網(wǎng)站、成都網(wǎng)站制作網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元山海關(guān)做網(wǎng)站,已為上家服務(wù),為山海關(guān)各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792

  • 一. EGL 前言
  • 二. EGL 繪制流程簡介
  • 三.eglCreateContext 函數(shù)簡介
    • 1.關(guān)于屬性列表 attribList
    • 2.關(guān)于返回值
  • 四.eglCreateContext 函數(shù)使用
  • 五.猜你喜歡

零基礎(chǔ) OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES 基礎(chǔ)

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

零基礎(chǔ) OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES 轉(zhuǎn)場

零基礎(chǔ) OpenGL ES 學習路線推薦 : OpenGL ES 學習目錄 >> OpenGL ES 函數(shù)

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

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

一. EGL 前言

EGLNativeDisplayType – 系統(tǒng)顯示類型,標識你所開發(fā)設(shè)備的物理屏幕,DX/OPenGL ES/Metal/Vulkan….

EGLNativeWindowType – 系統(tǒng)窗口,渲染顯示的窗口句柄

EGLDisplay – 關(guān)聯(lián) EGLNativeDisplayType 系統(tǒng)物理屏幕的通用數(shù)據(jù)類型,是平臺上 WGL / GLX / AGL 的等價物

EGLSurface – 渲染區(qū)域,系統(tǒng)窗口或 frame buffer 句柄 ,可以理解為一個后端的渲染目標窗口

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

EGLContext – OpenGL ES 圖形上下文

二. EGL 繪制流程簡介

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

三.eglCreateContext 函數(shù)簡介

EGLContext 上下文包含了操作所需的所有狀態(tài)信息,OpenGL ES 必須有一個可用的上下文 EGLContext 才能進行繪圖。如果沒有 EGLContext ,OpenGL 指令就沒有執(zhí)行的環(huán)境。函數(shù)聲明如下:

/*描述:創(chuàng)建 OpenGL ES 上下文 EGLContext
 *參數(shù):
 *    display:指定顯示的連接
 *    config:配置 EGLConfig
 *    share_context:允許其它 EGLContext 共享數(shù)據(jù),使用 EGL_NO_CONTEXT 表示不共享
 *    attribList:指定操作的屬性列表,只能接受一個屬性 EGL_CONTEXT_CLIENT_VERSION(設(shè)置 OpenGL ES 版本)
 *
 *返回值:成功時返回新創(chuàng)建的 EGLContext,失敗時返回 EGL_NO_CONTEXT
 */

EGLAPI EGLContext EGLAPIENTRY eglCreateContext(
		EGLDisplay display,
                EGLConfig config,
                EGLContext share_context,
                const EGLint *attribList);

1.關(guān)于屬性列表 attribList

attribList 屬性目前只有 EGL_CONTEXT_CLIENT_VERSION,類型是整數(shù)值,用于指定 OpenGL ES 版本,使用方法如下:

/*
EGL_CONTEXT_CLIENT_VERSION, 3, //使用OpenGL ES 3.0 版本 API
EGL_CONTEXT_CLIENT_VERSION, 2, //使用OpenGL ES 2.0版本 API
EGL_CONTEXT_CLIENT_VERSION, 1, //使用OpenGL ES 1.0版本 API
*/
const ELGint attribList[] = {
    EGL_CONTEXT_CLIENT_VERSION, 3, //使用OpenGL ES 3.0 版本 API
    EGL_NONE
};

如果當前設(shè)備只支持 OpenGL ES 2.0,那么該值就不能設(shè)置為 3 ,否則上下文創(chuàng)建失敗;

值得注意的是:如果使用 OpenGL ES 2.0,那么就不能使用 OpenGL ES 3.0 相關(guān) API, VAO / PBO 等都屬于 OpenGL ES 3.0,詳細介紹請參考《OpenGL ES 2.0 和 3.0 區(qū)別》

2.關(guān)于返回值

成功時返回新創(chuàng)建的 EGLContext,失敗時返回 EGL_NO_CONTEXT,也有可能返回其他錯誤,可以通過 eglGetError 獲取錯誤號,示例代碼:

EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribList);

if (context == EGL_NO_CONTEXT) {
    EGLError error = eglGetError();
    if (error == EGL_BAD_CONFIG) {
        // Handle error and recover
    }
}

通過 eglGetError 獲取錯誤類型可能是以下值:

EGL_BAD_MATCH
EGL_BAD_DISPLAY
EGL_NOT_INITIALIZED
EGL_BAD_CONFIG
EGL_BAD_CONTEXT
EGL_BAD_ATTRIBUTE
EGL_BAD_ALLOC

四.eglCreateContext 函數(shù)使用

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

EGLint attrs[3] = { EGL_DEPTH_SIZE, 16, EGL_NONE };
EGLint num_configs;
EGLConfigs *configs_list;
// Get the display device
if ((eglDisplay = eglGetDisplay(EGL_NO_DISPLAY)) == EGL_NO_DISPLAY) {
	return eglGetError();
}
// Initialize the display
if (eglInitialize(eglDisplay, NULL, NULL) == EGL_FALSE) {
	return eglGetError();
}
// Obtain the total number of configurations that match
if (eglChooseConfig(eglDisplay, attrs, NULL, 0, &num_configs) == EGL_FALSE) {
	return eglGetError();
}
configs_list = malloc(num_configs * sizeof(EGLConfig));
if (configs_list == (EGLConfig *)0){
	return eglGetError();
}
// Obtain the first configuration with a depth buffer of 16 bits
if (!eglChooseConfig(eglDisplay, attrs, &configs_list, num_configs, &num_configs)) {
	return eglGetError();
}

const EGLint attribs[] =
{
    EGL_CONTEXT_CLIENT_VERSION, 2,  //使用OpenGL ES 2.0 版本 API
    EGL_NONE
};
EGLContext context = eglCreateContext(display, configs_list, EGL_NO_CONTEXT, attribs);

if (context == EGL_NO_CONTEXT)
{
    if (EGL_BAD_CONFIG == eglGetError())
    {
        ...
    }
}

五.猜你喜歡

  1. OpenGL ES 簡介
  2. OpenGL ES 版本介紹
  3. OpenGL ES 2.0 和 3.0 區(qū)別
  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

本文由博客 - 猿說編程 猿說編程 發(fā)布!

當前名稱:OpenGL ES EGL eglCreateContext
瀏覽路徑:http://chinadenli.net/article14/dsoiede.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)營銷型網(wǎng)站建設(shè)、網(wǎng)站導航、用戶體驗、動態(tài)網(wǎng)站做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)