美文网首页
OpenGLES1-OpenGLES的基本概念与历史

OpenGLES1-OpenGLES的基本概念与历史

作者: AlanGe | 来源:发表于2020-06-29 01:43 被阅读0次

OpenGL 与OpenGL ES的基本概念与历史

一、什么是图形编程接⼝

2D图形编程接口:GDI , Skiz,OpenVG
3D图形编程接口:DirectX , OpenGL/OpenGL ES Embedded Systems

二、图形编程接口与图形硬件的关系

三、OpenGL的特点

1.跨操作系统平台运行
2.隐藏底层硬件信息
3.专⽤渲染接⼝
4.OpenGL 与 DirectX⽐比较

四、OpenGL 历史变更

1992年年7⽉月SGI发布OpenGL 1.0版本 (硅图)SGI
Window NT版本的OpenGL
1995年年OpenGL 1.1版本发布
2003年年7⽉月SGI与ARB发布OpenGL 1.5
2004年年8⽉月OpenGL 2.0版本发布
OpenGL Shading Language (GLSL) shader

五、OpenGL ES 的版本

OpenGL ES 1.X :针对固定功能流水管线硬件
OpenGL ES 2.X :针对可编程流水管线硬件
OpenGL ES 3.X :OpenGL ES 2.0的扩展

着⾊色器渲染过程

在渲染过程中,必须存储2种着⾊器,分别是顶点着⾊器、片元着⾊器。顶点着⾊器是第一个着⾊器、片元着色器是最后一个。顶点着⾊器中处理顶点、片元着⾊器处理像素点颜色。


屏幕渲染⽅方式

On-Screen Rendering(当前屏幕渲染)
指的是GPU的渲染操作是在当前用于显示的屏幕缓存区中进行的。
Off-Screen Rendering(离幕渲染)
指的是GPU在当前屏幕缓存区以外新开辟一个缓存区进行渲染操作

一般情况下,OpenGL ES会将应用提供到渲染服务的动画直接渲染显示(使⽤用基本的渲染的流程) 但对于一些复杂的图像动画的渲染,并不能够直接渲染叠加显示出来。而是需要根据Command Buffer 分通道进行渲染再组合。这个组合过程中,就有些渲染通道是不会直接显示出来的。标记此次渲染需要更多的渲染通道和合并步骤,而这些没有直接渲染显示在屏幕上的通道就是离屏渲染通道。

离屏渲染为什么会卡顿?

离屏渲染需要更多的渲染通道,⽽不同的渲染通道间切换需要消耗一定的时间,这个时间内GPU会闲置。当通道数量足够时,对性能也会较大的影响。

离屏渲染的体现

1、相⽐比于当前屏幕渲染,离屏渲染的代价相对⽽言较高。主要有以下2个原因:
1.1.创建新的缓存区
1.2.上下文切换

2、哪些情况会使用离屏渲染(off-Screen Render)?
2.1.drawRect
2.2.layer.shouldRasterize = true;
2.3.有mask或者阴影(layer.makesToBounds)
shouldRasterize(光栅化)、masks(遮罩)、shadows(阴影) edgeantialiasing(抗锯⻮齿)、group opacity(不不透明)
2.4.Text(UILabel,CATextLayer,CoreText)

思考题:

为么要⽤FrameBuffer 和 RenderBuffer?它们是什么关系?

A renderbuffer object is a 2D image buffer allocated by the application. The renderbuffer can be used to allocate and store color, depth, orstencil values and can be used as a color, depth, or stencil attachmentin a framebuffer object. A renderbuffer is similar to an off-screenwindow system provided drawable surface, such as a pbuffer. A renderbuffer, however, cannot be directly used as a GL texture.

一个renderbuffer 对象是通过应用分配的一个2D图像缓存区。renderbuffer 能够被用来分配和存储颜色、深度或者模板值。也能够在⼀个framebuffer被用作颜于屏幕窗口系统提供可绘制的表面。⽐如pBuffer。一个renderbuffer,然后它并不能直接的使用像一个GL纹理。

A framebuffer object (often referred to as an FBO) is a collection ofcolor, depth, and stencil buffer attachment points; state that describesproperties such as the size and format of the color, depth, and stencilbuffers attached to the FBO; and the names of the textureand renderbuffer objects attached to the FBO. Various 2D images can beattached to the color attachment point in the framebuffer object. Theseinclude a renderbuffer object that stores color values, a mip-level of a2D texture or a cube map face, or even a mip-level of a 2D slice in a 3Dtexture. Similarly, various 2D images contain- ing depth values can beattached to the depth attachment point of an FBO. These can includea renderbuffer, a mip-level of a 2D texture or a cubemap face thatstores depth values. The only 2D image that can be attached to thestencil attachment point of an FBO is a renderbuffer object that storesstencil values.

一个 frameBuffer 对象(通常被称为一个FBO)。是一个收集颜色、深度和模板缓存区的附着点。描述属性的状态,例如颜色、深度和模板缓存区的⼤小和格式,都关联到FBO(Frame Buffer Object)。并且纹理理的名字和renderBuffer 对象也都是关联于FBO。各种各样的2D图形能够被附着framebuffer对象的颜色附着点。它们包含了renderbuffer对象存储的颜色值、一个2D纹理理或⽴方体贴图。或者一个mip-level的二维切面在3D纹理理。同样,各种各样的2D图形包含了当时的深度值可以附加到一个FBO的深度附着点钟去。唯一的二维图像,能够附着在FBO的模板附着点,是一个renderbuffer对象存储模板值。


Demo: 01-使用OpenGLES加载图片

思考题:

渲染图⽚是倒置的,如果解决?


Demo: 02-使用着色器加载图片

本专题资料来自CC老师

相关文章

网友评论

      本文标题:OpenGLES1-OpenGLES的基本概念与历史

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