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
bool WXGLSetCurrentContext(WXGLContext context
);
28 WXDLLIMPEXP_GL
void WXGLSwapBuffers( WXGLContext context
);
30 WXDLLIMPEXP_GL WXGLPixelFormat
WXGLChoosePixelFormat(const int *attribList
);
31 WXDLLIMPEXP_GL
void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat
);
33 class WXDLLIMPEXP_GL wxGLContext
: public wxGLContextBase
36 wxGLContext(wxGLCanvas
*win
, const wxGLContext
*other
= NULL
);
37 virtual ~wxGLContext();
39 virtual bool SetCurrent(const wxGLCanvas
& win
) const;
42 WXGLContext
GetWXGLContext() const { return m_glContext
; }
45 WXGLContext m_glContext
;
47 wxDECLARE_NO_COPY_CLASS(wxGLContext
);
50 class WXDLLIMPEXP_GL wxGLCanvas
: public wxGLCanvasBase
53 wxGLCanvas(wxWindow
*parent
,
54 wxWindowID id
= wxID_ANY
,
55 const int *attribList
= NULL
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
59 const wxString
& name
= wxGLCanvasName
,
60 const wxPalette
& palette
= wxNullPalette
);
62 bool Create(wxWindow
*parent
,
63 wxWindowID id
= wxID_ANY
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
,
67 const wxString
& name
= wxGLCanvasName
,
68 const int *attribList
= NULL
,
69 const wxPalette
& palette
= wxNullPalette
);
71 virtual ~wxGLCanvas();
73 // implement wxGLCanvasBase methods
74 virtual bool SwapBuffers();
77 // Mac-specific functions
78 // ----------------------
80 // return true if multisample extension is supported
81 static bool IsAGLMultiSampleAvailable();
83 // return the pixel format used by this window
84 WXGLPixelFormat
GetWXGLPixelFormat() const { return m_glFormat
; }
86 // update the view port of the current context to match this window
93 #if WXWIN_COMPATIBILITY_2_8
95 wxGLCanvas(wxWindow
*parent
,
96 wxWindowID id
= wxID_ANY
,
97 const wxPoint
& pos
= wxDefaultPosition
,
98 const wxSize
& size
= wxDefaultSize
,
100 const wxString
& name
= wxGLCanvasName
,
101 const int *attribList
= NULL
,
102 const wxPalette
& palette
= wxNullPalette
)
106 wxGLCanvas(wxWindow
*parent
,
107 const wxGLContext
*shared
,
108 wxWindowID id
= wxID_ANY
,
109 const wxPoint
& pos
= wxDefaultPosition
,
110 const wxSize
& size
= wxDefaultSize
,
112 const wxString
& name
= wxGLCanvasName
,
113 const int *attribList
= NULL
,
114 const wxPalette
& palette
= wxNullPalette
)
118 wxGLCanvas(wxWindow
*parent
,
119 const wxGLCanvas
*shared
,
120 wxWindowID id
= wxID_ANY
,
121 const wxPoint
& pos
= wxDefaultPosition
,
122 const wxSize
& size
= wxDefaultSize
,
124 const wxString
& name
= wxGLCanvasName
,
125 const int *attribList
= NULL
,
126 const wxPalette
& palette
= wxNullPalette
)
128 #endif // WXWIN_COMPATIBILITY_2_8
130 // implementation-only from now on
133 // Unlike some other platforms, this must get called if you override it,
134 // i.e. don't forget "event.Skip()" in your EVT_SIZE handler
135 void OnSize(wxSizeEvent
& event
);
137 virtual void MacSuperChangedPosition();
138 virtual void MacTopLevelWindowChangedPosition();
139 virtual void MacVisibilityChanged();
141 void MacUpdateView();
143 GLint
GetAglBufferName() const { return m_bufferName
; }
147 WXGLPixelFormat m_glFormat
;
150 bool m_macCanvasIsShown
,
152 WXGLContext m_dummyContext
;
156 DECLARE_EVENT_TABLE()
157 DECLARE_CLASS(wxGLCanvas
)
160 #endif // _WX_GLCANVAS_H_