Added iOS-specific functions to get the window view's current OpenGL Renderbuffer and Framebuffer objects, so they can be more easily rebound when necessary. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Fri, 08 Aug 2014 15:14:09 -0300
branchiOS-improvements
changeset 9514 5b56ab9ff5fe
parent 9513 34d9391e7d3e
child 9515 63f5d07c7d70
Added iOS-specific functions to get the window view's current OpenGL Renderbuffer and Framebuffer objects, so they can be more easily rebound when necessary.
include/SDL_system.h
src/video/uikit/SDL_uikitopengles.m
src/video/uikit/SDL_uikitopenglview.h
src/video/uikit/SDL_uikitopenglview.m
--- a/include/SDL_system.h	Thu Aug 07 00:44:16 2014 -0300
+++ b/include/SDL_system.h	Fri Aug 08 15:14:09 2014 -0300
@@ -70,6 +70,16 @@
 extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
 extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
 
+/* 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_iPhoneGetViewRenderbuffer(SDL_Window * window);
+
+/* 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_iPhoneGetViewFramebuffer(SDL_Window * window);
+
 #endif /* __IPHONEOS__ */
 
 
--- a/src/video/uikit/SDL_uikitopengles.m	Thu Aug 07 00:44:16 2014 -0300
+++ b/src/video/uikit/SDL_uikitopengles.m	Fri Aug 08 15:14:09 2014 -0300
@@ -210,6 +210,40 @@
     }
 }
 
+Uint32 SDL_iPhoneGetViewRenderbuffer(SDL_Window * window)
+{
+    if (!window) {
+        SDL_SetError("Invalid window");
+        return 0;
+    }
+
+    @autoreleasepool {
+        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
+        if (data.view != nil) {
+            return data.view.drawableRenderbuffer;
+        } else {
+            return 0;
+        }
+    }
+}
+
+Uint32 SDL_iPhoneGetViewFramebuffer(SDL_Window * window)
+{
+    if (!window) {
+        SDL_SetError("Invalid window");
+        return 0;
+    }
+
+    @autoreleasepool {
+        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
+        if (data.view != nil) {
+            return data.view.drawableFramebuffer;
+        } else {
+            return 0;
+        }
+    }
+}
+
 #endif /* SDL_VIDEO_DRIVER_UIKIT */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitopenglview.h	Thu Aug 07 00:44:16 2014 -0300
+++ b/src/video/uikit/SDL_uikitopenglview.h	Fri Aug 08 15:14:09 2014 -0300
@@ -50,6 +50,9 @@
 @property (nonatomic, readonly) int backingWidth;
 @property (nonatomic, readonly) int backingHeight;
 
+@property (nonatomic, readonly) GLuint drawableRenderbuffer;
+@property (nonatomic, readonly) GLuint drawableFramebuffer;
+
 - (void)swapBuffers;
 - (void)setCurrentContext;
 
--- a/src/video/uikit/SDL_uikitopenglview.m	Thu Aug 07 00:44:16 2014 -0300
+++ b/src/video/uikit/SDL_uikitopenglview.m	Fri Aug 08 15:14:09 2014 -0300
@@ -162,6 +162,16 @@
     return self;
 }
 
+- (GLuint)drawableRenderbuffer
+{
+    return viewRenderbuffer;
+}
+
+- (GLuint)drawableFramebuffer
+{
+    return viewFramebuffer;
+}
+
 - (void)updateFrame
 {
     glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);