]>
Commit | Line | Data |
---|---|---|
9d3221ab RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: glcanvas.h | |
3 | // Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 17/8/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Robert Roebling | |
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/defs.h" | |
20 | #include "wx/scrolwin.h" | |
21 | ||
aae24d21 | 22 | extern "C" { |
9d3221ab RR |
23 | #include "GL/gl.h" |
24 | #include "GL/glx.h" | |
25 | #include "GL/glu.h" | |
aae24d21 | 26 | } |
9d3221ab | 27 | |
089e55d6 RR |
28 | //--------------------------------------------------------------------------- |
29 | // Constants for attriblist | |
30 | //--------------------------------------------------------------------------- | |
31 | ||
32 | enum | |
33 | { | |
34 | WX_GL_RGBA=1, /* use true color palette */ | |
35 | WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ | |
36 | WX_GL_DOUBLEBUFFER, /* use doublebuffer */ | |
37 | WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ | |
38 | WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ | |
39 | WX_GL_MIN_BLUE /* use blue buffer with most bits (> MIN_BLUE bits) */ | |
40 | /* these are enough constants for now, the remaining will be added later */ | |
41 | }; | |
42 | ||
9d3221ab RR |
43 | //--------------------------------------------------------------------------- |
44 | // classes | |
45 | //--------------------------------------------------------------------------- | |
46 | ||
47 | class wxGLContext; | |
48 | class wxGLCanvas; | |
49 | ||
50 | //--------------------------------------------------------------------------- | |
51 | // wxGLContext | |
52 | //--------------------------------------------------------------------------- | |
53 | ||
54 | ||
55 | class wxGLContext: public wxObject | |
56 | { | |
57 | DECLARE_CLASS(wxGLContext) | |
58 | ||
59 | public: | |
60 | ||
61 | wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette ); | |
089e55d6 RR |
62 | wxGLContext( |
63 | bool WXUNUSED(isRGB), wxWindow *win, | |
64 | const wxPalette& WXUNUSED(palette), | |
65 | const wxGLContext *other /* for sharing display lists */ | |
66 | ); | |
9d3221ab RR |
67 | ~wxGLContext(); |
68 | ||
69 | void SetCurrent(); | |
70 | void SetColour(const char *colour); | |
71 | void SwapBuffers(); | |
72 | ||
73 | void SetupPixelFormat(); | |
74 | void SetupPalette(const wxPalette& palette); | |
75 | wxPalette CreateDefaultPalette(); | |
76 | ||
77 | inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; } | |
78 | inline wxWindow* GetWindow() const { return m_window; } | |
79 | inline GtkWidget* GetWidget() const { return m_widget; } | |
80 | inline GLXContext GetContext() const { return m_glContext; } | |
81 | ||
82 | public: | |
83 | ||
84 | GLXContext m_glContext; | |
85 | ||
86 | GtkWidget *m_widget; | |
87 | wxPalette m_palette; | |
88 | wxWindow* m_window; | |
89 | }; | |
90 | ||
91 | //--------------------------------------------------------------------------- | |
92 | // wxGLContext | |
93 | //--------------------------------------------------------------------------- | |
94 | ||
95 | class wxGLCanvas: public wxScrolledWindow | |
96 | { | |
97 | DECLARE_CLASS(wxGLCanvas) | |
98 | ||
99 | public: | |
aae24d21 RR |
100 | wxGLCanvas( wxWindow *parent, wxWindowID id = -1, |
101 | const wxPoint& pos = wxDefaultPosition, | |
102 | const wxSize& size = wxDefaultSize, | |
089e55d6 RR |
103 | long style = 0, const wxString& name = "GLCanvas", |
104 | int *attribList = (int*) NULL, | |
105 | const wxPalette& palette = wxNullPalette ); | |
106 | wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, | |
107 | wxWindowID id = -1, | |
108 | const wxPoint& pos = wxDefaultPosition, | |
109 | const wxSize& size = wxDefaultSize, | |
110 | long style = 0, const wxString& name = "GLCanvas", | |
111 | int *attribList = (int*) NULL, | |
112 | const wxPalette& palette = wxNullPalette ); | |
113 | ||
114 | bool Create( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, | |
115 | wxWindowID id = -1, | |
aae24d21 RR |
116 | const wxPoint& pos = wxDefaultPosition, |
117 | const wxSize& size = wxDefaultSize, | |
118 | long style = 0, const wxString& name = "GLCanvas", | |
119 | int *attribList = (int*) NULL, | |
120 | const wxPalette& palette = wxNullPalette ); | |
121 | ||
9d3221ab RR |
122 | ~wxGLCanvas(); |
123 | ||
124 | void SetCurrent(); | |
125 | void SetColour(const char *colour); | |
126 | void SwapBuffers(); | |
127 | ||
128 | void OnSize(wxSizeEvent& event); | |
129 | ||
aae24d21 | 130 | inline wxGLContext* GetContext() const { return m_glContext; } |
9d3221ab | 131 | |
aae24d21 | 132 | // implementation |
9d3221ab | 133 | |
180307da | 134 | virtual void DoSetSize( int x, int y, int width, int height, |
aae24d21 | 135 | int sizeFlags = wxSIZE_AUTO ); |
aae24d21 RR |
136 | |
137 | virtual GtkWidget *GetConnectWidget(); | |
138 | bool IsOwnGtkWindow( GdkWindow *window ); | |
139 | ||
140 | wxGLContext *m_glContext; | |
141 | GtkWidget *m_glWidget; | |
9d3221ab RR |
142 | |
143 | DECLARE_EVENT_TABLE() | |
144 | }; | |
145 | ||
146 | #endif |