1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GLCANVAS_H_
13 #define _WX_GLCANVAS_H_
15 #ifdef __WXOSX_IPHONE__
16 #import <OpenGLES/ES1/gl.h>
17 #import <OpenGLES/ES1/glext.h>
19 #include <OpenGL/gl.h>
24 WXDLLIMPEXP_GL WXGLContext
WXGLCreateContext( WXGLPixelFormat pixelFormat
, WXGLContext shareContext
);
25 WXDLLIMPEXP_GL
void WXGLDestroyContext( WXGLContext context
);
26 WXDLLIMPEXP_GL WXGLContext
WXGLGetCurrentContext();
27 WXDLLIMPEXP_GL
void WXGLSwapBuffers( WXGLContext context
);
29 WXDLLIMPEXP_GL WXGLPixelFormat
WXGLChoosePixelFormat(const int *attribList
);
30 WXDLLIMPEXP_GL
void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat
);
32 class WXDLLIMPEXP_GL wxGLContext
: public wxGLContextBase
35 wxGLContext(wxGLCanvas
*win
, const wxGLContext
*other
= NULL
);
36 virtual ~wxGLContext();
38 virtual bool SetCurrent(const wxGLCanvas
& win
) const;
41 WXGLContext
GetWXGLContext() const { return m_glContext
; }
44 WXGLContext m_glContext
;
46 wxDECLARE_NO_COPY_CLASS(wxGLContext
);
49 class WXDLLIMPEXP_GL wxGLCanvas
: public wxGLCanvasBase
52 wxGLCanvas(wxWindow
*parent
,
53 wxWindowID id
= wxID_ANY
,
54 const int *attribList
= NULL
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
58 const wxString
& name
= wxGLCanvasName
,
59 const wxPalette
& palette
= wxNullPalette
);
61 bool Create(wxWindow
*parent
,
62 wxWindowID id
= wxID_ANY
,
63 const wxPoint
& pos
= wxDefaultPosition
,
64 const wxSize
& size
= wxDefaultSize
,
66 const wxString
& name
= wxGLCanvasName
,
67 const int *attribList
= NULL
,
68 const wxPalette
& palette
= wxNullPalette
);
70 virtual ~wxGLCanvas();
72 // implement wxGLCanvasBase methods
73 virtual bool SwapBuffers();
76 // Mac-specific functions
77 // ----------------------
79 // return true if multisample extension is supported
80 static bool IsAGLMultiSampleAvailable();
82 // return the pixel format used by this window
83 WXGLPixelFormat
GetWXGLPixelFormat() const { return m_glFormat
; }
85 // update the view port of the current context to match this window
92 #if WXWIN_COMPATIBILITY_2_8
94 wxGLCanvas(wxWindow
*parent
,
95 wxWindowID id
= wxID_ANY
,
96 const wxPoint
& pos
= wxDefaultPosition
,
97 const wxSize
& size
= wxDefaultSize
,
99 const wxString
& name
= wxGLCanvasName
,
100 const int *attribList
= NULL
,
101 const wxPalette
& palette
= wxNullPalette
)
105 wxGLCanvas(wxWindow
*parent
,
106 const wxGLContext
*shared
,
107 wxWindowID id
= wxID_ANY
,
108 const wxPoint
& pos
= wxDefaultPosition
,
109 const wxSize
& size
= wxDefaultSize
,
111 const wxString
& name
= wxGLCanvasName
,
112 const int *attribList
= NULL
,
113 const wxPalette
& palette
= wxNullPalette
)
117 wxGLCanvas(wxWindow
*parent
,
118 const wxGLCanvas
*shared
,
119 wxWindowID id
= wxID_ANY
,
120 const wxPoint
& pos
= wxDefaultPosition
,
121 const wxSize
& size
= wxDefaultSize
,
123 const wxString
& name
= wxGLCanvasName
,
124 const int *attribList
= NULL
,
125 const wxPalette
& palette
= wxNullPalette
)
127 #endif // WXWIN_COMPATIBILITY_2_8
129 // implementation-only from now on
132 // Unlike some other platforms, this must get called if you override it,
133 // i.e. don't forget "event.Skip()" in your EVT_SIZE handler
134 void OnSize(wxSizeEvent
& event
);
136 virtual void MacSuperChangedPosition();
137 virtual void MacTopLevelWindowChangedPosition();
138 virtual void MacVisibilityChanged();
140 void MacUpdateView();
142 GLint
GetAglBufferName() const { return m_bufferName
; }
146 WXGLPixelFormat m_glFormat
;
149 bool m_macCanvasIsShown
,
151 WXGLContext m_dummyContext
;
155 DECLARE_EVENT_TABLE()
156 DECLARE_CLASS(wxGLCanvas
)
159 #endif // _WX_GLCANVAS_H_