title: OpenGL lines not colored
body: <p>I'm working in OpenGL, with VBOs, and I have a set of three lines (along the X, Y and Z axes - think Czech hedgehog). The lines are grey by default, but I want them bright red so I can see them better.  Unfortunately, though I added color information as vertex data, the lines still appear grey.  I'm probably missing something basic, but I can't see it.  Here is how I create the VBO:</p>
  
  <pre><code>//Position data
  sf::Vector3&lt;float&gt; Top    = sf::Vector3&lt;float&gt;(0.0, 1.0, 0.0);
  sf::Vector3&lt;float&gt; Front  = sf::Vector3&lt;float&gt;(0.0, 0.0, -1.0);
  sf::Vector3&lt;float&gt; Right  = sf::Vector3&lt;float&gt;(1.0, 0.0, 0.0);
  sf::Vector3&lt;float&gt; Back   = sf::Vector3&lt;float&gt;(0.0, 0.0, 1.0);
  sf::Vector3&lt;float&gt; Left   = sf::Vector3&lt;float&gt;(-1.0, 0.0, 0.0);
  sf::Vector3&lt;float&gt; Bottom = sf::Vector3&lt;float&gt;(0.0, -1.0, 0.0);
  
  //Color data
  //Just to be clear, I also tried with 255.0, although I'm rather certain OpenGL 
  //does its colors on a 0-1 scale.
  sf::Vector3&lt;float&gt; Color = sf::Vector3&lt;float&gt;(1.0, 0.0, 0.0);
  
  //Create vector
  std::vector&lt;float&gt; LineArray;
  
  //Top
  LineArray.push_back(Top.x);
  LineArray.push_back(Top.y);
  LineArray.push_back(Top.z);
  LineArray.push_back(Color.x);
  LineArray.push_back(Color.y);
  LineArray.push_back(Color.z);
  //Bottom
  LineArray.push_back(Bottom.x);
  LineArray.push_back(Bottom.y);
  LineArray.push_back(Bottom.z);
  LineArray.push_back(Color.x);
  LineArray.push_back(Color.y);
  LineArray.push_back(Color.z);
  
  //Front
  LineArray.push_back(Front.x);
  LineArray.push_back(Front.y);
  LineArray.push_back(Front.z);
  LineArray.push_back(Color.x);
  LineArray.push_back(Color.y);
  LineArray.push_back(Color.z);
  //Back
  LineArray.push_back(Back.x);
  LineArray.push_back(Back.y);
  LineArray.push_back(Back.z);
  LineArray.push_back(Color.x);
  LineArray.push_back(Color.y);
  LineArray.push_back(Color.z);
  
  //Right
  LineArray.push_back(Right.x);
  LineArray.push_back(Right.y);
  LineArray.push_back(Right.z);
  LineArray.push_back(Color.x);
  LineArray.push_back(Color.y);
  LineArray.push_back(Color.z);
  //Left
  LineArray.push_back(Left.x);
  LineArray.push_back(Left.y);
  LineArray.push_back(Left.z);
  LineArray.push_back(Color.x);
  LineArray.push_back(Color.y);
  LineArray.push_back(Color.z);
  
  //Create buffer
  glGenBuffers(1, &amp;m_Buffer);
  glBindBuffer(GL_ARRAY_BUFFER, m_Buffer);
  int SizeInBytes = LineArray.size() * 6 * sizeof(float);
  glBufferData(GL_ARRAY_BUFFER, SizeInBytes, NULL, GL_STATIC_DRAW);
  
  //Upload buffer data
  glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float) * LineArray.size(), &amp;LineArray[0]);
  </code></pre>
  
  <p>And this is how I display it every tick:</p>
  
  <pre><code>glPushMatrix();
  
  //Translate
  glTranslatef(m_Position.x, m_Position.y, m_Position.z);
  //Rotate
  glMultMatrixf(m_RotationMatrix);
  
  //Bind buffers for vertex and color arrays
  glBindBuffer(GL_ARRAY_BUFFER, m_Buffer);
  
  glEnableClientState(GL_VERTEX_ARRAY);
  glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), 0);
  glEnableClientState(GL_COLOR_ARRAY);
  glColorPointer(3, GL_FLOAT, 6 * sizeof(float), (void*)12);
  
  //Draw
  glDrawArrays(GL_LINES, 0, 36);
  
  glDisableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
  
  //Unbind the buffers
  glBindBuffer(GL_ARRAY_BUFFER, 0);
  
  glPopMatrix();
  </code></pre>
  
  <p>I've never used GL_COLOR_ARRAY before, but I based the code off of successful use of GL_NORMAL_ARRAY.  Can someone point out what's wrong?</p>
  
  <p>EDIT: On the offchance that I'm setting up my basic OpenGL parameters wrong (lighting in particular), here are those:</p>
  
  <pre><code>m_AmbientLight = {0.5f, 0.5f, 0.5f, 1.0f};
  m_DiffuseLight = {1.0f, 1.0f, 1.0f, 1.0f};
  m_LightPos = {8.0f, -16.0f, 8.0f, 0.0f};
  
  //Smooth Shading
  glShadeModel(GL_SMOOTH);
  
  // Set color and depth clear value
  glClearDepth(1.f);
  //Color here is in RGB, converted to a 0-1 scale.
  glClearColor(0.3f, 0.3f, 0.3f, 1.f);
  
  // Enable Z-buffer read and write
  glEnable(GL_DEPTH_TEST);
  glDepthMask(GL_TRUE);
  
  ///
  ///LIGHTING
  ///
  //Set up lighting.
  //This activates the ambient light.
  glLightfv(GL_LIGHT0, GL_AMBIENT, m_AmbientLight);
  //This activates the diffuse light.
  glLightfv(GL_LIGHT1, GL_DIFFUSE, m_DiffuseLight);
  //This sets the position of the diffuse light.
  glLightfv(GL_LIGHT1, GL_POSITION, m_LightPos);
  //This enables the light.
  glEnable(GL_LIGHT0);
  glEnable(GL_LIGHT1);
  //Enables all lighting...?
  glEnable(GL_LIGHTING);
  glEnable(GL_COLOR_MATERIAL);
  //glEnable(GL_NORMALIZE);
  
  // Setup a perspective projection
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(60.f, 1.33f, 0.1f, 512.f);
  </code></pre>
  
  <p>EDIT 2: Having established that glColor3f() also doesn't have any effect, I wonder if my shaders are the problem:</p>
  
  <p>Vert shader:</p>
  
  <pre><code>void main()
  {
  vec3 normal, lightDir;
  vec4 diffuse;
  float NdotL;
  
  normal = normalize(gl_NormalMatrix * gl_Normal);
  
  lightDir = normalize(vec3(gl_LightSource[0].position));
  
  NdotL = max(dot(normal, lightDir), 0.0);
  
  diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
  gl_FrontColor =  NdotL * diffuse;
  
  gl_Position = ftransform();
  }
  </code></pre>
  
  <p>Frag shader:</p>
  
  <pre><code>void main()
  {
  gl_FragColor = gl_Color;
  }
  </code></pre>