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