Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

simple question regarding with color arrays

Help
ffelagund
2005-02-03
2013-04-17
  • ffelagund
    ffelagund
    2005-02-03

    Hello, I'm triying to write the simplest ogl es application I  could: A triangle rotating in the middle of the screen with  the RGB colors interpolated across it's surface, but I have a problem. I'm triying  this setup for the VA:
    GLubyte indices[3]    = {0, 1, 2};
    GLshort vertexArray[9]= {-25,-25,0,    25,-25,0,     0,25,0 };
    GLubyte colorArray[9] = {255,0,0,      0,255,0,      0,0,255};
     
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_SHORT, 0, vertexArray);
       
    glEnableClientState(GL_COLOR_ARRAY);
    glColorPointer(3,GL_UNSIGNED_BYTE, 0, colorArray);
       
    glDrawElements(GL_TRIANGLES,3 ,GL_UNSIGNED_BYTE, indices);

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    But all that I get is a white triangle. Maybe I'm omitting some obvious, please, dont kill me if the error is too stupid :)

     
    • ffelagund
      ffelagund
      2005-02-03

      Found the error, I was using 3 color components, while 4 are needed... I have to read the spec much more carefully....