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 #include <OpenGL/gl.h>
19 WXDLLIMPEXP_GL WXGLContext
WXGLCreateContext( WXGLPixelFormat pixelFormat
, WXGLContext shareContext
);
20 WXDLLIMPEXP_GL
void WXGLDestroyContext( WXGLContext context
);
21 WXDLLIMPEXP_GL WXGLContext
WXGLGetCurrentContext();
22 WXDLLIMPEXP_GL
void WXGLSwapBuffers( WXGLContext context
);
24 WXDLLIMPEXP_GL WXGLPixelFormat
WXGLChoosePixelFormat(const int *attribList
);
25 WXDLLIMPEXP_GL
void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat
);
27 class WXDLLIMPEXP_GL wxGLContext
: public wxGLContextBase
30 wxGLContext(wxGLCanvas
*win
, const wxGLContext
*other
= NULL
);
31 virtual ~wxGLContext();
33 virtual bool SetCurrent(const wxGLCanvas
& win
) const;
36 WXGLContext
GetWXGLContext() const { return m_glContext
; }
39 WXGLContext m_glContext
;
41 wxDECLARE_NO_COPY_CLASS(wxGLContext
);
44 class WXDLLIMPEXP_GL wxGLCanvas
: public wxGLCanvasBase
47 wxGLCanvas(wxWindow
*parent
,
48 wxWindowID id
= wxID_ANY
,
49 const int *attribList
= NULL
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxGLCanvasName
,
54 const wxPalette
& palette
= wxNullPalette
);
56 bool Create(wxWindow
*parent
,
57 wxWindowID id
= wxID_ANY
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxString
& name
= wxGLCanvasName
,
62 const int *attribList
= NULL
,
63 const wxPalette
& palette
= wxNullPalette
);
65 virtual ~wxGLCanvas();
67 // implement wxGLCanvasBase methods
68 virtual bool SwapBuffers();
71 // Mac-specific functions
72 // ----------------------
74 // return true if multisample extension is supported
75 static bool IsAGLMultiSampleAvailable();
77 // return the pixel format used by this window
78 WXGLPixelFormat
GetWXGLPixelFormat() const { return m_glFormat
; }
80 // update the view port of the current context to match this window
87 #if WXWIN_COMPATIBILITY_2_8
89 wxGLCanvas(wxWindow
*parent
,
90 wxWindowID id
= wxID_ANY
,
91 const wxPoint
& pos
= wxDefaultPosition
,
92 const wxSize
& size
= wxDefaultSize
,
94 const wxString
& name
= wxGLCanvasName
,
95 const int *attribList
= NULL
,
96 const wxPalette
& palette
= wxNullPalette
)
100 wxGLCanvas(wxWindow
*parent
,
101 const wxGLContext
*shared
,
102 wxWindowID id
= wxID_ANY
,
103 const wxPoint
& pos
= wxDefaultPosition
,
104 const wxSize
& size
= wxDefaultSize
,
106 const wxString
& name
= wxGLCanvasName
,
107 const int *attribList
= NULL
,
108 const wxPalette
& palette
= wxNullPalette
)
112 wxGLCanvas(wxWindow
*parent
,
113 const wxGLCanvas
*shared
,
114 wxWindowID id
= wxID_ANY
,
115 const wxPoint
& pos
= wxDefaultPosition
,
116 const wxSize
& size
= wxDefaultSize
,
118 const wxString
& name
= wxGLCanvasName
,
119 const int *attribList
= NULL
,
120 const wxPalette
& palette
= wxNullPalette
)
122 #endif // WXWIN_COMPATIBILITY_2_8
124 // implementation-only from now on
127 // Unlike some other platforms, this must get called if you override it,
128 // i.e. don't forget "event.Skip()" in your EVT_SIZE handler
129 void OnSize(wxSizeEvent
& event
);
131 virtual void MacSuperChangedPosition();
132 virtual void MacTopLevelWindowChangedPosition();
133 virtual void MacVisibilityChanged();
135 void MacUpdateView();
137 GLint
GetAglBufferName() const { return m_bufferName
; }
141 WXGLPixelFormat m_glFormat
;
144 bool m_macCanvasIsShown
,
146 WXGLContext m_dummyContext
;
150 DECLARE_EVENT_TABLE()
151 DECLARE_CLASS(wxGLCanvas
)
154 #endif // _WX_GLCANVAS_H_