NSString *path = [[NSBundle mainBundle] pathForResource:@"myImage"ofType:@"jpg"];
NSData *texData= [[NSData alloc] initWithContentsOfFile:path];
UIImage *image = [[UIImage alloc] initWithData:texData];
if (image == nil)
   NSLog(@"W tym miejscu przeprowad sprawdzenie pod ktem bdw");

GLuint width = CGImageGetWidth(image.CGImage);
GLuint height = CGImageGetHeight(image.CGImage);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
void *imageData = malloc(height * width * 4);
CGContextRef context = CGBitmapContextCreate(imageData, width, height,
   8, 4 * width, colorSpace,
   kCGImageAlphaPremultpliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
CGRect imageRect= CGRectMake(0, 0, width, height);
CGContextClearRect(context, imageRect);
CGContextTranslateCTM(context, 0, height - height);
CGContextDrawImage(context, imageRect, image.CGImage);

glTexImage2D(GL_TEXTURE_2D 0, GL_RGBA, width, height, 0,
   GL_RGBA, GL_UNSIGNED_BYTE, imageData);

CGContextRelease(context);

free(imageData);
[image release];
[texData release];
