OpenGL ES API to resolve common in GLKit

1 GLKit Brief

GLKit Destination time frame design goal is to simplify based on OpenGL / OpenGL ES Use should be used to develop.

GLKitIt appeared to speed up OpenGL ESor OpenGLto apply it with program development. Using mathematical library, background texture is loaded, the target mark is the effect of pre-created, as well as the standard view and the view controller to achieve rendering loop.

Using Apple abandoned the OpenGL ES, but iOS developers can continue to use.

2 GLKit function

GLKit provide functionality in four key areas:

  • Texture loaded usingGLKTextureLoader
  • Math library provides commonly used vector, quaternion and matrix operations
  • Common effect of providing a standard implementation of the shader effects, including effects of the three key class implements a subset of OpenGL ES 1.1 shadow and illumination model, which extends the base comprises a reflective effect in the map, and such effect is provided skybox implementation.
  • Views and view controllers provide standard OpenGL ES view and a corresponding view controller implementation ( GLKViewControllerand GLKView)

3 GLKit common api

3.1 GLKTextureLoader

Function : simplified load textures from a variety of resource file

initialization

    - initWithSharegroup: 初始化⼀个新的纹理加载到对象中
    - initWithShareContext: 初始化⼀个新的纹理加载对象

Load texture from a file

    + textureWithContentsOfFile:options:errer: 从⽂件加载2D纹理图像并从数据中创建新的纹理
    - textureWithContentsOfFile:options:queue:completionHandler: 从⽂件中异步加载2D纹理图像,并根据数据创建新纹理

Load textures from URL

    - textureWithContentsOfURL:options:error: 从URL加载2D纹理图像并从数据创建新纹理
    - textureWithContentsOfURL:options:queue:completionHandler: 从URL异步加载2D纹理图像,并根据数据创建新纹理

Load textures from memory

    + textureWithContentsOfData:options:errer: 从内存空间加载2D纹理图像,并根据数据创建新纹理
    - textureWithContentsOfData:options:queue:completionHandler:从内存空间异步加载2D纹理图像,并从数据中创建新纹理

Create a texture from CGImages

    - textureWithCGImage:options:error: 从Quartz图像 加载2D纹理图像并从数据创建新纹理
    - textureWithCGImage:options:queue:completionHandler: 从Quartz图像异步加载2D纹理图像,并根据数据创建新纹理

Multi-dimensional texture loaded from a URL

    + cabeMapWithContentsOfURL:options:errer: 从单个URL加载⽴方体贴图纹理图像,并根据数据创建新纹理
    - cabeMapWithContentsOfURL:options:queue:completionHandler:从单个URL异步加载⽴方体贴图纹理图像,并根据数据创建新纹理

Create a texture from a file to load cube

    + cubeMapWithContentsOfFile:options:errer: 从单个文件加载立方体贴图纹理对象,并从数据中创建新纹理
    - cubeMapWithContentsOfFile:options:queue:completionHandler:从单个文件异步加载⽴方体贴图纹理对象,并从数据中创建新纹理
    + cubeMapWithContentsOfFiles:options:errer: 从一系列文件中加载⽴方体贴图纹理图像,并从数据总创建新纹理
    - cubeMapWithContentsOfFiles:options:options:queue:completionHandler:从⼀系列文件异步加载⽴方体贴图纹理图像,并从数据中创建新纹理

3.2 GLKView

Function : to draw using OpenGL ES implementation of the contents of the default view

3.2.1 Properties

proxy

 delegate 视图的代理

Configuration frame buffer objects

    drawableColorFormat 颜⾊色渲染缓存区格式
    drawableDepthFormat 深度渲染缓存区格式
    drawableStencilFormat 模板渲染缓存区的格式
    drawableMultisample 多重采样缓存区的格式

Frame buffer properties

    drawableHeight 底层缓存区对象的⾼高度(以像素为单位)
    drawableWidth 底层缓存区对象的宽度(以像素为单位)

