Skip to content

Commit

Permalink
Added iOS-specific functions to get the window view's current OpenGL …
Browse files Browse the repository at this point in the history
…Renderbuffer and Framebuffer objects, so they can be more easily rebound when necessary.
  • Loading branch information
slime73 committed Aug 8, 2014
1 parent 2dac6bf commit deceab2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/SDL_system.h
Expand Up @@ -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__ */


Expand Down
34 changes: 34 additions & 0 deletions src/video/uikit/SDL_uikitopengles.m
Expand Up @@ -210,6 +210,40 @@ void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
}
}

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: */
3 changes: 3 additions & 0 deletions src/video/uikit/SDL_uikitopenglview.h
Expand Up @@ -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;

Expand Down
10 changes: 10 additions & 0 deletions src/video/uikit/SDL_uikitopenglview.m
Expand Up @@ -162,6 +162,16 @@ - (id)initWithFrame:(CGRect)frame
return self;
}

- (GLuint)drawableRenderbuffer
{
return viewRenderbuffer;
}

- (GLuint)drawableFramebuffer
{
return viewFramebuffer;
}

- (void)updateFrame
{
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
Expand Down

0 comments on commit deceab2

Please sign in to comment.