title: How do I convert this OpenGL pointer math to Swift?
body: <p>I’m following <a href="http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1#comments" rel="noreferrer">this tutorial</a> about OpenGL / GLKit for iOS but trying to implement it in Swift. It’s going fine until I get to this part:</p>
  
  <pre><code>- (void)render { 
  
  // 1
  self.effect.texture2d0.name = self.textureInfo.name;
  self.effect.texture2d0.enabled = YES;
  
  // 2    
  [self.effect prepareToDraw];
  
  // 3
  glEnableVertexAttribArray(GLKVertexAttribPosition);
  glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
  
  //---------------- This is where things break down...
  long offset = (long)&amp;_quad;        
  glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, geometryVertex)));
  glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, textureVertex)));
  
  // 5    
  glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  
  }
  
  @end
  </code></pre>
  
  <p>I have a property <code>self.quad</code> that’s a Swift struct like this:</p>
  
  <pre><code>struct TexturedVertex {
  let geometryVertex: CGPoint
  let textureVertex: CGPoint
  }
  
  struct TexturedQuad {
  
  let bottomLeft: TexturedVertex
  let bottomRight: TexturedVertex
  let topLeft: TexturedVertex
  let topRight: TexturedVertex
  }
  </code></pre>
  
  <p>It’s a fairly straightforward structure, but <strong>I don’t know how to pass it to the last argument of <code>glVertexAttribPointer</code></strong>. Any help would be stellar!</p>