OpenGL ES EGL eglGetError

ChatGPT 3.5 国内中文镜像站免费使用啦

零基础 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 – 渲染区域,系统窗口或 frame buffer 句柄 ,可以理解为一个后端的渲染目标窗口

EGLConfig – 对 EGLSurface的 EGL 配置,可以理解为绘制目标 framebuffer 的配置属性

EGLContextOpenGL ES 图形上下文


二. EGL 绘制流程简介

  1. 获取 EGL Display 对象:eglGetDisplay
  2. 初始化与 EGLDisplay 之间的连接:eglInitialize
  3. 获取 EGLConfig 对象:eglChooseConfig / eglGetConfigs
  4. 创建 EGLContext 实例:eglCreateContext
  5. 创建 EGLSurface 实例:eglCreateWindowSurface
  6. 连接 EGLContext 和 EGLSurface:eglMakeCurrent
  7. 使用 OpenGL ES API 绘制图形:gl_*
  8. 切换 front buffer 和 back buffer 显示:eglSwapBuffer
  9. 断开并释放与 EGLSurface 关联的 EGLContext 对象:eglRelease
  10. 删除 EGLSurface 对象
  11. 删除 EGLContext 对象
  12. 终止与 EGLDisplay 之间的连接
图片[1]-OpenGL ES EGL  eglGetError-猿说编程

三.eglGetError 函数简介  

EGL 中大部分函数成功时都是返回 EGL_TRUE,失败返回 EGL_FALSE。至于其他错误原因,需要调用 eglGetError 函数获取:

// 描述:返回 EGL 错误号,如果返回 EGL_SUCCESS 说明没有错误
EGLint eglGetError();

四.eglGetError 函数使用

调用 eglGetError 如果返回  EGL_SUCCESS 说明没有错误,返回其他值表示有错误产生;例如 :eglInitialize 会初始化 EGL 内部数据,分配显存等初始化失败

/******************************************************************************************/
//@Author:猿说编程
//@Blog(个人博客地址): www.codersrc.com
//@File:OpenGL ES EGL eglGetError
//@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();
}

五.猜你喜欢

  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

ChatGPT 3.5 国内中文镜像站免费使用啦
© 版权声明
THE END
喜欢就支持一下吧
点赞1 分享
评论 共1条

请登录后发表评论

    暂无评论内容