I'm trying to use GLKit within the Xcode 6 OS X Swift Playground but the
import GLKit
doesn't seem enough to make Playground recognize GLKView. Any ideas?
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)
}
}
You can create iOS project and add new .playground file inside that project. Then you can import GLkit, I also had to import OpenGLES instead of 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)
}
}
There is no GLKView in OS X! From Apple documentation:
In OS X, NSOpenGLView class subsumes the GLKView and GLKViewController classes in iOS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With