title: Yellow Triangle that should be 3 colours OpenGL
body: <p>This is probably a silly mistake but I cant see it?! I have classes defining geometry and classes that render that geometry. Right now it is basic triangles and colours for each vertex. </p>
  
  <p>Here is the code defining said geometry objects data:</p>
  
  <pre><code>CGeometry* g = new CGeometry();
  g-&gt;vertexes = new double[3*3];
  
  g-&gt;vertexes[0] = 0;
  g-&gt;vertexes[1] = 0;
  g-&gt;vertexes[2] = 0;
  
  g-&gt;vertexes[3] = 100;
  g-&gt;vertexes[4] = 100;
  g-&gt;vertexes[5] = 0;
  
  g-&gt;vertexes[6] = 100;
  g-&gt;vertexes[7] = 0;
  g-&gt;vertexes[8] = 0;
  
  g-&gt;colors = new double[12];
  
  g-&gt;colors[0] = 1;
  g-&gt;colors[1] = 1;
  g-&gt;colors[2] = 0;
  g-&gt;colors[3] = 1;
  
  g-&gt;colors[4] = 1;
  g-&gt;colors[5] = 0;
  g-&gt;colors[6] = 1;
  g-&gt;colors[7] = 0;
  
  g-&gt;colors[8] = 0;
  g-&gt;colors[9] = 1;
  g-&gt;colors[10] = 1;
  g-&gt;colors[11] = 0;
  </code></pre>
  
  <p>And here is the code that renders said data:</p>
  
  <pre><code>CGeometry* g = object-&gt;geometry;
  
  int j = object-&gt;endIndex - object-&gt;startIndex;
  double* vertexes = g-&gt;vertexes;
  double* colors = g-&gt;colors;
  
  glBegin(GL_TRIANGLES);
  {
      for(int i = 0; i &lt; j; i++){
          int coord = object-&gt;startIndex+i;
          int colorind = coord*4;
  
          double r,g,b,a;
          r = colors[colorind];
          g = colors[colorind+1];
          b = colors[colorind+2];
          a = colors[colorind+3];
  
          glColor4d(  r,g,b,a);
          glVertex3d( vertexes[coord*3],
                      vertexes[coord*3+1],
                      vertexes[coord*3+2]);
      }
  }
  glEnd();
  </code></pre>
  
  <p>Yet regardless of what I put my triangle is always yellow, or the value of the first color in the colors array. I have gone into the debugger and checked the values on each individual loop iteration and the values of the r g b and a variables do infact change accordingly and are not always yellow, yet the result is a yellow triangle.</p>
  
  <p></p>
  
  <p>Yet if I put the following nabbed from the neheGL tutorials:</p>
  
  <pre><code>glClearColor(0.1f,0.1f,0.1f,1);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
  glLoadIdentity();                                   // Reset The Current Modelview Matrix
  //glTranslatef(1.5f,0.0f,0.0f);                     // Move Left 1.5 Units And Into The Screen 6.0
  glBegin(GL_TRIANGLES);                              // Drawing Using Triangles
      glColor3f(1.0f,0.0f,0.0f);                      // Set The Color To Red
      glVertex3f( 0.0f, 1.0f, 0.0f);                  // Top
      glColor3f(0.0f,1.0f,0.0f);                      // Set The Color To Green
      glVertex3f(-1.0f,-1.0f, 0.0f);                  // Bottom Left
      glColor3f(0.0f,0.0f,1.0f);                      // Set The Color To Blue
      glVertex3f( 1.0f,-1.0f, 0.0f);                  // Bottom Right
  glEnd();                                            // Finished Drawing The Triangle
  glTranslatef(160.0f,0.0f,0.0f);                     // Move Right 3 Units
  glColor3f(0.5f,0.5f,1.0f);                          // Set The Color To Blue One Time Only
  glBegin(GL_QUADS);                                  // Draw A Quad
      glVertex3f(-1.0f, 1.0f, 0.0f);                  // Top Left
      glVertex3f( 1.0f, 1.0f, 0.0f);                  // Top Right
      glVertex3f( 1.0f,-1.0f, 0.0f);                  // Bottom Right
      glVertex3f(-1.0f,-1.0f, 0.0f);                  // Bottom Left
  glEnd();
  </code></pre>
  
  <p>I get a nice blended triangle with 3 colours from each vertex</p>