Nine OpenGL Note: Preliminary OpenGL ES

OpenGL ES

OpenGL ES Lee Use of the applications allowing the underlying graphics processor zoomed strong function. GPU on iOS can Perform complex 2D and 3D drawing and, ultimately, the complex image is calculated for each pixel discolored.


2421768-e37e98d3f2e593e0.png
Figure -1.png

OpenGL ES 3.0

  • Graphics pipeline


    2421768-e0b98abb338de75e.png
    Figure -2.png
  • Graphics pipeline


    2421768-e94190572a71c44d.png
    Figure -3.png

Vertex shader

The input vertex is discolored START:

  • The discolored program - described as an operation performed on the vertices of the source code of the program discolored / files can YES
  • The START input is discolored vertex (attribute) - Using the vertex array to provide data for each vertex
  • ⼀ system variable (uniform) - vertex / discolored allows the still picture element data unchanged Use
  • Sampler - Using the representative vertex texture allows the discolored special type of system variables ⼀

Vertex shader operations:

  • Matrix changing positions
  • Light formula to calculate per-vertex of colors in ⽣
  • ⽣ into / texture coordinates conversion

It can use it to calculate CUSTOM YES, the implementation of new transform, lighting, or traditional fixed function allowed based vertex effect.
To gl_Position final two carrier assignments and gl_PointSize

Element Assembly

After the vertex is discolored, record the next stage is the primitive assembly!
Primitives (Primitive): point, line, triangle, etc. ⻆ three
elements assembled: calculated vertex data to ⼀ all primitives. At this stage we will Perform crop, perspective divide and
Viewport Transform operation.

  • Type Cable primitive vertices and determines a separate element to be rendered FIG. For each individual vertices and corresponding primitive, primitive assembly stage Perform operations comprising: an output value of the vertex YES discolored cut filter, perspective divide, depending on the START-connector backward raster conversion stage.

Rasterization

  • Rasterizing: input primitive mathematical description into a pixel fragment (the fragment) corresponding to the screen position. Called rasterization.
    At this stage the corresponding drawing primitives (points / lines / three ⻆ triangle). Primitive is to rasterize the process of converting ⼀ group ⼆ release segment of dimension. These release segment ⽽ discolored by processing conversion element with still pictures. These ⼆ dimensional back the segment that is on the screen to draw a pixel.
    2421768-b17ef7314649b1b0.png
    Figure -4.png

Business cards yuan is significantly discolored

  • 最后,针对光栅化过程产生的每个片元,执行片元着色器(fragmen shader),从而决定这个片元的最终颜色和位置。
  • 如果有必要,还需要对每个片元执行一些额外的操作,例如判断片元对应的对象是否可见,或者将片元的颜色与当前屏幕位置言色进行融合。

⽚元着⾊器 输入:

  • 着⾊器程序—描述⽚段上执⾏操作的顶点着⾊器程序源代码/可执⾏⽂件
  • 输⼊变量— 光栅化单元⽤插值为每个⽚段⽣成的顶点着⾊器输出
  • 统⼀变量(uniform)—顶点/⽚元着⾊器使⽤的不变数据
  • 采样器—代表⽚元着⾊器使⽤纹理的特殊统⼀变量类型

它可以⽤于图⽚/视频/图形中每个像素的颜⾊填充(⽐如给视频添加滤镜,实际 上就是将视频中每个图⽚的像素点颜⾊填充进⾏修改。)
最终 gl_FragColor 载体赋值

逐⽚段操作

2421768-337080b6e3c2bdc2.png
图-5.png
  • 像素归属测试:确定帧缓存区中位置(Xw,Yw)的像素⽬前是不是归属于OpenGL ES所有。例:如果⼀个显示OpenGL ES帧缓存区View被另外⼀个View 所遮蔽。则窗⼝系统可以确定被遮蔽的像素不属于OpenGL ES 上下⽂。从⽽不全显示这些像素。⽽像素归属测试是OpenGL ES 的⼀部分,它不由开发者开⼈为控制,⽽是由OpenGL ES 内部进⾏。
  • 裁剪测试:裁剪测试确定(Xw,Yw)是否位于作为OpenGL ES状态的⼀部分裁剪矩形范围内。如果该⽚段位于裁剪区域之外,则被抛弃。
  • 深度测试: 输⼊⽚段的深度值进步⽐较,确定⽚段是否拒绝测试。
  • 混合:混合将新⽣成的⽚段颜⾊与保存在帧缓存的位置的颜⾊值组合起来。
  • 抖动:抖动可⽤于最⼩化因为使⽤有限精度在帧缓存区中保存颜⾊值⽽产⽣的伪像。

EGL (Embedded Graphics Library )

  • OpenGL ES 命令需要渲染上下⽂和绘制表⾯才能完成图形图像的绘制
  • 渲染上下⽂:存储相关OpenGL ES 状态
  • 绘制表⾯:是⽤于绘制图元的表⾯,它指定渲染所需要的缓存区类型,例如颜⾊缓存区,深度缓冲区和模板缓存区。
  • OpenGL ES API does not provide rendering how to create files up and down up and down the file or how to connect to the original ⽣ window-connector system. Connector EGL is between Khronos rendering API (such as OpenGL ES) and the original system-connector ⽣ window. Only ⼀ ⽀ support OpenGL ES support is not ⽀ EGL platform is iOS. Apple offers Your Own iOS EGL API implementation, called EAGL.
  • Because each window-connector system has a different definition, the EGL provides substantially opaque type -EGLDisplay, this type encapsulates all the system dependencies, and Use in ⽣ original window system-connector-connector.

Since OpenGL ES C-based API, so that it comes in handy portable and held by ⽀ Wide-pan. As CAPI, it Objective-C Cocoa Touch ⽆ seamless integration of the applications. OpenGL ES-connector specification does not define the window layer; contrary, hosted operating system must provide a function to create ⼀ accepts command files and OpenGL ES rendering ⼀ vertical frame buffers, which is writing the results of any drawing commands. Using OpenGL ES Use in need iOS iOS class table ⾯ drawing and rendering, and use the platform attention immediately API to render its contents.

OpenGL ES Perform animated display of the applications process

2421768-33a77296590c8510.jpg
Figure -6.jpg

Guess you like

Origin blog.csdn.net/weixin_34221775/article/details/90829760