Drawing content view

    context 绘制视图内容时使⽤的OpenGL ES 上下文
    enableSetNeedsDisplay 布尔值,指定视图是否响应使得视图内容⽆无效的消息
    snapshot 绘制视图内容并将其作为新图像对象返回

3.2.2 Method

Initialization view

 - initWithFrame:context: 初始化新视图

Drawing content view

    - bindDrawable 将底层FrameBuffer 对象绑定到OpenGL ES
    - display ⽴立即重绘视图内容

Delete View FrameBuffer objects

    - deleteDrawable 删除与视图关联的可绘制对象

Drawing content view

     - glkView:drawInRect: 绘制视图内容 (必须实现代理)

3.3 GLKViewController

Function : Managing OpenGL ES rendering view controller cycle

Update

    - (void) update 更新视图内容
    - (void) glkViewControllerUpdate:

Configuration frame rate

    preferredFramesPerSecond 视图控制器调⽤视图以及更新视图内容的速率
    framesPerSencond 视图控制器调用视图以及更新其内容的实际速率

Proxy Configuration GLKViewController

    delegate 视图控制器的代理

Update control frame

    paused 布尔值,渲染循环是否已暂停
    pausedOnWillResignActive 布尔值,当前程序重新激活动状态时视图控制器是否自动暂停渲染循环
    resumeOnDidBecomeActive 布尔值,当前程序变为活动状态时视图控制是否自动恢复呈现循环

View more information about obtaining updated

    frameDisplayed 视图控制器⾃创建以来发送的帧更新数
    timeSinceFirstResume ⾃视图控制器第一次恢复发送更新事件以来经过的时间量
    timeSinceLastResume ⾃上次视图控制器恢复发送更新事件以来更新的时间量
    timeSinceLastUpdate ⾃上次视图控制器调用委托方法以及经过的时间量glkViewControllerUpdate:
    timeSinceLastDraw ⾃上次视图控制器调用视图display 方法以来经过的时间量

3.4 GLKViewControllerDelegate

Function : Rendering cycle callback methods

Process management more update event

    - glkViewControllerUpdate: 在显示每个帧之前调⽤用

Pause / Resume notice

    - glkViewController:willPause: 在渲染循环暂停或恢复之前调⽤用.

3.5 GLKBaseEffect

Function : A simple light / discolored the system, based on the shader Use renderer in OpenGL

Named Effect

    label         给Effect(效果)命名

Configuration model view conversion

    transform 绑定效果时应⽤于顶点数据的模型视图,投影和纹理理变换

Configuration lighting effects

    lightingType 用于计算每个片段的光照策略,
                对应类型为GLKLightingType类型包含:
                    GLKLightingTypePerVertex 表示在三角形中每个顶点执行光照计算,然后在三角形进行插值
                    GLKLightingTypePerPixel 表示光照计算的输入在三角形内插入,并且在每个⽚段执行光照计算

Configuration of light

    lightModelTwoSided 布尔值,表示为基元的两侧计算光照
    material 计算渲染图元光照使⽤的材质属性
    lightModelAmbientColor 环境颜色,应用效果渲染的所有图元.
    light0 场景中第一个光照属性 
    light1 场景中第二个光照属性 
    light2 场景中第三个光照属性

Texture configuration management

    texture2d0 第⼀一个纹理理属性 texture2d1 第⼆二个纹理理属性
    textureOrder 纹理理应⽤用于渲染图元的顺序

Configuration atomization

    fog 应⽤用于场景的雾属性

Configuration of colors in the color information

    colorMaterialEnable 布尔值,表示计算光照与材质交互时是否使⽤用颜⾊色顶点属性
    useConstantColor 布尔值,指示是否使⽤用常量量颜⾊色
    constantColor 不不提供每个顶点颜⾊色数据时使⽤用常量量颜⾊色

Ready to draw results

    - prepareToDraw 准备渲染效果

Guess you like

Origin www.cnblogs.com/absty-guo/p/12595880.html