
176 5. OpenGL ES: Turbocharged!
e implementation of createTexFromImage: is not particularly dicult:
- (void) createTexFromImage: (NSString *) picName {
UIImage *pic = [UIImage imageNamed: picName];
int scaleFactor = 1;
float iOSVersion = [[[UIDevice currentDevice] systemVersion]
floatValue];
if (iOSVersion > = 4.0) {
if (pic.scale > = 2) {
scaleFactor = pic.scale;
}
}
if (pic) {
//set the texture’s dimensions
width = pic.size.width * scaleFactor;
height = pic.size.height * scaleFactor;
if ((width & (width-1)) ! = 0 || (height & (height-1)) ! = 0
|| width > 2048 || height > 2048) {
NSLog(@"ERROR:%@ width and/or height is not a power of 2 ...