Como usar o GLKit no Xcode OS X Swift Playground?
-
21-12-2019 - |
Pergunta
Estou tentando usar o GLKit no Xcode 6 OS X Swift Playground, mas o
import GLKit
não parece suficiente para fazer o Playground reconhecer o GLKView.Alguma ideia?
import Cocoa
import GLKit
import OpenGL
let frame = CGRect(x: 0, y: 0, width: 400, height: 300)
class TriangleView: GLKView { // ERROR: Use of undeclared type 'GLKView'
override func drawRect(dirtyRect: NSRect) {
glClearColor(0.0, 0.0, 0.1, 1.0)
}
}
Solução
Você pode criar um projeto iOS e adicionar um novo arquivo .playground dentro desse projeto.Então você pode importar o GLkit, também tive que importar OpenGLES em vez de OpenGL.
import UIKit
import GLKit
import OpenGLES
let frame = CGRect(x: 0, y: 0, width: 400, height: 300)
class TriangleView: GLKView { // ERROR: Use of undeclared type 'GLKView'
override func drawRect(dirtyRect: CGRect) {
glClearColor(0.0, 0.0, 0.1, 1.0)
}
}
Outras dicas
Não há GLKView no OS X!De Documentação da Apple:
Na classe OS X, o NSOPENGLVIEW inclui as classes GLKView e GlkViewController no iOS.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow