Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 2.76 KB  |  hits: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. GLKTextureLoader cubemap fails with GLError 1281
  2. - (BOOL)loadTextures
  3. {
  4. // make sure EAGL context is active
  5. [EAGLContext setCurrentContext:self.context];
  6.  
  7. /*
  8.  Array of textures sorted as written in apple documentation
  9.  Right(+x), Left(-x), Top(+y), Bottom(-y), Front(+z), Back(-z).
  10.  Ref: http://developer.apple.com/library/ios/#documentation/GLkit/Reference/GLKTextureLoader_ClassRef/Reference/Reference.html#//apple_ref/occ/clm/GLKTextureLoader/cubeMapWithContentsOfFiles:options:error:
  11. */
  12.  
  13. NSArray *texturesArray = @[
  14. [[NSBundle mainBundle] pathForResource:@"Right" ofType:@"png"], // +x
  15. [[NSBundle mainBundle] pathForResource:@"Left" ofType:@"png"],  // -x
  16. [[NSBundle mainBundle] pathForResource:@"Up" ofType:@"png"],    // +y
  17. [[NSBundle mainBundle] pathForResource:@"Down" ofType:@"png"],  // -y
  18. [[NSBundle mainBundle] pathForResource:@"Front" ofType:@"png"], // +z
  19. [[NSBundle mainBundle] pathForResource:@"Back" ofType:@"png"],  // -z
  20. ];
  21.  
  22. NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
  23.                          [NSNumber numberWithBool:YES],
  24.                          GLKTextureLoaderOriginBottomLeft,
  25.                          nil];
  26.  
  27. NSError *error;
  28. // load cubemap texture with given array of file paths
  29. self.cubemapTexture = [GLKTextureLoader cubeMapWithContentsOfFiles:texturesArray
  30.                                                            options:options
  31.                                                              error:&error];
  32. // if cubemapeTexture is null, loading failed
  33. if (nil == self.cubemapTexture) {
  34.     NSLog(@"Failure reason: %@", error.description);
  35.     NSLog(@"Error code: %i", error.code);
  36.     NSLog(@"Textures: %@", texturesArray);
  37.     NSLog(@"Error: %@", [error description]);
  38.     @throw @"Can not load cubemap textures";
  39. } else {
  40.     NSLog(@"Loaded cubemap textures '%@'n", self.cubemapTexture);
  41. }
  42. return YES;
  43. }
  44.        
  45. ERROR: The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 8.)
  46. Failure reason: Error Domain=GLKTextureLoaderErrorDomain Code=8 "The operation couldn’t be completed.
  47.     (GLKTextureLoaderErrorDomain error 8.)" UserInfo=0x886bee0 {
  48.         GLKTextureLoaderGLErrorKey=1281,
  49.         GLKTextureLoaderErrorKey=OpenGL error
  50.     }
  51.  
  52. Error code: 8
  53. Error loading cubemap texture (null)
  54. Textures: (
  55.     "/ShortenPATH/Right.png",
  56.     "/ShortenPATH/Left.png",
  57.     "/ShortenPATH/Up.png",
  58.     "/ShortenPATH/Down.png",
  59.     "/ShortenPATH/Front.png",
  60.     "/ShortenPATH/Back.png"
  61. )
  62. Error: Error Domain=GLKTextureLoaderErrorDomain Code=8
  63.     "The operation couldn’t be completed.
  64.     (GLKTextureLoaderErrorDomain error 8.)" UserInfo=0x886bee0 {
  65.         GLKTextureLoaderGLErrorKey=1281, GLKTextureLoaderErrorKey=OpenGL error
  66.     }
  67.  
  68. *** Terminating app due to uncaught exception of class '__NSCFConstantString'
  69. terminate called throwing an exception