0

我使用外部渲染器创建应用程序以及如何按请求调用重绘?例如,在 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()
    }

}
4

1 回答 1

0

我已经通过以下步骤完成了:

  1. 为 GLKView 启用 setNeedsDisplay
  2. 将 GLKViewController 更改为暂停:self.pause = true
  3. 称呼self.view.setNeedsDisplay
于 2015-10-30T12:11:58.793 回答