GLKView set drawable properties

后端 未结 1 1359
遇见更好的自我
遇见更好的自我 2021-02-11 17:44

I\'m trying to port Apples GLPaint example to use GLKit. Using a UIView, its possible to return the CAEAGLLayer of the view and set the drawableProperties to include kEAGLDrawab

1条回答
  •  无人及你
    2021-02-11 18:28

    If you want to get kEAGLDrawablePropertyRetainedBacking in a GLKView, add the following category to your project.

    @interface CAEAGLLayer (Retained)
    
    @end 
    
    @implementation CAEAGLLayer (Retained)
    
    - (NSDictionary*) drawableProperties
    {
        return @{kEAGLDrawablePropertyRetainedBacking : @(YES)};
    }
    
    @end
    

    Setting the drawableProperties on the CAEAGLLayer maintained by the GLKView doesn't work because the GLKView overwrites those properties when it binds its drawable and generates its render storage. Using this method forces the GLKView to use your category's returned drawableProperties instead.

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