]>
Commit | Line | Data |
---|---|---|
8b089c5e | 1 | ///////////////////////////////////////////////////////////////////////////// |
86e5d706 | 2 | // Name: wx/msw/glcanvas.h |
77ffb593 | 3 | // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Windows |
8b089c5e JS |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
8b089c5e | 7 | // Copyright: (c) Julian Smart |
65571936 | 8 | // Licence: wxWindows licence |
8b089c5e JS |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
db4c39a9 VZ |
11 | #ifndef _WX_GLCANVAS_H_ |
12 | #define _WX_GLCANVAS_H_ | |
13 | ||
2b5f62a0 | 14 | #include "wx/palette.h" |
8b089c5e | 15 | |
0643d43c | 16 | #include "wx/msw/wrapwin.h" |
8b089c5e | 17 | |
86e5d706 | 18 | #include <GL/gl.h> |
8b089c5e | 19 | |
dc3065a5 VZ |
20 | // ---------------------------------------------------------------------------- |
21 | // wxGLContext: OpenGL rendering context | |
22 | // ---------------------------------------------------------------------------- | |
8b089c5e | 23 | |
dc3065a5 | 24 | class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase |
8b089c5e JS |
25 | { |
26 | public: | |
dc3065a5 | 27 | wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL); |
d3c7fc99 | 28 | virtual ~wxGLContext(); |
8b089c5e | 29 | |
5ec69e96 | 30 | virtual bool SetCurrent(const wxGLCanvas& win) const; |
dc3065a5 VZ |
31 | |
32 | HGLRC GetGLRC() const { return m_glContext; } | |
8b089c5e | 33 | |
b7ea712c RR |
34 | protected: |
35 | HGLRC m_glContext; | |
36 | ||
37 | private: | |
38 | DECLARE_CLASS(wxGLContext) | |
8b089c5e JS |
39 | }; |
40 | ||
dc3065a5 VZ |
41 | // ---------------------------------------------------------------------------- |
42 | // wxGLCanvas: OpenGL output window | |
43 | // ---------------------------------------------------------------------------- | |
44 | ||
45 | class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase | |
8b089c5e | 46 | { |
0b3fcc0a | 47 | public: |
1f526a8c | 48 | wxEXPLICIT // avoid implicitly converting a wxWindow* to wxGLCanvas |
0b3fcc0a | 49 | wxGLCanvas(wxWindow *parent, |
dc3065a5 VZ |
50 | wxWindowID id = wxID_ANY, |
51 | const int *attribList = NULL, | |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, | |
54 | long style = 0, | |
55 | const wxString& name = wxGLCanvasName, | |
56 | const wxPalette& palette = wxNullPalette); | |
57 | ||
58 | bool Create(wxWindow *parent, | |
59 | wxWindowID id = wxID_ANY, | |
60 | const wxPoint& pos = wxDefaultPosition, | |
61 | const wxSize& size = wxDefaultSize, | |
62 | long style = 0, | |
63 | const wxString& name = wxGLCanvasName, | |
64 | const int *attribList = NULL, | |
65 | const wxPalette& palette = wxNullPalette); | |
0b3fcc0a | 66 | |
d3c7fc99 | 67 | virtual ~wxGLCanvas(); |
0b3fcc0a | 68 | |
dc3065a5 | 69 | // implement wxGLCanvasBase methods |
5ec69e96 | 70 | virtual bool SwapBuffers(); |
0b3fcc0a | 71 | |
0b3fcc0a | 72 | |
dc3065a5 VZ |
73 | // MSW-specific helpers |
74 | // -------------------- | |
8b089c5e | 75 | |
dc3065a5 VZ |
76 | // get the HDC used for OpenGL rendering |
77 | HDC GetHDC() const { return m_hDC; } | |
8b089c5e | 78 | |
dc3065a5 VZ |
79 | // try to find pixel format matching the given attributes list for the |
80 | // specified HDC, return 0 on error, otherwise pfd is filled in with the | |
81 | // information from attribList if non-NULL | |
82 | static int ChooseMatchingPixelFormat(HDC hdc, const int *attribList, | |
83 | PIXELFORMATDESCRIPTOR *pfd = NULL); | |
8b089c5e | 84 | |
dc3065a5 VZ |
85 | #if wxUSE_PALETTE |
86 | // palette stuff | |
87 | bool SetupPalette(const wxPalette& palette); | |
88 | virtual wxPalette CreateDefaultPalette(); | |
0b3fcc0a | 89 | void OnQueryNewPalette(wxQueryNewPaletteEvent& event); |
0b3fcc0a | 90 | void OnPaletteChanged(wxPaletteChangedEvent& event); |
dc3065a5 | 91 | #endif // wxUSE_PALETTE |
8a39593e | 92 | |
dc3065a5 VZ |
93 | // deprecated methods using the implicit wxGLContext, associate the context |
94 | // explicitly with the window instead | |
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 | |
8b089c5e | 131 | |
dc3065a5 VZ |
132 | protected: |
133 | // common part of all ctors | |
134 | void Init(); | |
8b089c5e | 135 | |
82bf63a0 VZ |
136 | // the real window creation function, Create() may reuse it twice as we may |
137 | // need to create an OpenGL window to query the available extensions and | |
138 | // then potentially delete and recreate it with another pixel format | |
139 | bool CreateWindow(wxWindow *parent, | |
140 | wxWindowID id = wxID_ANY, | |
141 | const wxPoint& pos = wxDefaultPosition, | |
142 | const wxSize& size = wxDefaultSize, | |
143 | long style = 0, | |
144 | const wxString& name = wxGLCanvasName); | |
145 | ||
dc3065a5 | 146 | // set up the pixel format using the given attributes and palette |
82bf63a0 | 147 | int DoSetup(PIXELFORMATDESCRIPTOR &pfd, const int *attribList); |
8b089c5e | 148 | |
8b089c5e | 149 | |
dc3065a5 VZ |
150 | // HDC for this window, we keep it all the time |
151 | HDC m_hDC; | |
8b089c5e | 152 | |
b7ea712c | 153 | private: |
a3081354 | 154 | DECLARE_EVENT_TABLE() |
b7ea712c | 155 | DECLARE_CLASS(wxGLCanvas) |
8b089c5e JS |
156 | }; |
157 | ||
dc3065a5 | 158 | #endif // _WX_GLCANVAS_H_ |