]>
Commit | Line | Data |
---|---|---|
6762286d | 1 | ///////////////////////////////////////////////////////////////////////////// |
233f5738 | 2 | // Name: wx/osx/glcanvas.h |
6762286d SC |
3 | // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
6762286d SC |
7 | // Copyright: (c) Stefan Csomor |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_GLCANVAS_H_ | |
12 | #define _WX_GLCANVAS_H_ | |
13 | ||
421bb018 SC |
14 | #ifdef __WXOSX_IPHONE__ |
15 | #import <OpenGLES/ES1/gl.h> | |
16 | #import <OpenGLES/ES1/glext.h> | |
b90817de | 17 | #define wxUSE_OPENGL_EMULATION 1 |
421bb018 | 18 | #else |
6762286d | 19 | #include <OpenGL/gl.h> |
421bb018 | 20 | #endif |
6762286d | 21 | |
b90817de SC |
22 | #include "wx/vector.h" |
23 | ||
6762286d SC |
24 | // low level calls |
25 | ||
26 | WXDLLIMPEXP_GL WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext ); | |
27 | WXDLLIMPEXP_GL void WXGLDestroyContext( WXGLContext context ); | |
b90817de | 28 | |
6762286d | 29 | WXDLLIMPEXP_GL WXGLContext WXGLGetCurrentContext(); |
b6ccc13c | 30 | WXDLLIMPEXP_GL bool WXGLSetCurrentContext(WXGLContext context); |
6762286d SC |
31 | |
32 | WXDLLIMPEXP_GL WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList); | |
33 | WXDLLIMPEXP_GL void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat ); | |
34 | ||
35 | class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase | |
36 | { | |
37 | public: | |
38 | wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL); | |
39 | virtual ~wxGLContext(); | |
40 | ||
41 | virtual bool SetCurrent(const wxGLCanvas& win) const; | |
42 | ||
43 | // Mac-specific | |
44 | WXGLContext GetWXGLContext() const { return m_glContext; } | |
03647350 | 45 | |
6762286d SC |
46 | private: |
47 | WXGLContext m_glContext; | |
48 | ||
c0c133e1 | 49 | wxDECLARE_NO_COPY_CLASS(wxGLContext); |
6762286d SC |
50 | }; |
51 | ||
52 | class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase | |
53 | { | |
54 | public: | |
55 | wxGLCanvas(wxWindow *parent, | |
56 | wxWindowID id = wxID_ANY, | |
57 | const int *attribList = NULL, | |
58 | const wxPoint& pos = wxDefaultPosition, | |
59 | const wxSize& size = wxDefaultSize, | |
60 | long style = 0, | |
61 | const wxString& name = wxGLCanvasName, | |
62 | const wxPalette& palette = wxNullPalette); | |
63 | ||
64 | bool Create(wxWindow *parent, | |
65 | wxWindowID id = wxID_ANY, | |
66 | const wxPoint& pos = wxDefaultPosition, | |
67 | const wxSize& size = wxDefaultSize, | |
68 | long style = 0, | |
69 | const wxString& name = wxGLCanvasName, | |
70 | const int *attribList = NULL, | |
71 | const wxPalette& palette = wxNullPalette); | |
72 | ||
73 | virtual ~wxGLCanvas(); | |
74 | ||
75 | // implement wxGLCanvasBase methods | |
76 | virtual bool SwapBuffers(); | |
77 | ||
78 | ||
79 | // Mac-specific functions | |
80 | // ---------------------- | |
81 | ||
82 | // return true if multisample extension is supported | |
83 | static bool IsAGLMultiSampleAvailable(); | |
84 | ||
85 | // return the pixel format used by this window | |
86 | WXGLPixelFormat GetWXGLPixelFormat() const { return m_glFormat; } | |
87 | ||
88 | // update the view port of the current context to match this window | |
89 | void SetViewport(); | |
90 | ||
91 | ||
92 | // deprecated methods | |
93 | // ------------------ | |
94 | ||
95 | #if WXWIN_COMPATIBILITY_2_8 | |
96 | wxDEPRECATED( | |
97 | wxGLCanvas(wxWindow *parent, | |
98 | wxWindowID id = wxID_ANY, | |
99 | const wxPoint& pos = wxDefaultPosition, | |
100 | const wxSize& size = wxDefaultSize, | |
101 | long style = 0, | |
102 | const wxString& name = wxGLCanvasName, | |
103 | const int *attribList = NULL, | |
104 | const wxPalette& palette = wxNullPalette) | |
105 | ); | |
106 | ||
107 | wxDEPRECATED( | |
108 | wxGLCanvas(wxWindow *parent, | |
109 | const wxGLContext *shared, | |
110 | wxWindowID id = wxID_ANY, | |
111 | const wxPoint& pos = wxDefaultPosition, | |
112 | const wxSize& size = wxDefaultSize, | |
113 | long style = 0, | |
114 | const wxString& name = wxGLCanvasName, | |
115 | const int *attribList = NULL, | |
116 | const wxPalette& palette = wxNullPalette) | |
117 | ); | |
118 | ||
119 | wxDEPRECATED( | |
120 | wxGLCanvas(wxWindow *parent, | |
121 | const wxGLCanvas *shared, | |
122 | wxWindowID id = wxID_ANY, | |
123 | const wxPoint& pos = wxDefaultPosition, | |
124 | const wxSize& size = wxDefaultSize, | |
125 | long style = 0, | |
126 | const wxString& name = wxGLCanvasName, | |
127 | const int *attribList = NULL, | |
128 | const wxPalette& palette = wxNullPalette) | |
129 | ); | |
130 | #endif // WXWIN_COMPATIBILITY_2_8 | |
131 | ||
132 | // implementation-only from now on | |
133 | ||
134 | #if wxOSX_USE_CARBON | |
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); | |
138 | ||
139 | virtual void MacSuperChangedPosition(); | |
140 | virtual void MacTopLevelWindowChangedPosition(); | |
141 | virtual void MacVisibilityChanged(); | |
142 | ||
143 | void MacUpdateView(); | |
03647350 | 144 | |
6762286d SC |
145 | GLint GetAglBufferName() const { return m_bufferName; } |
146 | #endif | |
147 | ||
148 | protected: | |
149 | WXGLPixelFormat m_glFormat; | |
150 | ||
151 | #if wxOSX_USE_CARBON | |
152 | bool m_macCanvasIsShown, | |
153 | m_needsUpdate; | |
154 | WXGLContext m_dummyContext; | |
155 | GLint m_bufferName; | |
156 | #endif | |
157 | ||
158 | DECLARE_EVENT_TABLE() | |
159 | DECLARE_CLASS(wxGLCanvas) | |
160 | }; | |
161 | ||
162 | #endif // _WX_GLCANVAS_H_ |