]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/glcanvas.mm
Misc XRC format docs corrections.
[wxWidgets.git] / src / cocoa / glcanvas.mm
CommitLineData
bd2af428 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/cocoa/glcanvas.mm
bd2af428
DE
3// Purpose: wxGLContext, wxGLCanvas
4// Author: David Elliott
5// Modified by:
6// Created: 2004/09/29
bd2af428 7// Copyright: (c) 2004 David Elliott
526954c5 8// Licence: wxWindows licence
bd2af428
DE
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
dc3065a5 25wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other)
ce0c732e 26{
dc3065a5 27 // TODO
ce0c732e
VZ
28}
29
dc3065a5 30wxGLContext::~wxGLContext()
bd2af428 31{
bd2af428
DE
32}
33
dc3065a5 34void wxGLContext::SetCurrent(const wxGLCanvas& win) const
bd2af428 35{
dc3065a5 36 [[win.GetNSOpenGLView() openGLContext] makeCurrentContext];
bd2af428
DE
37}
38
dc3065a5
VZ
39IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
40// WX_IMPLEMENT_COCOA_OWNER(wxGLCanvas,NSOpenGLView,NSView,NSView)
41
42bool 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)
bd2af428
DE
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
64wxGLCanvas::~wxGLCanvas()
65{
66}
67
bd2af428
DE
68void wxGLCanvas::SwapBuffers()
69{
dc3065a5 70 [[GetNSOpenGLView() openGLContext] flushBuffer];
bd2af428
DE
71}
72
73#endif // wxUSE_GLCANVAS