SDL 2 - Get EAGLLayer from OpenGL context on iOS

Hello everyone,

I have an issue in my program due to glReadPixels() function that seems to doesn’t work on iOS device (that works well on simulator).

I saw on many threads that I have to set the property kEAGLDrawablePropertyRetainedBacking of the EAGLLayer to YES.

Unfortunately, I don’t know where I can get this EAGLLayer from OpenGL context create by SDL…

Do you know if it’s possible? Do you know how to do it?

Thanks in advance!

I currently dont have the code here, but wasn’t there a hint to set that
flag?

Hello everyone,

I have an issue in my program due to glReadPixels() function that seems
to doesn’t work on iOS device (that works well on simulator).

I saw on many threads that I have to set the property
kEAGLDrawablePropertyRetainedBacking of the EAGLLayer to YES.

Unfortunately, I don’t know where I can get this EAGLLayer from OpenGL
context create by SDL…Am 04.06.2014 18:08 schrieb “Noxalus” :

Do you know if it’s possible? Do you know how to do it?

Thanks in advance!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks for you answer!

I’ve searched into SDL2 source files and I found that into the function called UIKit_GL_CreateContext (in the file named SDL_uikitopengles), there is indeed a flag that seems to correspond to my propery when we init the view line 123:

Code:
retainBacking: _this->gl_config.retained_backing

So in my code, just before I call the SDL_GL_CreateContext function, I put this:

Code:
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);

But it doesn’t work better :’(

I’ve check that the value is corretly set with SDL_GL_GetAttribute() and it is.

I’ve seen that this attribute is depreciated in the SDL documentation (https://wiki.libsdl.org/SDL_GL_SetAttribute), but I don’t know if this is why it doesn’t work for me.

Anybody uses this attribute in his project?

I’m sorry, this was a problem of precision, the flag SDL_GL_RETAINED_BACKING didn’t resolve my problem.

For my issue, I had to increase the SDL_GL_BLUE_SIZE from 5 to 8.

Thanks for your help and have a nice day :wink: