Ответ 1
Класс NSValue
имеет методы +[valueWithPoint:]
и -[CGPointValue]
? Это то, что вы ищете?
//Getting mouse coordinates
NSMutableArray *vertices = [[NSMutableArray alloc] init];
CGPoint location = [self convertPoint:event.locationInWindow fromView:self];
NSValue *locationValue = [NSValue valueWithPoint:location];
[vertices addObject:locationValue];
//Converting from NSMutableArray to GLFloat to work with OpenGL
NSUInteger count = vertices.count * 2; // * 2 for the two coordinates
GLFloat GLVertices[] = (GLFloat *)malloc(count * sizeof(GLFloat));
for (NSUInteger i = 0; i < count; i++) {
NSValue *locationValue = [vertices objectAtIndex:i];
CGPoint location = locationValue.CGPointValue;
GLVertices[i] = location.x;
GLVertices[i] = location.y;
}