// 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
///////////////////////////////////////////////////////////////////////////////
{
WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext];
if ( !context )
+ {
wxFAIL_MSG("NSOpenGLContext creation failed");
+ }
return context ;
}
if ( !attribList[arg++] )
break;
- return false;
+ return nil;
}
data[p++] = NSOpenGLPFASampleBuffers;
if ( !attribList[arg++] )
break;
- return false;
+ return nil;
}
data[p++] = NSOpenGLPFASamples;
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;
+ (void)initialize
{
static BOOL initialized = NO;
- if (!initialized)
+ if (!initialized)
{
initialized = YES;
wxOSXCocoaClassAddWXMethods( self );
if ( !m_glFormat )
return false;
- // m_macIsUserPane = false ;
-
+ // DontCreatePeer();
+
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
return false;
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