X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4850cc8b2e1037cd394806db4ddcf73868588a4c..eda34276d67de1578a3ed3d727b595b1858a8547:/src/osx/cocoa/glcanvas.mm diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 4e6654452c..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,54 +221,23 @@ 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 { - wxWidgetCocoaImpl* impl; NSOpenGLContext* context; } -- (id)initWithFrame:(NSRect)frame; -- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation; -- (wxWidgetCocoaImpl*) implementation; -- (BOOL) isFlipped; - @end @implementation wxNSCustomOpenGLView -- (id)initWithFrame:(NSRect)frame -{ - [super initWithFrame:frame]; - impl = NULL; - return self; -} - -- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation -{ - impl = theImplementation; -} - -- (wxWidgetCocoaImpl*) implementation ++ (void)initialize { - return impl; -} - -- (BOOL) isFlipped -{ - return YES; + static BOOL initialized = NO; + if (!initialized) + { + initialized = YES; + wxOSXCocoaClassAddWXMethods( self ); + } } - (BOOL)isOpaque @@ -293,7 +269,6 @@ bool wxGLCanvas::Create(wxWindow *parent, NSRect r = wxOSXGetFrameForControl( this, pos , size ) ; wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r]; m_peer = new wxWidgetCocoaImpl( this, v ); - [v setImplementation:m_peer]; MacPostControlCreate(pos, size) ; */ @@ -306,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