return [NSOpenGLContext currentContext];
}
+bool WXGLSetCurrentContext(WXGLContext context)
+{
+ [context makeCurrentContext];
+
+ return true;
+}
+
void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat )
{
if ( pixelFormat )
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
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) ;
*/
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