title: Swift - How to draw line in OpenGL ES?
body: <p>I'm trying to draw a black single line on <code>GLKitView</code>, using <code>Swift</code>, but it does not work.
  I can clear screen and I can fill it with any color, but I can't draw anything on it.
  And I know, this question was asked lots of times, but I could not found any answer on Swift.
  More over, there is no any info about using OpenGL ES with Swift, so I came here.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import GLKit
  
  class MyGLKit: GLKView {
      override func drawRect(rect: CGRect) {
          glClearColor(0.8, 0.8, 0.8, 1.0)
          glClear(GLbitfield(GL_COLOR_BUFFER_BIT))
  
          glColor4f(0, 0, 0, 1)
  
          var line: [GLfloat] = [-1, 0, 1, 0]
          var len = line.count * sizeof(GLfloat)
  
          // Create an handle for a buffer object array
          var bufferObjectNameArray: GLuint = 0
  
          // Have OpenGL generate a buffer name and store it in the buffer object array
          glGenBuffers(1, &amp;bufferObjectNameArray);
  
          // Bind the buffer object array to the GL_ARRAY_BUFFER target buffer
          glBindBuffer(GLbitfield(GL_ARRAY_BUFFER), bufferObjectNameArray);
  
          // Send the line data over to the target buffer in GPU RAM
          glBufferData(
          GLbitfield(GL_ARRAY_BUFFER),    // the target buffer
          len,                            // the number of bytes to put into the buffer
          line,                           // a pointer to the data being copied
          GLbitfield(GL_STATIC_DRAW));    // the usage pattern of the data
  
          glVertexPointer(2, GLbitfield(GL_FLOAT), 0, line);
          var programHandle: GLuint = glCreateProgram()
          glLinkProgram(programHandle)
  
          glDrawArrays(GLbitfield(GL_LINES), 0, 2);
      }
  }
  </code></pre>
  
  <p>I'm not sure what this code doing, cause OpenGL ES seems insanely, after usual OpenGL. I mean, you need to write a lot of code just to draw a single line. Why does it work that way?</p>