28

I'm having an issue creating a 4X4 openGL matrix in swift. I have imported the following which worked in Obj-C:

import UIKit
import GLKit
import OpenGLES

GLKMatrix4 is not available, however I have access to other GL math resources, GLKMathDegreesToRadians() for instance.

Has anyone else run into this issue?

Joseph Mark
  • 9,298
  • 4
  • 29
  • 31
Daniel Rushton
  • 480
  • 5
  • 13
  • what is the issue exactly? – Joseph Mark Jun 25 '14 at 02:24
  • None of the GLmatrix initializer methods are available. I am attempting to use GLKMatrix4Make but get an unresolved identifier warning from the compiler. – Daniel Rushton Jun 25 '14 at 02:31
  • the swift equivalent of `GLKMatrix4Make()` is `GLKMatrix4()`. have you tried that? – Joseph Mark Jun 25 '14 at 02:33
  • Yeah, I tried that initially and fell back to trying to use the former. I see other GLKMatrix* functions in the autocomplete but nothing that returns a matrix. Most of them return void. I thought perhaps the GLMath components weren't coming in with the GLKit import, but as I mentioned before GLKMathDegreesToRadians() works as expected. – Daniel Rushton Jun 25 '14 at 02:37
  • Also, the Swift documentation for GLKMatrix4 is incomplete as of yet. – Daniel Rushton Jun 25 '14 at 02:42
  • you're right actually I'm having the same problem. `GLKMatrix4` appears to be a module not a type – Joseph Mark Jun 25 '14 at 02:44
  • 5
    I just had the good sense to check the apple forums and I guess this is a known issue with Swift not yet supporting C unions. Looks like we'll have to wait for the next Beta. – Daniel Rushton Jun 25 '14 at 02:46
  • possible duplicate of [Using GLKMath from GLKit in Swift](http://stackoverflow.com/questions/24622475/using-glkmath-from-glkit-in-swift) – Nate Cook Oct 15 '14 at 04:13

1 Answers1

0

This works as expected in playground and yields a 4x4 matrix Version 6.3.2 (6D2105)

import GLKit

let someMatrix: GLKMatrix4 = GLKMatrix4Make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
Mark Essel
  • 4,606
  • 2
  • 29
  • 47