GLKTextureLoader fails when loading a certain texture the first time, but succeeds the second time

前端 未结 8 2695
清酒与你
清酒与你 2021-02-20 12:57

I\'m making an iPhone application with OpenGL ES 2.0 using the GLKit. I\'m using GLKTextureLoader to load textures synchronously.

The problem is that for a certain textu

相关标签:
8条回答
  • 2021-02-20 13:39

    I've also found that you get this error when trying to create a 2D texture with an image larger than the maximum texture size. For the max size you can see Apple's Open GL ES Platform Notes, although those do not appear correct for newer devices so the best bet is to get the value directly.

    0 讨论(0)
  • 2021-02-20 13:42

    I was also getting

    The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 8.)
    

    when loading a texture late in runtime while several previous textures had loaded successfully closer to launch. I was able to solve the problem by inserting the following line of code before the GLKTextureLoader call:

    NSLog(@"GL Error = %u", glGetError());
    

    Sure enough, GL was reporting an error, but it did not require me to address the error in order for GLKTextureLoader to work. Merely getting the GL Error was enough.

    0 讨论(0)
  • 2021-02-20 13:42

    Ok, I'll try this one again as I ran into the error again. What appears to happen is that if there is some other glError that has not been processed, then you will have trouble with the texture loading on the first time.

    Before you load that texture that fails, check for a glError and then track down where that error occurred. Or you can capture an opengl frame prior to where the texture is loaded and see if a glError is being thrown prior. This happened to me both times when I ran into the error 8, and both times this error disappeared once I fixed the error that had occurred earlier.

    0 讨论(0)
  • 2021-02-20 13:43

    I had very similar problem and it has been solved by calling setCurrentContext.

    self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
    [EAGLContext setCurrentContext:self.context];
    
    0 讨论(0)
  • 2021-02-20 13:45

    I got this when enabling textures before loading the texture. Simply moved glEnable(GL_TEXTURE) after the loading and the issue was gone.

    0 讨论(0)
  • 2021-02-20 13:45

    I ran into the same problem. I'm not exactly sure as to why it occurred exactly other than that it appeared that there were multiple file operations going on at the same time. For example, performing a file load (for model data) right AFTER using the texture loader for the first time would cause error 8 to pop up. I fixed it in my program by having some other operations occur after the texture loader is called for the first time.

    0 讨论(0)
提交回复
热议问题