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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/include/SDL_system.h b/include/SDL_system.h
index 78d5b0d..8184e59 100644
--- a/include/SDL_system.h
+++ b/include/SDL_system.h
@@ -70,6 +70,16 @@ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *a
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__ */
diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m
index 7d82809..378099d 100644
--- a/src/video/uikit/SDL_uikitopengles.m
+++ b/src/video/uikit/SDL_uikitopengles.m
@@ -210,6 +210,40 @@ UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
}
}
+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: */
diff --git a/src/video/uikit/SDL_uikitopenglview.h b/src/video/uikit/SDL_uikitopenglview.h
index 9bb8f0c..b232c53 100644
--- a/src/video/uikit/SDL_uikitopenglview.h
+++ b/src/video/uikit/SDL_uikitopenglview.h
@@ -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;
diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m
index da724dc..4b93ab6 100644
--- a/src/video/uikit/SDL_uikitopenglview.m
+++ b/src/video/uikit/SDL_uikitopenglview.m
@@ -162,6 +162,16 @@
return self;
}
+- (GLuint)drawableRenderbuffer
+{
+ return viewRenderbuffer;
+}
+
+- (GLuint)drawableFramebuffer
+{
+ return viewFramebuffer;
+}
+
- (void)updateFrame
{
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);