1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/glcanvas.mm
3 // Purpose: wxGLContext, wxGLCanvas
4 // Author: David Elliott
7 // Copyright: (c) 2004 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
18 #include "wx/glcanvas.h"
20 #include "wx/cocoa/autorelease.h"
22 #import <AppKit/NSOpenGL.h>
23 #import <AppKit/NSOpenGLView.h>
25 wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other)
30 wxGLContext::~wxGLContext()
34 void wxGLContext::SetCurrent(const wxGLCanvas& win) const
36 [[win.GetNSOpenGLView() openGLContext] makeCurrentContext];
39 IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
40 // WX_IMPLEMENT_COCOA_OWNER(wxGLCanvas,NSOpenGLView,NSView,NSView)
42 bool wxGLCanvas::Create(wxWindow *parent,
48 const int *attribList,
49 const wxPalette& palette)
51 wxAutoNSAutoreleasePool pool;
52 if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
54 SetNSView([[NSOpenGLView alloc] initWithFrame: MakeDefaultNSRect(size)
55 pixelFormat:[NSOpenGLView defaultPixelFormat]]);
56 [m_cocoaNSView release];
58 m_parent->CocoaAddChild(this);
59 SetInitialFrameRect(pos,size);
64 wxGLCanvas::~wxGLCanvas()
68 void wxGLCanvas::SwapBuffers()
70 [[GetNSOpenGLView() openGLContext] flushBuffer];
73 #endif // wxUSE_GLCANVAS