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 kEAGLDrawablePropertyRetainedBacking. This has the effect of retaining the drawable contents after presenting the render buffer, as expected. Removing this property results in flickering after the draw call with part of the drawable content seemingly being drawn to different buffers.
The problem is this is exactly the issue I am now having in my GLKView, but there doesn't seem to be a way to set the drawable properties. Returning a CAEAGLLayer and setting the properties has no effect and I don't see any relevant properties of GLKView to set retained backing.
Has anybody else come across this or have a solution?
If you want to get kEAGLDrawablePropertyRetainedBacking in a GLKView, add the following category to your project.
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.
Simeon's answer works but changes the behavior for all EAGL-based views in an application. I have some views which need the backing forced and others which don't, so I came up with a slightly different solution by creating subclasses of GLKView and CEAGLLayer, like this:
and this
Now I can just use RetainedGLKView instead of GLKView for those views where I want to force a retained backing.
In your GLKView implementation file:
I don't know how people manage to make things so complicated; it's like this, and only this.
Hi Please try this one
Not sure if this will work but here is some code we have:
You should be able to access
eaglLayer.drawableProperties
. Hopefully that lets you set the parameter you want.