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