Question

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)
    }
}
Was it helpful?

Solution

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)
    }
}

OTHER TIPS

There is no GLKView in OS X! From Apple documentation:

In OS X, NSOpenGLView class subsumes the GLKView and GLKViewController classes in iOS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top