1. EGL

OpenGL ES命令须要一个rendering context和一个drawing surface。

Rendering Context: 保存当前的OpenGL ES状态。

Drawing Surface: 是原语(primitive)绘图的Surface。

它指定了渲染的buffer类型,如:color buffer。depth buffer和stencil buffer;同一时候它也指定了每一个须要的buffer的位深度(bit depth)。

EGL是OpenGL ES API与Native Window System之间的接口。

在OpenGL ES运行render之前,须要EGL做下面工作:

• 查询设备上可得到的显示设备,并初始化它们。

•  创建一个Rendering Surface(渲染表面)。

EGL能够创建屏幕上的表面(on-srceen surface)或离线屏幕表面off-screen surface,屏幕上的表面连接到本地窗体系统;而离线屏幕表面不显示,但能够用于渲染表面(rendering surface)的像素缓冲区。

• 创建一个rendering context(渲染环境)。

在真正開始绘图之前,须要把渲染环境连接到渲染表面。

1.1 EGL 数据类型

Data Type

C-Language Type

EGL Type

32-bit integer int EGLint
32-bit unsigned integer unsigned int EGLBoolean, EGLenum
32-bit pointer void * EGLConfig, EGLContext,
EGLDisplay, EGLSurface,
EGLClientBuffer

2.  OpengGL ES命令后缀和參数数据类型

Data Type Suffix Data Type C-Language Type GL Type
b 8-bit signed integer signed char GLbyte
ub 8-bit unsigned integer unsigned char GLubyte,
GLboolean
s 16-bit signed integer short GLshort
us 16-bit unsigned integer unsigned short GLushort
i 32-bit signed integer int GLint
ui 32-bit unsigned integer unsigned int GLuint,
GLbitfield,
GLenum
x 16.16 fixed point int GLfixed
f 32-bit floating point float GLfloat,
GLclampf

GLvoid是OpenGL ES命令可接受的指针。

2.1 OpenGL ES基本错误码

错误码可通过GLenum glGetError(void)函数获取。假设当前错误码的值不为GL_NO_ERROR。则新产生的错误码不能被保存。

Error Code Description
GL_NO_ERROR No error has been generated since the last call to glGetError.
GL_INVALID_ENUM A GLenum argument is out of range. The command that generated the error is ignored.
GL_INVALID_VALUE A numeric argument is out of range. The command that generated the error is ignored.
GL_INVALID_OPERATION The specific command cannot be performed in the current OpenGL ES state. The command that generated the error is ignored.
GL_OUT_OF_MEMORY There is insufficient memory to execute this command. The state of the OpenGL ES pipeline is considered to be undefined if this error is encountered except for the current error code.

 3. Flush和Finish

OpenGL ES2.0 API继承了OpenGL的C-S(client-server)模式。应用程序(client)公布命令,则Server负责运行处理。且不是应用程序每发一个命令都被及时地发送给Server。在设备中CPU负责运行游戏的逻辑。并向GPU(硬件显卡或是软件模拟的显卡)发送绘图指令。在这样的架构下,CPU和GPU分别充当client与server端的角色。

glFlush命令把当前OpenGL ES环境中的命令进行刷新,然后发送给Server。glFlush仅仅是把命令发送给Server,但并不等待运行完毕。

假设须要等到Server运行完毕时才返回,则须要调用glFinish,但它严重影响性能。

eglSwapBuffers中调用了glFlush。

4. 主要的状态管理

管道的每一个阶段都有自己的一些状态,且每一个状态有相应的值,这些状态值能够通过下面两个函数进行改动:

void glEnable(GLenum cap)
void glDisable(GLenum cap)

在初始状态时,除GL_DITHER(初始值为GL_TRUE)之外,其他每一个状态的初始值都为GL_FALSE。这些状态值被保存在EGLcontext中。

其状态值可通过glIsEnabled(GLboolean glIsEnabled(GLenum cap))来进行查询。

最新文章

  1. C语言中struct位域的定义和使用
  2. mysql基本命令整理
  3. directly receive json data from javascript in mvc
  4. HDU 1102 最小生成树裸题,kruskal,prim
  5. Mediator Pattern --中介者模式原理及实现(C++)
  6. 汇编学习笔记(11)int指令和端口
  7. 圣何塞与 Microsoft 宣布该市为超过 5,000 名市府公务员选择 Office 365、Windows Azure 和 StorSimple
  8. Windows Phone 8初学者开发—第16部分:使用应用程序栏
  9. Input文本框属性及js
  10. 关于react的分页
  11. 第一次作业_ChenHong1998
  12. Oracle 如何开启归档模式
  13. HDU - 1542 扫描线入门+线段树离散化
  14. Vue 父组件调用子组件函数的方法
  15. Android Studio模拟器磁盘空间不足(Not enough disk space to run AVD)
  16. Nginx-rtmp 直播媒体实时流实现
  17. 《Java程序设计》第十一章 JDBC与MySQL数据库
  18. 使用delphi 10.2 开发linux 上的Daemon
  19. JAVAWEB开发之HttpServletResponse和HttpServletRequest详解(上)(各种乱码、验证码、重定向和转发)
  20. MsChart,饼状图

热门文章

  1. 自学Python十二 战斗吧Scrapy!
  2. node.js安装步骤
  3. [转]python模块全面
  4. JS高级——Function原型链
  5. 神经网络图灵机(Neural Turing Machines, NTM)
  6. 我的 Windows 10 的基本配置
  7. 转录组入门(3):了解fastq测序数据
  8. Java程序员怎么不断进阶 必须要掌握哪些技能
  9. pymysql连接数据库
  10. matlab数值数据的表示方法,输出数据以及相关函数