I'm drawing two untextured rectangles, but the 2nd one ends up the same colour as the first one despite using different RGBs
Is there any limitation on using GL_COLOR_ARRAY ?
Here's my function that's called twice...
Code:
void DrawGouraudRect( Vector2 topleft, Vector2 bottomright, RGBA col1, RGBA col2, RGBA col3, RGBA col4 )
{
glDisable( GL_TEXTURE_2D );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrthof( 0, 320, 480, 0, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( topleft.x, topleft.y, 0 );
GLfloat rectVertices[] =
{
0, 0,
bottomright.x - topleft.x, 0,
0, bottomright.y - topleft.y,
bottomright.x - topleft.x, bottomright.y - topleft.y,
};
glVertexPointer( 2, GL_FLOAT, 0, rectVertices );
glEnableClientState( GL_VERTEX_ARRAY );
static const GLubyte rectColors[] =
{
col1.r, col1.g, col1.b, col1.a,
col2.r, col2.g, col2.b, col2.a,
col3.r, col3.g, col3.b, col3.a,
col4.r, col4.g, col4.b, col4.a,
};
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, rectColors );
glEnableClientState( GL_COLOR_ARRAY );
glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
glDisableClientState( GL_COLOR_ARRAY );
}
Any help much appreciated