Added framebuffer and colorbuffer members to the uikit portion of the SDL_SysWMinfo struct, removed SDL_iOSGetViewRenderbuffer and SDL_iOSGetViewFramebuffer. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Thu, 09 Apr 2015 19:28:00 -0300
branchiOS-improvements
changeset 9540 32ddc92d78cf
parent 9539 ea3513fe64a0
child 9541 cf8fab52e33b
child 9542 618662dc9e82
Added framebuffer and colorbuffer members to the uikit portion of the SDL_SysWMinfo struct, removed SDL_iOSGetViewRenderbuffer and SDL_iOSGetViewFramebuffer.
include/SDL_system.h
include/SDL_syswm.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/video/uikit/SDL_uikitopengles.m
src/video/uikit/SDL_uikitwindow.m
--- a/include/SDL_system.h	Wed Apr 08 15:59:29 2015 -0300
+++ b/include/SDL_system.h	Thu Apr 09 19:28:00 2015 -0300
@@ -79,20 +79,6 @@
 #define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
 extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
 
-/**
-   \brief Returns the OpenGL Renderbuffer Object associated with the window's main view.
-
-   The Renderbuffer must be bound when calling SDL_GL_SwapWindow.
- */
-extern DECLSPEC Uint32 SDLCALL SDL_iOSGetViewRenderbuffer(SDL_Window * window);
-
-/**
-   \brief Returns the OpenGL Framebuffer Object associated with the window's main view.
-
-   The Framebuffer must be bound when rendering to the screen.
- */
-extern DECLSPEC Uint32 SDLCALL SDL_iOSGetViewFramebuffer(SDL_Window * window);
-
 #endif /* __IPHONEOS__ */
 
 
--- a/include/SDL_syswm.h	Wed Apr 08 15:59:29 2015 -0300
+++ b/include/SDL_syswm.h	Thu Apr 09 19:28:00 2015 -0300
@@ -98,6 +98,7 @@
 typedef struct _UIWindow UIWindow;
 typedef struct _UIViewController UIViewController;
 #endif
+typedef Uint32 GLuint;
 #endif
 
 #if defined(SDL_VIDEO_DRIVER_ANDROID)
@@ -228,6 +229,8 @@
 #else
             UIWindow *window;                     /* The UIKit window */
 #endif
+            GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
+            GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
         } uikit;
 #endif
 #if defined(SDL_VIDEO_DRIVER_WAYLAND)
--- a/src/dynapi/SDL_dynapi_overrides.h	Wed Apr 08 15:59:29 2015 -0300
+++ b/src/dynapi/SDL_dynapi_overrides.h	Thu Apr 09 19:28:00 2015 -0300
@@ -592,5 +592,3 @@
 #define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL
 #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
 #define SDL_GetGrabbedWindow SDL_GetGrabbedWindow_REAL
-#define SDL_iOSGetViewRenderbuffer SDL_iOSGetViewRenderbuffer_REAL
-#define SDL_iOSGetViewFramebuffer SDL_iOSGetViewFramebuffer_REAL
--- a/src/dynapi/SDL_dynapi_procs.h	Wed Apr 08 15:59:29 2015 -0300
+++ b/src/dynapi/SDL_dynapi_procs.h	Thu Apr 09 19:28:00 2015 -0300
@@ -624,7 +624,3 @@
 SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return)
 SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
 SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
-#if defined(__IPHONEOS__) && __IPHONEOS__
-SDL_DYNAPI_PROC(Uint32,SDL_iOSGetViewRenderbuffer,(SDL_Window *a),(a),return)
-SDL_DYNAPI_PROC(Uint32,SDL_iOSGetViewFramebuffer,(SDL_Window *a),(a),return)
-#endif
--- a/src/video/uikit/SDL_uikitopengles.m	Wed Apr 08 15:59:29 2015 -0300
+++ b/src/video/uikit/SDL_uikitopengles.m	Thu Apr 09 19:28:00 2015 -0300
@@ -183,48 +183,6 @@
     }
 }
 
-Uint32
-SDL_iOSGetViewRenderbuffer(SDL_Window * window)
-{
-    if (!window) {
-        SDL_SetError("Invalid window");
-        return 0;
-    }
-
-    @autoreleasepool {
-        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
-        UIView *view = data.viewcontroller.view;
-        if ([view isKindOfClass:[SDL_uikitopenglview class]]) {
-            SDL_uikitopenglview *glview = (SDL_uikitopenglview *) view;
-            return glview.drawableRenderbuffer;
-        }
-    }
-
-    SDL_SetError("Window does not have an attached OpenGL view");
-    return 0;
-}
-
-Uint32
-SDL_iOSGetViewFramebuffer(SDL_Window * window)
-{
-    if (!window) {
-        SDL_SetError("Invalid window");
-        return 0;
-    }
-
-    @autoreleasepool {
-        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
-        UIView *view = data.viewcontroller.view;
-        if ([view isKindOfClass:[SDL_uikitopenglview class]]) {
-            SDL_uikitopenglview *glview = (SDL_uikitopenglview *) view;
-            return glview.drawableFramebuffer;
-        }
-    }
-
-    SDL_SetError("Window does not have an attached OpenGL view");
-    return 0;
-}
-
 #endif /* SDL_VIDEO_DRIVER_UIKIT */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitwindow.m	Wed Apr 08 15:59:29 2015 -0300
+++ b/src/video/uikit/SDL_uikitwindow.m	Thu Apr 09 19:28:00 2015 -0300
@@ -38,6 +38,7 @@
 #import "SDL_uikitappdelegate.h"
 
 #import "SDL_uikitview.h"
+#import "SDL_uikitopenglview.h"
 
 #include <Foundation/Foundation.h>
 
@@ -314,8 +315,23 @@
         SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
 
         if (info->version.major <= SDL_MAJOR_VERSION) {
+            int versionnum = SDL_VERSIONNUM(info->version.major, info->version.minor, info->version.patch);
+
             info->subsystem = SDL_SYSWM_UIKIT;
             info->info.uikit.window = data.uiwindow;
+
+            /* These struct members were added in SDL 2.0.4. */
+            if (versionnum >= SDL_VERSIONNUM(2,0,4)) {
+                if ([data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview class]]) {
+                    SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.viewcontroller.view;
+                    info->info.uikit.framebuffer = glview.drawableFramebuffer;
+                    info->info.uikit.colorbuffer = glview.drawableRenderbuffer;
+                } else {
+                    info->info.uikit.framebuffer = 0;
+                    info->info.uikit.colorbuffer = 0;
+                }
+            }
+
             return SDL_TRUE;
         } else {
             SDL_SetError("Application not compiled with SDL %d.%d\n",