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