X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4dd9fdf82749bb5f9e2bf9c2ad1bbd59e0eeb00e..33820d94285c0004acce756e7d10d9698e6387d1:/src/osx/cocoa/glcanvas.mm?ds=sidebyside diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 83c99ce833..bebcdcefdb 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -61,6 +61,13 @@ WXGLContext WXGLGetCurrentContext() return [NSOpenGLContext currentContext]; } +bool WXGLSetCurrentContext(WXGLContext context) +{ + [context makeCurrentContext]; + + return true; +} + void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat ) { if ( pixelFormat ) @@ -214,19 +221,6 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) return [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*) attribs]; } -bool wxGLContext::SetCurrent(const wxGLCanvas& win) const -{ - if ( !m_glContext ) - return false; - - [m_glContext setView: win.GetHandle() ]; - [m_glContext update]; - - [m_glContext makeCurrentContext]; - - return true; -} - @interface wxNSCustomOpenGLView : NSView { NSOpenGLContext* context; @@ -239,7 +233,7 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const + (void)initialize { static BOOL initialized = NO; - if (!initialized) + if (!initialized) { initialized = YES; wxOSXCocoaClassAddWXMethods( self ); @@ -287,5 +281,27 @@ wxGLCanvas::~wxGLCanvas() WXGLDestroyPixelFormat(m_glFormat); } +bool wxGLCanvas::SwapBuffers() +{ + WXGLContext context = WXGLGetCurrentContext(); + wxCHECK_MSG(context, false, wxT("should have current context")); + + [context flushBuffer]; + + return true; +} + +bool wxGLContext::SetCurrent(const wxGLCanvas& win) const +{ + if ( !m_glContext ) + return false; + + [m_glContext setView: win.GetHandle() ]; + [m_glContext update]; + + [m_glContext makeCurrentContext]; + + return true; +} #endif // wxUSE_GLCANVAS