]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/glcanvas.mm
Disable some wxWebView tests that fail on the buildbot but not locally.
[wxWidgets.git] / src / osx / cocoa / glcanvas.mm
index e088ede061fa7e95f27632a927dfcf52364b93d6..863bd8bf28aabd6ee208b274620ad3e77d5de57f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     1998-01-01
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     1998-01-01
-// RCS-ID:      $Id: glcanvas.cpp 54129 2008-06-11 19:30:52Z SC $
+// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) Stefan Csomor
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -61,6 +61,13 @@ WXGLContext WXGLGetCurrentContext()
     return [NSOpenGLContext currentContext];
 }
 
     return [NSOpenGLContext currentContext];
 }
 
+bool WXGLSetCurrentContext(WXGLContext context)
+{
+    [context makeCurrentContext];
+
+    return true;
+}
+
 void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat )
 {
     if ( pixelFormat )
 void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat )
 {
     if ( pixelFormat )
@@ -180,7 +187,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
                         if ( !attribList[arg++] )
                             break;
 
                         if ( !attribList[arg++] )
                             break;
 
-                        return false;
+                        return nil;
                     }
 
                     data[p++] = NSOpenGLPFASampleBuffers;
                     }
 
                     data[p++] = NSOpenGLPFASampleBuffers;
@@ -197,7 +204,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
                         if ( !attribList[arg++] )
                             break;
 
                         if ( !attribList[arg++] )
                             break;
 
-                        return false;
+                        return nil;
                     }
 
                     data[p++] = NSOpenGLPFASamples;
                     }
 
                     data[p++] = NSOpenGLPFASamples;
@@ -214,42 +221,25 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
     return [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*) attribs];
 }
 
     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
 {
 @interface wxNSCustomOpenGLView : NSView
 {
-    WXCOCOAIMPL_COMMON_MEMBERS
     NSOpenGLContext* context;
 }
 
     NSOpenGLContext* context;
 }
 
-- (id)initWithFrame:(NSRect)frame;
-
-WXCOCOAIMPL_COMMON_INTERFACE
-
 @end
 
 @implementation wxNSCustomOpenGLView
 
 @end
 
 @implementation wxNSCustomOpenGLView
 
-- (id)initWithFrame:(NSRect)frame
++ (void)initialize
 {
 {
-    [super initWithFrame:frame];
-    impl = NULL;
-    return self;
+    static BOOL initialized = NO;
+    if (!initialized)
+    {
+        initialized = YES;
+        wxOSXCocoaClassAddWXMethods( self );
+    }
 }
 
 }
 
-WXCOCOAIMPL_COMMON_IMPLEMENTATION
-
 - (BOOL)isOpaque
 {
     return YES;
 - (BOOL)isOpaque
 {
     return YES;
@@ -270,8 +260,8 @@ bool wxGLCanvas::Create(wxWindow *parent,
     if ( !m_glFormat )
         return false;
 
     if ( !m_glFormat )
         return false;
 
-   // m_macIsUserPane = false ;
-
+    // DontCreatePeer();
+    
     if ( !wxWindow::Create(parent, id, pos, size, style, name) )
         return false;
 
     if ( !wxWindow::Create(parent, id, pos, size, style, name) )
         return false;
 
@@ -279,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 );
     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) ;
 */
 
     MacPostControlCreate(pos, size) ;
 */
@@ -292,5 +281,27 @@ wxGLCanvas::~wxGLCanvas()
         WXGLDestroyPixelFormat(m_glFormat);
 }
 
         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
 
 #endif // wxUSE_GLCANVAS