title: OpenGL Texture not displaying on iOS with Swift
body: <p>I would like to show a texture with OpenGLES2 on iOS using Swift, but unfortunately the texture does not show up :-(. I don't know what I am doing wrong. Obviously the 'Test-Texture' is correctly loaded (and is POT). Maybe the call to glEnableVertexAttribArray is wrong?</p>
  
  <pre><code>func BUFFER_OFFSET(i: Int) -&gt; UnsafePointer&lt;Void&gt; {
      let p: UnsafePointer&lt;Void&gt; = nil
      return p.advancedBy(i)
  }
  
  let vertices:[GLfloat] = [
      // Positions       // Colors        // Texture Coords
      0.5,  0.5, 0.0,   1.0, 0.0, 0.0,   1.0, 1.0, // Top Right
      0.5, -0.5, 0.0,   0.0, 1.0, 0.0,   1.0, 0.0, // Bottom Right
      -0.5, -0.5, 0.0,   0.0, 0.0, 1.0,   0.0, 0.0, // Bottom Left
      -0.5,  0.5, 0.0,   1.0, 1.0, 0.0,   0.0, 1.0  // Top Left
  ]
  
  let indices:[GLuint] = [  // Note that we start from 0!
      0, 1, 3,  // First Triangle
      1, 2, 3   // Second Triangle
  ]
  
  func setupGL() {
      EAGLContext.setCurrentContext(self.context)
      self.loadShaders()
  
      self.effect = GLKBaseEffect()
      self.effect!.light0.enabled = GLboolean(GL_TRUE)
      self.effect!.light0.diffuseColor = GLKVector4Make(1.0, 0.4, 0.4, 1.0)
  
      do {
          testTexture = try GLKTextureLoader.textureWithContentsOfFile(NSBundle.mainBundle().pathForResource("MyTexture1024x1024", ofType: "png")!, options: [GLKTextureLoaderOriginBottomLeft:true, GLKTextureLoaderApplyPremultiplication:true])
          print("successfully loaded test texture")
      }
      catch let error as NSError {
          print("could not load test texture \(error)")
      }
  
      glEnable(GLenum(GL_DEPTH_TEST))
      glGenVertexArraysOES(1, &amp;vertexArray)
      glBindVertexArrayOES(vertexArray)
  
      glGenBuffers(1, &amp;vertexBuffer)
      glBindBuffer(GLenum(GL_ARRAY_BUFFER), vertexBuffer)
      glBufferData(GLenum(GL_ARRAY_BUFFER), GLsizeiptr(sizeof(GLfloat) * vertices.count), vertices, GLenum(GL_STATIC_DRAW))
  
      glGenBuffers(1, &amp;indexBuffer)
      glBindBuffer(GLenum(GL_ELEMENT_ARRAY_BUFFER), indexBuffer)
      glBufferData(GLenum(GL_ELEMENT_ARRAY_BUFFER), GLsizeiptr(sizeof(GLfloat) * indices.count), indices, GLenum(GL_STATIC_DRAW))
  
      glEnableVertexAttribArray(GLuint(GLKVertexAttrib.Position.rawValue))
      glVertexAttribPointer(GLuint(GLKVertexAttrib.Position.rawValue), 3, GLenum(GL_FLOAT), GLboolean(GL_FALSE), GLsizei(sizeof(GLfloat) * 8), BUFFER_OFFSET(0))
      glEnableVertexAttribArray(GLuint(GLKVertexAttrib.TexCoord0.rawValue))
      glVertexAttribPointer(GLuint(GLKVertexAttrib.TexCoord0.rawValue), 2, GLenum(GL_FLOAT), GLboolean(GL_FALSE), GLsizei(sizeof(GLfloat) * 8), BUFFER_OFFSET(sizeof(GLfloat) * 6))
  
      glBindVertexArrayOES(0)
  }
  
  override func glkView(view: GLKView, drawInRect rect: CGRect) {
      glClearColor(0.65, 0.65, 0.65, 1.0)
      glClear(GLbitfield(GL_COLOR_BUFFER_BIT) | GLbitfield(GL_DEPTH_BUFFER_BIT))
  
      //use specified vertex buffer
      glBindVertexArrayOES(vertexArray)
  
      //use specified index buffer
      glBindBuffer(GLenum(GL_ELEMENT_ARRAY_BUFFER), indexBuffer)
  
      glEnable(GLenum(GL_BLEND));
      glBlendFunc(GLenum(GL_SRC_ALPHA), GLenum(GL_ONE_MINUS_SRC_ALPHA));
  
      self.effect!.texture2d0.name = testTexture.name
      self.effect!.texture2d0.enabled = 1
  
      // Render the object with GLKit
      self.effect!.prepareToDraw()    
      glDrawElements(GLenum(GL_TRIANGLES), 6, GLenum(GL_UNSIGNED_INT), nil)
  }
  </code></pre>