title: How to draw lines (wireframe) using GLKit?
body: <p><strong>What I have:</strong> A GLKViewController and its associated view that draws my cube objects (rotating, if I want :) in the expected location, scale, color, etc.</p>
  
  <p>*<strong>What I want:</strong> Rather than cubes, I'd like to specify an object with geometry that is an array of vertex-pairs and convince GLKit (implied: OpenGL-ES-2) to draw each pair of vertices as a line-segment in my view space.</p>
  
  <p>NOTE: My line segments do <em>NOT</em> form a line-strip, so no line-strips.  My line-segments do <em>NOT</em> form triangles as part of a mesh (or any other geometry.)  They're just individual line-segments in space, with no relation to each other.  Think "pick-up sticks" or something similar.</p>
  
  <p><strong>What I tried:</strong> I created an array of vertex pairs (GLKVector3) and vertex colors (GLKVector4) like this:</p>
  
  <pre><code>lineVertices  = calloc (verts, sizeof(GLKVector3));
  colorVertices = calloc (verts, sizeof(GLKVector4));
  
  lineVertices[index++] = GLKVector3Make(x, 0, z);
  lineVertices[index++] = GLKVector3Make(x2, 0, z2);
  // etc., snip
  colorVertices[cIndex++] = GLKVector4Make(1, 0.0, 1, 1);
  // etc., snip
  </code></pre>
  
  <p>...and tried to draw them like this:</p>
  
  <pre><code>glEnable(GL_DEPTH_TEST);
  
  glEnableVertexAttribArray(GLKVertexAttribPosition);
  glVertexAttribPointer(GLKVertexAttribPosition, 2,   // ** WRONG ** "2" should be "3"
                            GL_FLOAT, GL_FALSE, 0, lineVertices);
  
  glEnableVertexAttribArray(GLKVertexAttribColor);
  glVertexAttribPointer(GLKVertexAttribColor, 4,
                                GL_FLOAT, GL_FALSE, 0, colorVertices);
  
  glDrawArrays(GL_LINES, 0, lineVertCount);
  
  glDisableVertexAttribArray(GLKVertexAttribPosition);
  glDisableVertexAttribArray(GLKVertexAttribColor);
  </code></pre>
  
  <p>(All this code is in the right place, as proven by the fact that my cube-objects, which use the same infrastructure, draw correctly.)</p>
  
  <p><strong>What I get when I try that:</strong>  Only some of my line segments draw, and they appear to be pointing every which way, not at all in lovely pattern that I'd hoped to see.  I can't quite seem to discern the pattern of he line-segments drawn.  It's as if I'm getting random memory, except that my lineVertices array is correct (checked.)</p>
  
  <p><strong>Homework completed:</strong> I see a lot of SO questions that are close, but most devolve to line-strips or triangle-meshes or otherwise don't quite apply.  Some are setup-problems related (already eliminated, as my cubes draw just fine.)  Similar not-quite-right for other non-SO answers, tutorials, etc.</p>
  
  <p>NOTE: I'm relying on built-in shaders (that is, I don't have any create-shader code in my app.)</p>
  
  <p>While my end-result geometry is <em>NOT</em> a cube, I'd be ok with drawing a basic wireframe cube as a proof-of-concept, here.  Again, without using triangles or line-strips, though, since my final-result is not going to be appropriate for those.</p>
  
  <p>Can anyone give me any pointers to sample-code that does the sort of bare-line-segment drawing for which I'm looking?</p>
  
  <p>Thanks!</p>