I write some code about OpenGL ES. and I draw a triangle and want to put a image as texture on it. So I define a structure like this.
struct SceneVertor {
var postion : GLKVector3
var texture : GLKVector2
init(_ value:(Float, Float, Float, Float, Float)) {
self.postion = GLKVector3(v: (value.0, value.1, value.2))
self.texture = GLKVector2(v: (value.3, value.4))
}
}
but when I found glVertexAttribPointer
function. Its last argument is the UnSafeRowPointer type . In Objective-C, this argument can be
Null + offsetof(SceneVertor, texture)
but I don't understand to change it by Swift .
In the Swift 4.2, we can calculate the offset like this
MemoryLayout<SceneVertor>.offset(of: \SceneVertor.texture)
now, how can I use it in the glVertexAttribPointer
function.
thx.