根据要求调用GLKView渲染

时间:2015-10-27 14:04:02

标签: ios swift opengl-es-2.0 glkit glkview

我使用外部渲染器创建应用程序以及如何通过请求调用重绘?例如,在Android上我可以使用requestRenderer()和RENDERMODE_WHEN_DIRTY渲染模式来完成。

我有下一个代码:

import UIKit
import GLKit
class RendererViewController: GLKViewController {

    var rendererView: GLKView!
    var filename: String!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.rendererView = self.view as! GLKView
        self.rendererView.context = EAGLContext(API: .OpenGLES2)
        self.rendererView.drawableDepthFormat = GLKViewDrawableDepthFormat.Format24
        self.setupGL()

    }

    func setupGL(){
        EAGLContext.setCurrentContext(self.rendererView.context)
         RendererBridge.initLLG()
        self.rendererView.bindDrawable()
        let wight = self.rendererView.drawableWidth
        let height = self.rendererView.drawableHeight
         RendererBridge.open(Int32(wight), hei: Int32(height), filepath: filename)
         RendererBridge.createRenderer(Int32(wight), hei: Int32(height))
    }



    deinit{
        if EAGLContext.currentContext() == self.rendererView.context{
            EAGLContext.setCurrentContext(nil)
        }
    }

    override func glkView(view: GLKView, drawInRect rect: CGRect) {
            RendererBridge.renderFrame()
    }

}

1 个答案:

答案 0 :(得分:0)

我已经完成了下一步:

  1. 为GLKView启用setNeedsDisplay
  2. 将GLKViewController更改为暂停:self.pause = true
  3. 致电self.view.setNeedsDisplay