1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/glcanvas.mm
3 // Purpose: wxGLContext, wxGLCanvas
4 // Author: David Elliott
8 // Copyright: (c) 2004 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
19 #include "wx/glcanvas.h"
21 #include "wx/cocoa/autorelease.h"
23 #import <AppKit/NSOpenGL.h>
24 #import <AppKit/NSOpenGLView.h>
26 wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other)
31 wxGLContext::~wxGLContext()
35 void wxGLContext::SetCurrent(const wxGLCanvas& win) const
37 [[win.GetNSOpenGLView() openGLContext] makeCurrentContext];
40 IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
41 // WX_IMPLEMENT_COCOA_OWNER(wxGLCanvas,NSOpenGLView,NSView,NSView)
43 bool wxGLCanvas::Create(wxWindow *parent,
49 const int *attribList,
50 const wxPalette& palette)
52 wxAutoNSAutoreleasePool pool;
53 if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
55 SetNSView([[NSOpenGLView alloc] initWithFrame: MakeDefaultNSRect(size)
56 pixelFormat:[NSOpenGLView defaultPixelFormat]]);
57 [m_cocoaNSView release];
59 m_parent->CocoaAddChild(this);
60 SetInitialFrameRect(pos,size);
65 wxGLCanvas::~wxGLCanvas()
69 void wxGLCanvas::SwapBuffers()
71 [[GetNSOpenGLView() openGLContext] flushBuffer];
74 #endif // wxUSE_GLCANVAS