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