Reputation: 9257
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)
}
}
Upvotes: 5
Views: 7411
Reputation: 9257
There is no GLKView in OS X! From Apple documentation:
In OS X, NSOpenGLView class subsumes the GLKView and GLKViewController classes in iOS.
Upvotes: 3
Reputation: 1174
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)
}
}
Upvotes: 9