]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/glcanvas.mm
Fix referencing of cairo_t returned from wxDCImpl::GetCairoContext().
[wxWidgets.git] / src / cocoa / glcanvas.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/glcanvas.mm
3 // Purpose: wxGLContext, wxGLCanvas
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2004/09/29
7 // Copyright: (c) 2004 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #if wxUSE_GLCANVAS
14
15 #ifndef WX_PRECOMP
16 #include "wx/app.h"
17 #endif //WX_PRECOMP
18 #include "wx/glcanvas.h"
19
20 #include "wx/cocoa/autorelease.h"
21
22 #import <AppKit/NSOpenGL.h>
23 #import <AppKit/NSOpenGLView.h>
24
25 wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other)
26 {
27 // TODO
28 }
29
30 wxGLContext::~wxGLContext()
31 {
32 }
33
34 void wxGLContext::SetCurrent(const wxGLCanvas& win) const
35 {
36 [[win.GetNSOpenGLView() openGLContext] makeCurrentContext];
37 }
38
39 IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
40 // WX_IMPLEMENT_COCOA_OWNER(wxGLCanvas,NSOpenGLView,NSView,NSView)
41
42 bool wxGLCanvas::Create(wxWindow *parent,
43 wxWindowID winid,
44 const wxPoint& pos,
45 const wxSize& size,
46 long style,
47 const wxString& name,
48 const int *attribList,
49 const wxPalette& palette)
50 {
51 wxAutoNSAutoreleasePool pool;
52 if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
53 return false;
54 SetNSView([[NSOpenGLView alloc] initWithFrame: MakeDefaultNSRect(size)
55 pixelFormat:[NSOpenGLView defaultPixelFormat]]);
56 [m_cocoaNSView release];
57 if(m_parent)
58 m_parent->CocoaAddChild(this);
59 SetInitialFrameRect(pos,size);
60
61 return true;
62 }
63
64 wxGLCanvas::~wxGLCanvas()
65 {
66 }
67
68 void wxGLCanvas::SwapBuffers()
69 {
70 [[GetNSOpenGLView() openGLContext] flushBuffer];
71 }
72
73 #endif // wxUSE_GLCANVAS