func BUFFER_OFFSET(_ i: Int) -> UnsafeRawPointer {
return UnsafeRawPointer(bitPattern: i)!
}
fatal error: unexpectedly found nil while unwrapping an Optional value
func BUFFER_OFFSET(_ i: Int) -> UnsafeRawPointer {
return UnsafeRawPointer(bitPattern: i)!
}
fatal error: unexpectedly found nil while unwrapping an Optional value
Had the same issue. Was able to solve as follows:
When parameter value i == 0, UnsafeRawPointer(bitPattern: i) evaluates to nil, which you can't force unwrap.
Since the vertex position offset is 0, you can just pass nil as the last parameter:
glVertexAttribPointer(GLuint(GLKVertexAttrib.position.rawValue), 3, GLenum(GL_FLOAT), GLboolean(GL_FALSE), 24, nil)
Alternatively, you can change the BUFFER_OFFSET function to:
- 01. Return an optional
- 02. Don't force unwrap the UnsafeRawPointer call
func BUFFER_OFFSET(_ i: Int) -> UnsafeRawPointer? {
return UnsafeRawPointer(bitPattern: i)
}
Woohoo! I can use the start project again 😝