]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/glcanvas.mm
Fix wrong tab order in wxAuiNotebook after dragging.
[wxWidgets.git] / src / osx / cocoa / glcanvas.mm
index 83c99ce833f7778d1ac7b66bd9fbf8287ce8c455..f9ff2a81bff03c08302115f3a4af2d9f5d367235 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
 ///////////////////////////////////////////////////////////////////////////////
@@ -39,7 +39,9 @@ WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareCon
 {
     WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext];
     if ( !context )
 {
     WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext];
     if ( !context )
+    {
         wxFAIL_MSG("NSOpenGLContext creation failed");
         wxFAIL_MSG("NSOpenGLContext creation failed");
+    }
     return context ;
 }
 
     return context ;
 }
 
@@ -61,6 +63,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 +189,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 +206,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,19 +223,6 @@ 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
 {
     NSOpenGLContext* context;
 @interface wxNSCustomOpenGLView : NSView
 {
     NSOpenGLContext* context;
@@ -239,7 +235,7 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
 + (void)initialize
 {
     static BOOL initialized = NO;
 + (void)initialize
 {
     static BOOL initialized = NO;
-    if (!initialized) 
+    if (!initialized)
     {
         initialized = YES;
         wxOSXCocoaClassAddWXMethods( self );
     {
         initialized = YES;
         wxOSXCocoaClassAddWXMethods( self );
@@ -266,8 +262,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;
 
@@ -287,5 +283,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