美文网首页
学习OpenGL ES

学习OpenGL ES

作者: swagon | 来源:发表于2017-06-20 10:07 被阅读53次

    概念性东西

    1. OpenGL(英语:Open Graphics Library,译名:开放图形库或者“开放式图形库”)是用于渲染2D3D矢量图形的跨语言跨平台应用程序编程接口(API)。OpenGL常用于CAD虚拟实境、科学可视化程序和电子游戏开发
      OpenGL的高效实现(利用了图形加速硬件)存在于Windows,很多UNIX平台和Mac OS。这些实现一般由显示设备厂商提供,而且非常依赖于该厂商提供的硬件。开放源代码Mesa是一个纯基于软件的图形API,它的代码兼容于OpenGL。但是,由于许可证的原因,它只声称是一个“非常相似”的API。
      OpenGL规范由1992年成立的OpenGL架构评审委员会(ARB)维护。ARB由一些对创建一个统一的、普遍可用的API特别感兴趣的公司组成。
      整型常数 常数GL_TEXTURE_2D对应的整数为3553
      OpenGL纯粹专注于渲染,而不提供输入、音频以及窗口相关的API。
      架构评审委员(Architecture Review Board,ARB)例如:GL_ARB_multitexture
      如果多个供应商同意使用相同的API来实现相同的功能,那么就用EXT标志符

    OpengGL原来是在应用程序和图形设备接口之间运作,

    Paste_Image.png
    1. OpenGL ES(OpenGL for Embedded Systems)是 OpenGL 三维图形API的子集,针对手机、PDA和游戏主机等嵌入式设备而设计。该API由Khronos集团定义推广,Khronos是一个图形软硬件行业协会,该协会主要关注图形和多媒体方面的开放标准。
      OpenGL ES是从OpenGL裁剪定制而来的,去除了glBegin/glEnd,四边形(GL_QUADS)、多边形(GL_POLYGONS)等复杂图元等许多非绝对必要的特性。经过多年发展,现在主要有两个版本,OpenGL ES 1.x针对固定管线硬件的,OpenGL ES 2.x针对可编程管线硬件。OpenGL ES 1.0是以OpenGL 1.3规范为基础的,OpenGL ES 1.1是以OpenGL 1.5规范为基础的,它们分别又支持common和common lite两种profile。lite profile只支持定点实数,而common profile既支持定点数又支持浮点数。OpenGL ES 2.0则是参照OpenGL 2.0规范定义的,common profile发布于2005-8,引入了对可编程管线的支持。OpenGL ES 3.0于2012年公布,加入了大量新特性。
      OpenGL ES还有一个safety-critical profile。 (简单说就是 为嵌入式设备设计的精简版的OpenGL)
    1. Renderbuffer Objects:是包含图片的OpenGL 对象,一般配合Framebuffer Objects一起使用。They are optimized for use as render targets, while Textures may not be, and are the logical choice when you do not need to sample (i.e. in a post-pass shader) from the produced image. If you need to resample (such as when reading depth back in a second shader pass), use Textures instead. Renderbuffer objects also natively accommodate Multisampling

    2. glViewport

    3. 渲染管线(可编程和固定):完成图形功能


      Paste_Image.png

      几何部分一般处理顶点,光栅部分处理的是像素
      primitive(原始的) 集
      rasterization(光栅化)
      fragment(片段)
      framebuffer


      Paste_Image.png
      引入可编程
      shader(着色器)
      Paste_Image.png

      演化(体现在硬件变化上)


      Paste_Image.png
    4. 模式

      1. 立即模式:在立即模式中,我们不需要像保持模式一样去提供一个模型或是场景,而是向图形处理器发送命令,图形处理器就会根据它的状态及发送的命令产生立即的效果。查询图形学书籍得知,大多数保持模式中的API或场景图在其内部使用一个立即模式的API执行实际的渲染任务。
      2. 保持模式:提供物体和场景,然后图形包就会在屏幕上创建这个图像,我们需要做的就是提供命令去改变照相机或场景中其他物体的位置和观察方向,对于我们开发者而言,我们创建的能够对物体及场景的描述称为场景图,场景图是个有向无环图的数据结构
    5. 顶点着色器

    6. glEnableVertexAttribArray 允许顶点着色器读取GPU(服务器端)数据
      glEnableVertexAttribArray enables the generic vertex attribute array specified by index. glDisableVertexAttribArray disables the generic vertex attribute array specified by index. By default, all client-side capabilities are disabled, including all generic vertex attribute arrays. If enabled, the values in the generic vertex attribute array will be accessed and used for rendering when calls are made to vertex array commands such as glDrawArrays or glDrawElements.

    7. glShaderSource 字符串数组有多少条字符串的参数是count The number of strings in the array is specified by count, 只是拷贝到指定的着色器中

    8. glViewport(30, 30, frame.size.width * self.layer.contentsScale, frame.size.height * self.layer.contentsScale); 所以会往上往右边
      坐标要做一次转换,glViewport视图可见区域

      Paste_Image.png

    相关文章

      网友评论

          本文标题:学习OpenGL ES

          本文链接:https://www.haomeiwen.com/subject/wujwyttx.html