X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03647350fc7cd141953c72e0284e928847d30f44..ab67e8874db324fab5223cc8d5dff8a8de3e2b77:/src/osx/cocoa/glcanvas.mm diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 4c5f6ec1e5..f9ff2a81bf 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -4,7 +4,7 @@ // 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 /////////////////////////////////////////////////////////////////////////////// @@ -39,7 +39,9 @@ WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareCon { WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext]; if ( !context ) + { wxFAIL_MSG("NSOpenGLContext creation failed"); + } return context ; } @@ -187,7 +189,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) if ( !attribList[arg++] ) break; - return false; + return nil; } data[p++] = NSOpenGLPFASampleBuffers; @@ -204,7 +206,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) if ( !attribList[arg++] ) break; - return false; + return nil; } data[p++] = NSOpenGLPFASamples; @@ -221,19 +223,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; @@ -273,8 +262,8 @@ bool wxGLCanvas::Create(wxWindow *parent, if ( !m_glFormat ) return false; - // m_macIsUserPane = false ; - + // DontCreatePeer(); + if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return false; @@ -294,5 +283,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