]>
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 | ||
12028905 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
8b089c5e JS |
13 | #pragma interface "glcanvas.h" |
14 | #endif | |
15 | ||
16 | #ifndef _WX_GLCANVAS_H_ | |
17 | #define _WX_GLCANVAS_H_ | |
18 | ||
2b5f62a0 VZ |
19 | #include "wx/palette.h" |
20 | #include "wx/scrolwin.h" | |
8b089c5e JS |
21 | |
22 | #include <windows.h> | |
2b5f62a0 | 23 | #include "wx/msw/winundef.h" |
8b089c5e | 24 | |
86e5d706 | 25 | #include <GL/gl.h> |
8b089c5e JS |
26 | |
27 | //--------------------------------------------------------------------------- | |
28 | // Constants for attriblist | |
29 | //--------------------------------------------------------------------------- | |
30 | ||
f48d169c UN |
31 | // The generic GL implementation doesn't support most of these options, |
32 | // such as stereo, auxiliary buffers, alpha channel, and accum buffer. | |
33 | // Other implementations may actually support them. | |
34 | ||
8b089c5e JS |
35 | enum |
36 | { | |
0b3fcc0a DS |
37 | WX_GL_RGBA=1, /* use true color palette */ |
38 | WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ | |
39 | WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ | |
40 | WX_GL_DOUBLEBUFFER, /* use doublebuffer */ | |
41 | WX_GL_STEREO, /* use stereoscopic display */ | |
42 | WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ | |
43 | WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ | |
44 | WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ | |
45 | WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ | |
46 | WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */ | |
47 | WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ | |
48 | WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ | |
49 | WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ | |
50 | WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ | |
51 | WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ | |
52 | WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */ | |
8b089c5e JS |
53 | }; |
54 | ||
eac90854 | 55 | class WXDLLIMPEXP_GL wxGLCanvas; /* forward reference */ |
8b089c5e | 56 | |
eac90854 | 57 | class WXDLLIMPEXP_GL wxGLContext: public wxObject |
8b089c5e JS |
58 | { |
59 | public: | |
0b3fcc0a | 60 | wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette); |
8b089c5e | 61 | |
0b3fcc0a DS |
62 | wxGLContext( bool isRGB, wxGLCanvas *win, |
63 | const wxPalette& WXUNUSED(palette), | |
64 | const wxGLContext *other /* for sharing display lists */ ); | |
8b089c5e | 65 | |
0b3fcc0a | 66 | ~wxGLContext(); |
8b089c5e | 67 | |
0b3fcc0a DS |
68 | |
69 | void SetCurrent(); | |
70 | ||
71 | void SetColour(const wxChar *colour); | |
72 | ||
73 | void SwapBuffers(); | |
74 | ||
75 | ||
76 | inline wxWindow* GetWindow() const { return m_window; } | |
77 | ||
78 | inline WXHDC GetHDC() const { return m_hDC; } | |
79 | ||
80 | inline HGLRC GetGLRC() const { return m_glContext; } | |
8b089c5e JS |
81 | |
82 | public: | |
0b3fcc0a DS |
83 | HGLRC m_glContext; |
84 | WXHDC m_hDC; | |
85 | wxWindow* m_window; | |
8b089c5e JS |
86 | }; |
87 | ||
eac90854 | 88 | class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow |
8b089c5e | 89 | { |
0b3fcc0a DS |
90 | DECLARE_CLASS(wxGLCanvas) |
91 | public: | |
92 | wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, | |
93 | const wxPoint& pos = wxDefaultPosition, | |
8b089c5e | 94 | const wxSize& size = wxDefaultSize, long style = 0, |
0b3fcc0a DS |
95 | const wxString& name = wxGLCanvasName, int *attribList = 0, |
96 | const wxPalette& palette = wxNullPalette); | |
97 | ||
98 | wxGLCanvas(wxWindow *parent, | |
99 | const wxGLContext *shared = (wxGLContext *) NULL, | |
100 | wxWindowID id = wxID_ANY, | |
101 | const wxPoint& pos = wxDefaultPosition, | |
102 | const wxSize& size = wxDefaultSize, | |
103 | long style = 0, | |
104 | const wxString& name = wxGLCanvasName, | |
105 | int *attribList = (int *) NULL, | |
106 | const wxPalette& palette = wxNullPalette); | |
107 | ||
108 | wxGLCanvas(wxWindow *parent, | |
109 | const wxGLCanvas *shared = (wxGLCanvas *)NULL, | |
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 | int *attribList = 0, | |
116 | const wxPalette& palette = wxNullPalette); | |
117 | ||
118 | ~wxGLCanvas(); | |
119 | ||
120 | // Replaces wxWindow::Create functionality, since | |
121 | // we need to use a different window class | |
122 | bool Create(wxWindow *parent, wxWindowID id, | |
123 | const wxPoint& pos, const wxSize& size, | |
124 | long style, const wxString& name); | |
125 | ||
126 | void SetCurrent(); | |
127 | ||
128 | #ifdef __WXUNIVERSAL__ | |
129 | virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); }; | |
130 | #endif | |
131 | ||
132 | void SetColour(const wxChar *colour); | |
8b089c5e | 133 | |
0b3fcc0a | 134 | void SwapBuffers(); |
8b089c5e | 135 | |
0b3fcc0a | 136 | void OnSize(wxSizeEvent& event); |
8b089c5e | 137 | |
0b3fcc0a | 138 | void OnQueryNewPalette(wxQueryNewPaletteEvent& event); |
8b089c5e | 139 | |
0b3fcc0a | 140 | void OnPaletteChanged(wxPaletteChangedEvent& event); |
8a39593e | 141 | |
0b3fcc0a | 142 | inline wxGLContext* GetContext() const { return m_glContext; } |
8b089c5e | 143 | |
0b3fcc0a | 144 | inline WXHDC GetHDC() const { return m_hDC; } |
8b089c5e | 145 | |
0b3fcc0a | 146 | void SetupPixelFormat(int *attribList = (int *) NULL); |
8b089c5e | 147 | |
0b3fcc0a | 148 | void SetupPalette(const wxPalette& palette); |
8b089c5e | 149 | |
0b3fcc0a | 150 | wxPalette CreateDefaultPalette(); |
8b089c5e | 151 | |
0b3fcc0a | 152 | inline wxPalette* GetPalette() const { return (wxPalette *) &m_palette; } |
8b089c5e JS |
153 | |
154 | protected: | |
155 | wxGLContext* m_glContext; // this is typedef-ed ptr, in fact | |
156 | wxPalette m_palette; | |
157 | WXHDC m_hDC; | |
158 | ||
a3081354 | 159 | DECLARE_EVENT_TABLE() |
8b089c5e JS |
160 | }; |
161 | ||
8b089c5e JS |
162 | #endif |
163 | // _WX_GLCANVAS_H_ | |
164 |