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 95145b56ab9ff5fe
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
     1.1 --- a/include/SDL_system.h	Thu Aug 07 00:44:16 2014 -0300
     1.2 +++ b/include/SDL_system.h	Fri Aug 08 15:14:09 2014 -0300
     1.3 @@ -70,6 +70,16 @@
     1.4  extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
     1.5  extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
     1.6  
     1.7 +/* Returns the OpenGL Renderbuffer Object associated with the window's main view.
     1.8 +   The Renderbuffer must be bound when calling SDL_GL_SwapWindow.
     1.9 + */
    1.10 +extern DECLSPEC Uint32 SDLCALL SDL_iPhoneGetViewRenderbuffer(SDL_Window * window);
    1.11 +
    1.12 +/* Returns the OpenGL Framebuffer Object associated with the window's main view.
    1.13 +   The Framebuffer must be bound when rendering to the screen.
    1.14 + */
    1.15 +extern DECLSPEC Uint32 SDLCALL SDL_iPhoneGetViewFramebuffer(SDL_Window * window);
    1.16 +
    1.17  #endif /* __IPHONEOS__ */
    1.18  
    1.19  
     2.1 --- a/src/video/uikit/SDL_uikitopengles.m	Thu Aug 07 00:44:16 2014 -0300
     2.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Fri Aug 08 15:14:09 2014 -0300
     2.3 @@ -210,6 +210,40 @@
     2.4      }
     2.5  }
     2.6  
     2.7 +Uint32 SDL_iPhoneGetViewRenderbuffer(SDL_Window * window)
     2.8 +{
     2.9 +    if (!window) {
    2.10 +        SDL_SetError("Invalid window");
    2.11 +        return 0;
    2.12 +    }
    2.13 +
    2.14 +    @autoreleasepool {
    2.15 +        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
    2.16 +        if (data.view != nil) {
    2.17 +            return data.view.drawableRenderbuffer;
    2.18 +        } else {
    2.19 +            return 0;
    2.20 +        }
    2.21 +    }
    2.22 +}
    2.23 +
    2.24 +Uint32 SDL_iPhoneGetViewFramebuffer(SDL_Window * window)
    2.25 +{
    2.26 +    if (!window) {
    2.27 +        SDL_SetError("Invalid window");
    2.28 +        return 0;
    2.29 +    }
    2.30 +
    2.31 +    @autoreleasepool {
    2.32 +        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
    2.33 +        if (data.view != nil) {
    2.34 +            return data.view.drawableFramebuffer;
    2.35 +        } else {
    2.36 +            return 0;
    2.37 +        }
    2.38 +    }
    2.39 +}
    2.40 +
    2.41  #endif /* SDL_VIDEO_DRIVER_UIKIT */
    2.42  
    2.43  /* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/video/uikit/SDL_uikitopenglview.h	Thu Aug 07 00:44:16 2014 -0300
     3.2 +++ b/src/video/uikit/SDL_uikitopenglview.h	Fri Aug 08 15:14:09 2014 -0300
     3.3 @@ -50,6 +50,9 @@
     3.4  @property (nonatomic, readonly) int backingWidth;
     3.5  @property (nonatomic, readonly) int backingHeight;
     3.6  
     3.7 +@property (nonatomic, readonly) GLuint drawableRenderbuffer;
     3.8 +@property (nonatomic, readonly) GLuint drawableFramebuffer;
     3.9 +
    3.10  - (void)swapBuffers;
    3.11  - (void)setCurrentContext;
    3.12  
     4.1 --- a/src/video/uikit/SDL_uikitopenglview.m	Thu Aug 07 00:44:16 2014 -0300
     4.2 +++ b/src/video/uikit/SDL_uikitopenglview.m	Fri Aug 08 15:14:09 2014 -0300
     4.3 @@ -162,6 +162,16 @@
     4.4      return self;
     4.5  }
     4.6  
     4.7 +- (GLuint)drawableRenderbuffer
     4.8 +{
     4.9 +    return viewRenderbuffer;
    4.10 +}
    4.11 +
    4.12 +- (GLuint)drawableFramebuffer
    4.13 +{
    4.14 +    return viewFramebuffer;
    4.15 +}
    4.16 +
    4.17  - (void)updateFrame
    4.18  {
    4.19      glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);