Hello All,
I'm getting a EXC_BAD_ACCESS error every if GL_COLOR_ARRAY is enabled. If I forget to disable it, it will cause the bad access error. However, I would like to use glColorPointer().
-(void) draw {
CGPoint vertices[2];
vertices[0] = ccp(0.0, 0.0);
vertices[1] = ccp(0.0, 15.0);
GLfloat colors[6];
colors[0] = 0.0f;
colors[1] = 0.0f;
colors[2] = 1.0f;
colors[3] = 1.0f;
colors[4] = 0.0f;
colors[5] = 0.0f;
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY,
// GL_TEXTURE_COORD_ARRAY
// Needed states: GL_VERTEX_ARRAY,
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
glEnable(GL_LINE_SMOOTH);
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY); // Comment for error
glColorPointer(3, GL_FLOAT, 0, colors);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(GL_LINES, 0, 2);
// restore default state
glEnableClientState(GL_COLOR_ARRAY); // Comment for error
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glDisable(GL_LINE_SMOOTH);
}
I simplified the code, but this code also generates the error. It's pretty much a class that inherited a CCNode. Nothing else in there besides the draw method. I pretty much copied the code from CCDrawingPrimitives.m to use as the basis. However, when I enable GL_COLOR_ARRAY, it crashes with the bad access error. Disabling it, everything works fine.
Am I doing something wrong? I can't find anything wrong with the code. I'm using Cocos2D ver. 0.99.
Any help is appreciated.