21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2)
30 #include "../SDL_sysvideo.h"
31 #include "../../events/SDL_keyboard_c.h"
32 #include "../../events/SDL_mouse_c.h"
33 #include "../../power/uikit/SDL_syspower.h"
37 @interface SDLEAGLContext : EAGLContext
40 @property (nonatomic, strong) SDL_uikitopenglview *sdlView;
44 @implementation SDLEAGLContext
50 [
self.sdlView setSDLWindow:NULL];
56 UIKit_GL_GetProcAddress(
_THIS,
const char *proc)
61 return dlsym(RTLD_DEFAULT, proc);
71 SDLEAGLContext *eaglcontext = (__bridge SDLEAGLContext *)
context;
73 if (![EAGLContext setCurrentContext:eaglcontext]) {
74 return SDL_SetError(
"Could not make EAGL context current");
78 [eaglcontext.sdlView setSDLWindow:window];
91 if ([view isKindOfClass:[SDL_uikitopenglview
class]]) {
92 SDL_uikitopenglview *glview = (SDL_uikitopenglview *) view;
94 *
w = glview.backingWidth;
97 *
h = glview.backingHeight;
106 UIKit_GL_LoadLibrary(
_THIS,
const char *
path)
111 return SDL_SetError(
"iOS GL Load Library just here for compatibility");
123 SDL_UIKit_UpdateBatteryMonitoring();
126 [context.sdlView swapBuffers];
140 SDL_uikitopenglview *view;
143 EAGLSharegroup *sharegroup = nil;
151 EAGLRenderingAPI api = major;
156 SDL_SetError(
"OpenGL ES %d.%d context could not be created", major, minor);
166 sharegroup =
context.sharegroup;
173 if ([
data.uiwindow.screen respondsToSelector:
@selector(nativeScale)]) {
174 scale =
data.uiwindow.screen.nativeScale;
180 context = [[SDLEAGLContext alloc] initWithAPI:api sharegroup:sharegroup];
187 view = [[SDL_uikitopenglview alloc] initWithFrame:frame
189 retainBacking:_this->gl_config.retained_backing
190 rBits:_this->gl_config.red_size
191 gBits:_this->gl_config.green_size
192 bBits:_this->gl_config.blue_size
193 aBits:_this->gl_config.alpha_size
194 depthBits:_this->gl_config.depth_size
195 stencilBits:_this->gl_config.stencil_size
196 sRGB:_this->gl_config.framebuffer_srgb_capable
230 UIKit_GL_RestoreCurrentContext(
void)
242 [EAGLContext setCurrentContext:context];