1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GLCANVAS_H_
12 #define _WX_GLCANVAS_H_
14 #ifdef __WXOSX_IPHONE__
15 #import <OpenGLES/ES1/gl.h>
16 #import <OpenGLES/ES1/glext.h>
17 #define wxUSE_OPENGL_EMULATION 1
19 #include <OpenGL/gl.h>
22 #include "wx/vector.h"
26 WXDLLIMPEXP_GL WXGLContext
WXGLCreateContext( WXGLPixelFormat pixelFormat
, WXGLContext shareContext
);
27 WXDLLIMPEXP_GL
void WXGLDestroyContext( WXGLContext context
);
29 WXDLLIMPEXP_GL WXGLContext
WXGLGetCurrentContext();
30 WXDLLIMPEXP_GL
bool WXGLSetCurrentContext(WXGLContext context
);
32 WXDLLIMPEXP_GL WXGLPixelFormat
WXGLChoosePixelFormat(const int *attribList
);
33 WXDLLIMPEXP_GL
void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat
);
35 class WXDLLIMPEXP_GL wxGLContext
: public wxGLContextBase
38 wxGLContext(wxGLCanvas
*win
, const wxGLContext
*other
= NULL
);
39 virtual ~wxGLContext();
41 virtual bool SetCurrent(const wxGLCanvas
& win
) const;
44 WXGLContext
GetWXGLContext() const { return m_glContext
; }
47 WXGLContext m_glContext
;
49 wxDECLARE_NO_COPY_CLASS(wxGLContext
);
52 class WXDLLIMPEXP_GL wxGLCanvas
: public wxGLCanvasBase
55 wxGLCanvas(wxWindow
*parent
,
56 wxWindowID id
= wxID_ANY
,
57 const int *attribList
= NULL
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxString
& name
= wxGLCanvasName
,
62 const wxPalette
& palette
= wxNullPalette
);
64 bool Create(wxWindow
*parent
,
65 wxWindowID id
= wxID_ANY
,
66 const wxPoint
& pos
= wxDefaultPosition
,
67 const wxSize
& size
= wxDefaultSize
,
69 const wxString
& name
= wxGLCanvasName
,
70 const int *attribList
= NULL
,
71 const wxPalette
& palette
= wxNullPalette
);
73 virtual ~wxGLCanvas();
75 // implement wxGLCanvasBase methods
76 virtual bool SwapBuffers();
79 // Mac-specific functions
80 // ----------------------
82 // return true if multisample extension is supported
83 static bool IsAGLMultiSampleAvailable();
85 // return the pixel format used by this window
86 WXGLPixelFormat
GetWXGLPixelFormat() const { return m_glFormat
; }
88 // update the view port of the current context to match this window
95 #if WXWIN_COMPATIBILITY_2_8
97 wxGLCanvas(wxWindow
*parent
,
98 wxWindowID id
= wxID_ANY
,
99 const wxPoint
& pos
= wxDefaultPosition
,
100 const wxSize
& size
= wxDefaultSize
,
102 const wxString
& name
= wxGLCanvasName
,
103 const int *attribList
= NULL
,
104 const wxPalette
& palette
= wxNullPalette
)
108 wxGLCanvas(wxWindow
*parent
,
109 const wxGLContext
*shared
,
110 wxWindowID id
= wxID_ANY
,
111 const wxPoint
& pos
= wxDefaultPosition
,
112 const wxSize
& size
= wxDefaultSize
,
114 const wxString
& name
= wxGLCanvasName
,
115 const int *attribList
= NULL
,
116 const wxPalette
& palette
= wxNullPalette
)
120 wxGLCanvas(wxWindow
*parent
,
121 const wxGLCanvas
*shared
,
122 wxWindowID id
= wxID_ANY
,
123 const wxPoint
& pos
= wxDefaultPosition
,
124 const wxSize
& size
= wxDefaultSize
,
126 const wxString
& name
= wxGLCanvasName
,
127 const int *attribList
= NULL
,
128 const wxPalette
& palette
= wxNullPalette
)
130 #endif // WXWIN_COMPATIBILITY_2_8
132 // implementation-only from now on
135 // Unlike some other platforms, this must get called if you override it,
136 // i.e. don't forget "event.Skip()" in your EVT_SIZE handler
137 void OnSize(wxSizeEvent
& event
);
139 virtual void MacSuperChangedPosition();
140 virtual void MacTopLevelWindowChangedPosition();
141 virtual void MacVisibilityChanged();
143 void MacUpdateView();
145 GLint
GetAglBufferName() const { return m_bufferName
; }
149 WXGLPixelFormat m_glFormat
;
152 bool m_macCanvasIsShown
,
154 WXGLContext m_dummyContext
;
158 DECLARE_EVENT_TABLE()
159 DECLARE_CLASS(wxGLCanvas
)
162 #endif // _WX_GLCANVAS_H_