我是一名新的快速开发人员。我正在使用glkit编写代码。我在GLKViewController中没有调用update方法时遇到麻烦。请帮我修理一下。谢谢
import GLKit
class gameController:GLKViewController {
override func viewDidLoad() {
super.viewDidLoad()
let glkView: GLKView = view as! GLKView
glkView.context = EAGLContext(api: .openGLES2)!
EAGLContext.setCurrent(glkView.context)
}
func update(){
}
override func glkView(_ view: GLKView, drawIn rect: CGRect) {
glClearColor(1, 1, 1, 1)
glClear(GLbitfield(GL_COLOR_BUFFER_BIT))
}
}
答案 0 :(得分:0)
使用代表!
ViewController
中,继承GLKViewController
和GLKViewControllerDelegate
。viewDidLoad()
分配self.delegate
self
glkViewControllerUpdate(_ controller: GLKViewController)
class ViewController: GLKViewController, GLKViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
....
}
func glkViewControllerUpdate(_ controller: GLKViewController) {
....
....
}
}