]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/mac/carbon/glcanvas.h | |
3 | // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_GLCANVAS_H_ | |
13 | #define _WX_GLCANVAS_H_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_GLCANVAS | |
18 | ||
19 | #include "wx/palette.h" | |
20 | #include "wx/scrolwin.h" | |
21 | #include "wx/app.h" | |
22 | ||
23 | #ifdef __DARWIN__ | |
24 | # include <OpenGL/gl.h> | |
25 | # include <AGL/agl.h> | |
26 | #else | |
27 | # include <gl.h> | |
28 | # include <agl.h> | |
29 | #endif | |
30 | ||
31 | class WXDLLEXPORT wxGLCanvas; /* forward reference */ | |
32 | ||
33 | class WXDLLEXPORT wxGLContext: public wxObject | |
34 | { | |
35 | public: | |
36 | wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win, | |
37 | const wxPalette& WXUNUSED(palette), | |
38 | const wxGLContext *other /* for sharing display lists */ | |
39 | ); | |
40 | virtual ~wxGLContext(); | |
41 | ||
42 | void SetCurrent(); | |
43 | void Update(); // must be called after window drag/grows/zoom or clut change | |
44 | void SetColour(const wxChar *colour); | |
45 | void SwapBuffers(); | |
46 | ||
47 | ||
48 | inline wxWindow* GetWindow() const { return m_window; } | |
49 | inline AGLDrawable GetDrawable() const { return m_drawable; } | |
50 | ||
51 | public: | |
52 | AGLContext m_glContext; | |
53 | AGLDrawable m_drawable; | |
54 | wxWindow* m_window; | |
55 | }; | |
56 | ||
57 | class WXDLLEXPORT wxGLCanvas: public wxWindow | |
58 | { | |
59 | DECLARE_CLASS(wxGLCanvas) | |
60 | public: | |
61 | wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, | |
62 | const wxSize& size = wxDefaultSize, long style = 0, | |
63 | const wxString& name = wxT("GLCanvas") , int *attribList = 0, const wxPalette& palette = wxNullPalette); | |
64 | wxGLCanvas( wxWindow *parent, const wxGLContext *shared, | |
65 | wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, | |
66 | const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"), | |
67 | int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); | |
68 | ||
69 | wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id = wxID_ANY, | |
70 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, | |
71 | const wxString& name = wxT("GLCanvas"), int *attribList = 0, const wxPalette& palette = wxNullPalette ); | |
72 | ||
73 | virtual ~wxGLCanvas(); | |
74 | ||
75 | bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, | |
76 | const wxPoint& pos, const wxSize& size, long style, const wxString& name, | |
77 | int *attribList, const wxPalette& palette); | |
78 | ||
79 | void SetCurrent(); | |
80 | void SetColour(const wxChar *colour); | |
81 | void SwapBuffers(); | |
82 | void UpdateContext(); | |
83 | void SetViewport(); | |
84 | virtual bool Show(bool show = true) ; | |
85 | ||
86 | // Unlike some other platforms, this must get called if you override it. | |
87 | // It sets the viewport correctly and update the context. | |
88 | // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.) | |
89 | void OnSize(wxSizeEvent& event); | |
90 | ||
91 | virtual void MacSuperChangedPosition() ; | |
92 | virtual void MacTopLevelWindowChangedPosition() ; | |
93 | virtual void MacVisibilityChanged() ; | |
94 | ||
95 | void MacUpdateView() ; | |
96 | ||
97 | inline wxGLContext* GetContext() const { return m_glContext; } | |
98 | ||
99 | protected: | |
100 | wxGLContext* m_glContext; | |
101 | bool m_macCanvasIsShown ; | |
102 | DECLARE_EVENT_TABLE() | |
103 | }; | |
104 | ||
105 | #endif // wxUSE_GLCANVAS | |
106 | #endif // _WX_GLCANVAS_H_ |