1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/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>
18 #define wxUSE_OPENGL_EMULATION 1
20 #include <OpenGL/gl.h>
23 #include "wx/vector.h"
27 WXDLLIMPEXP_GL WXGLContext
WXGLCreateContext( WXGLPixelFormat pixelFormat
, WXGLContext shareContext
);
28 WXDLLIMPEXP_GL
void WXGLDestroyContext( WXGLContext context
);
30 WXDLLIMPEXP_GL WXGLContext
WXGLGetCurrentContext();
31 WXDLLIMPEXP_GL
bool WXGLSetCurrentContext(WXGLContext context
);
33 WXDLLIMPEXP_GL WXGLPixelFormat
WXGLChoosePixelFormat(const int *attribList
);
34 WXDLLIMPEXP_GL
void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat
);
36 class WXDLLIMPEXP_GL wxGLContext
: public wxGLContextBase
39 wxGLContext(wxGLCanvas
*win
, const wxGLContext
*other
= NULL
);
40 virtual ~wxGLContext();
42 virtual bool SetCurrent(const wxGLCanvas
& win
) const;
45 WXGLContext
GetWXGLContext() const { return m_glContext
; }
48 WXGLContext m_glContext
;
50 wxDECLARE_NO_COPY_CLASS(wxGLContext
);
53 class WXDLLIMPEXP_GL wxGLCanvas
: public wxGLCanvasBase
56 wxGLCanvas(wxWindow
*parent
,
57 wxWindowID id
= wxID_ANY
,
58 const int *attribList
= NULL
,
59 const wxPoint
& pos
= wxDefaultPosition
,
60 const wxSize
& size
= wxDefaultSize
,
62 const wxString
& name
= wxGLCanvasName
,
63 const wxPalette
& palette
= wxNullPalette
);
65 bool Create(wxWindow
*parent
,
66 wxWindowID id
= wxID_ANY
,
67 const wxPoint
& pos
= wxDefaultPosition
,
68 const wxSize
& size
= wxDefaultSize
,
70 const wxString
& name
= wxGLCanvasName
,
71 const int *attribList
= NULL
,
72 const wxPalette
& palette
= wxNullPalette
);
74 virtual ~wxGLCanvas();
76 // implement wxGLCanvasBase methods
77 virtual bool SwapBuffers();
80 // Mac-specific functions
81 // ----------------------
83 // return true if multisample extension is supported
84 static bool IsAGLMultiSampleAvailable();
86 // return the pixel format used by this window
87 WXGLPixelFormat
GetWXGLPixelFormat() const { return m_glFormat
; }
89 // update the view port of the current context to match this window
96 #if WXWIN_COMPATIBILITY_2_8
98 wxGLCanvas(wxWindow
*parent
,
99 wxWindowID id
= wxID_ANY
,
100 const wxPoint
& pos
= wxDefaultPosition
,
101 const wxSize
& size
= wxDefaultSize
,
103 const wxString
& name
= wxGLCanvasName
,
104 const int *attribList
= NULL
,
105 const wxPalette
& palette
= wxNullPalette
)
109 wxGLCanvas(wxWindow
*parent
,
110 const wxGLContext
*shared
,
111 wxWindowID id
= wxID_ANY
,
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
,
115 const wxString
& name
= wxGLCanvasName
,
116 const int *attribList
= NULL
,
117 const wxPalette
& palette
= wxNullPalette
)
121 wxGLCanvas(wxWindow
*parent
,
122 const wxGLCanvas
*shared
,
123 wxWindowID id
= wxID_ANY
,
124 const wxPoint
& pos
= wxDefaultPosition
,
125 const wxSize
& size
= wxDefaultSize
,
127 const wxString
& name
= wxGLCanvasName
,
128 const int *attribList
= NULL
,
129 const wxPalette
& palette
= wxNullPalette
)
131 #endif // WXWIN_COMPATIBILITY_2_8
133 // implementation-only from now on
136 // Unlike some other platforms, this must get called if you override it,
137 // i.e. don't forget "event.Skip()" in your EVT_SIZE handler
138 void OnSize(wxSizeEvent
& event
);
140 virtual void MacSuperChangedPosition();
141 virtual void MacTopLevelWindowChangedPosition();
142 virtual void MacVisibilityChanged();
144 void MacUpdateView();
146 GLint
GetAglBufferName() const { return m_bufferName
; }
150 WXGLPixelFormat m_glFormat
;
153 bool m_macCanvasIsShown
,
155 WXGLContext m_dummyContext
;
159 DECLARE_EVENT_TABLE()
160 DECLARE_CLASS(wxGLCanvas
)
163 #endif // _WX_GLCANVAS_H_