]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/msw/glcanvas.h | |
3 | // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Windows | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_GLCANVAS_H_ | |
13 | #define _WX_GLCANVAS_H_ | |
14 | ||
15 | #include "wx/palette.h" | |
16 | #include "wx/scrolwin.h" | |
17 | ||
18 | #include "wx/msw/wrapwin.h" | |
19 | ||
20 | #include <GL/gl.h> | |
21 | ||
22 | class WXDLLIMPEXP_GL wxGLCanvas; /* forward reference */ | |
23 | ||
24 | class WXDLLIMPEXP_GL wxGLContext: public wxObject | |
25 | { | |
26 | public: | |
27 | wxGLContext(wxGLCanvas *win, const wxGLContext* other=NULL /* for sharing display lists */ ); | |
28 | virtual ~wxGLContext(); | |
29 | ||
30 | void SetCurrent(const wxGLCanvas& win) const; | |
31 | inline HGLRC GetGLRC() const { return m_glContext; } | |
32 | ||
33 | protected: | |
34 | HGLRC m_glContext; | |
35 | ||
36 | private: | |
37 | DECLARE_CLASS(wxGLContext) | |
38 | }; | |
39 | ||
40 | class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow | |
41 | { | |
42 | public: | |
43 | // This ctor is identical to the next, except for the fact that it | |
44 | // doesn't create an implicit wxGLContext. | |
45 | // The attribList parameter has been moved to avoid overload clashes. | |
46 | wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, | |
47 | int* attribList = 0, | |
48 | const wxPoint& pos = wxDefaultPosition, | |
49 | const wxSize& size = wxDefaultSize, long style = 0, | |
50 | const wxString& name = wxGLCanvasName, | |
51 | const wxPalette& palette = wxNullPalette); | |
52 | ||
53 | wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, | |
54 | const wxPoint& pos = wxDefaultPosition, | |
55 | const wxSize& size = wxDefaultSize, long style = 0, | |
56 | const wxString& name = wxGLCanvasName, int *attribList = 0, | |
57 | const wxPalette& palette = wxNullPalette); | |
58 | ||
59 | wxGLCanvas(wxWindow *parent, | |
60 | const wxGLContext *shared, | |
61 | wxWindowID id = wxID_ANY, | |
62 | const wxPoint& pos = wxDefaultPosition, | |
63 | const wxSize& size = wxDefaultSize, | |
64 | long style = 0, | |
65 | const wxString& name = wxGLCanvasName, | |
66 | int *attribList = (int *) NULL, | |
67 | const wxPalette& palette = wxNullPalette); | |
68 | ||
69 | wxGLCanvas(wxWindow *parent, | |
70 | const wxGLCanvas *shared, | |
71 | wxWindowID id = wxID_ANY, | |
72 | const wxPoint& pos = wxDefaultPosition, | |
73 | const wxSize& size = wxDefaultSize, | |
74 | long style = 0, | |
75 | const wxString& name = wxGLCanvasName, | |
76 | int *attribList = 0, | |
77 | const wxPalette& palette = wxNullPalette); | |
78 | ||
79 | virtual ~wxGLCanvas(); | |
80 | ||
81 | // Replaces wxWindow::Create functionality, since | |
82 | // we need to use a different window class | |
83 | bool Create(wxWindow *parent, wxWindowID id, | |
84 | const wxPoint& pos, const wxSize& size, | |
85 | long style, const wxString& name); | |
86 | ||
87 | void SetCurrent(const wxGLContext& RC) const; | |
88 | void SetCurrent(); | |
89 | ||
90 | #ifdef __WXUNIVERSAL__ | |
91 | virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); }; | |
92 | #endif | |
93 | ||
94 | void SetColour(const wxChar *colour); | |
95 | ||
96 | void SwapBuffers(); | |
97 | ||
98 | void OnSize(wxSizeEvent& event); | |
99 | ||
100 | void OnQueryNewPalette(wxQueryNewPaletteEvent& event); | |
101 | ||
102 | void OnPaletteChanged(wxPaletteChangedEvent& event); | |
103 | ||
104 | inline wxGLContext* GetContext() const { return m_glContext; } | |
105 | ||
106 | inline WXHDC GetHDC() const { return m_hDC; } | |
107 | ||
108 | void SetupPixelFormat(int *attribList = (int *) NULL); | |
109 | ||
110 | void SetupPalette(const wxPalette& palette); | |
111 | ||
112 | wxPalette CreateDefaultPalette(); | |
113 | ||
114 | inline wxPalette* GetPalette() const { return (wxPalette *) &m_palette; } | |
115 | ||
116 | protected: | |
117 | wxGLContext* m_glContext; // this is typedef-ed ptr, in fact | |
118 | wxPalette m_palette; | |
119 | WXHDC m_hDC; | |
120 | ||
121 | private: | |
122 | DECLARE_EVENT_TABLE() | |
123 | DECLARE_CLASS(wxGLCanvas) | |
124 | }; | |
125 | ||
126 | #endif | |
127 | // _WX_GLCANVAS_H_ | |
128 |