glLoadIdentity(); // Added line
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
NumberFormatter *lFormater = [[NumberFormatter alloc] init];
int i = 0;
for (NSNumber *lNumber in mColXLabelCoord) {
NSNumber *lUnformated = [NSNumber numberWithInteger:[[NSString stringWithString:[mColYLabelsArray objectAtIndex:i]] integerValue]];
NSString *lFormated = [NSString stringWithString:[lFormater stringFromNumber:lUnformated withMask:[[mGraphArray objectAtIndex:0] mGraphMask]]];
Texture2D* lWord= [[Texture2D alloc] initWithString:lFormated dimensions:CGSizeMake(40, 15) alignment:UITextAlignmentLeft fontName:@"Helvetica" fontSize:13];
glColor4f(RedFromRGB(0xFFFFFF), GreenFromRGB(0xFFFFFF), BlueFromRGB(0xFFFFFF), 1.0);
[lWord drawInRect:CGRectMake([lNumber floatValue]+2, 470,40,15) rotation:-90];
[lWord release];
i++;
}
[lFormater release];
i = [mColYCoord count]-1;
for (NSNumber *lNumber in mColYCoord) {
Texture2D* lWord= [[Texture2D alloc] initWithString:[NSString stringWithFormat:((GraphValue*)[mGraphValuesArray objectAtIndex:i]).mGraphValueXLabel,[lNumber floatValue]]
dimensions:CGSizeMake(40, 15)
alignment:UITextAlignmentCenter
fontName:@"Helvetica" fontSize:12];
if ([mColYCoord count] < kOptimalLabelNumber) {
glColor4f(RedFromRGB(0xFFFFFF), GreenFromRGB(0xFFFFFF), BlueFromRGB(0xFFFFFF), 1.0);
[lWord drawInRect:CGRectMake(10, [lNumber floatValue]+15, 40, 15) rotation:-90];
}else {
glColor4f(RedFromRGB(0xFFFFFF), GreenFromRGB(0xFFFFFF), BlueFromRGB(0xFFFFFF), 1.0);
[lWord drawInRect:CGRectMake(2, [lNumber floatValue]+5, 40, 15) rotation:-30];
}
[lWord release];
i--;
}
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);