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