]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/x11/glcanvas.h | |
3 | // Purpose: wxGLCanvas, for using OpenGL with wxWidgets 2.0 for Motif. | |
4 | // Uses the GLX extension. | |
5 | // Author: Julian Smart and Wolfram Gloger | |
6 | // Modified by: | |
7 | // Created: 1995, 1999 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) Julian Smart, Wolfram Gloger | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef _WX_GLCANVAS_H_ | |
14 | #define _WX_GLCANVAS_H_ | |
15 | ||
16 | #include "wx/defs.h" | |
17 | ||
18 | #if wxUSE_GLCANVAS | |
19 | ||
20 | #include "wx/gdicmn.h" | |
21 | #include "wx/palette.h" | |
22 | #include "wx/scrolwin.h" | |
23 | ||
24 | #include <GL/glx.h> | |
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | // classes | |
28 | //--------------------------------------------------------------------------- | |
29 | ||
30 | ||
31 | class WXDLLEXPORT wxGLContext: public wxObject | |
32 | { | |
33 | public: | |
34 | wxGLContext( bool isRGB, wxWindow *win, | |
35 | const wxPalette& palette = wxNullPalette ); | |
36 | wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, | |
37 | const wxPalette& WXUNUSED(palette), | |
38 | const wxGLContext *other /* for sharing display lists */ | |
39 | ); | |
40 | virtual ~wxGLContext(); | |
41 | ||
42 | void SetCurrent(); | |
43 | void SetColour(const wxChar *colour); | |
44 | void SwapBuffers(); | |
45 | ||
46 | void SetupPixelFormat(); | |
47 | void SetupPalette(const wxPalette& palette); | |
48 | wxPalette CreateDefaultPalette(); | |
49 | ||
50 | inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; } | |
51 | inline wxWindow* GetWindow() const { return m_window; } | |
52 | // inline GtkWidget* GetWidget() const { return m_widget; } | |
53 | inline GLXContext GetContext() const { return m_glContext; } | |
54 | ||
55 | public: | |
56 | GLXContext m_glContext; | |
57 | ||
58 | // GtkWidget *m_widget; | |
59 | wxPalette m_palette; | |
60 | wxWindow* m_window; | |
61 | ||
62 | DECLARE_CLASS(wxGLContext) | |
63 | }; | |
64 | ||
65 | ||
66 | class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow | |
67 | { | |
68 | public: | |
69 | inline wxGLCanvas() { | |
70 | m_glContext = (wxGLContext*) NULL; | |
71 | m_sharedContext = (wxGLContext*) NULL; | |
72 | // m_glWidget = (GtkWidget*) NULL; | |
73 | m_vi = (void*) NULL; | |
74 | // m_exposed = FALSE; | |
75 | } | |
76 | wxGLCanvas( wxWindow *parent, wxWindowID id = wxID_ANY, | |
77 | const wxPoint& pos = wxDefaultPosition, | |
78 | const wxSize& size = wxDefaultSize, | |
79 | long style = 0, const wxString& name = wxT("GLCanvas"), | |
80 | int *attribList = (int*) NULL, | |
81 | const wxPalette& palette = wxNullPalette ); | |
82 | wxGLCanvas( wxWindow *parent, const wxGLContext *shared, | |
83 | wxWindowID id = wxID_ANY, | |
84 | const wxPoint& pos = wxDefaultPosition, | |
85 | const wxSize& size = wxDefaultSize, | |
86 | long style = 0, const wxString& name = wxT("GLCanvas"), | |
87 | int *attribList = (int*) NULL, | |
88 | const wxPalette& palette = wxNullPalette ); | |
89 | wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, | |
90 | wxWindowID id = wxID_ANY, | |
91 | const wxPoint& pos = wxDefaultPosition, | |
92 | const wxSize& size = wxDefaultSize, | |
93 | long style = 0, const wxString& name = wxT("GLCanvas"), | |
94 | int *attribList = (int*) NULL, | |
95 | const wxPalette& palette = wxNullPalette ); | |
96 | ||
97 | bool Create( wxWindow *parent, | |
98 | const wxGLContext *shared = (wxGLContext*)NULL, | |
99 | const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL, | |
100 | wxWindowID id = wxID_ANY, | |
101 | const wxPoint& pos = wxDefaultPosition, | |
102 | const wxSize& size = wxDefaultSize, | |
103 | long style = 0, const wxString& name = wxT("GLCanvas"), | |
104 | int *attribList = (int*) NULL, | |
105 | const wxPalette& palette = wxNullPalette ); | |
106 | ||
107 | virtual ~wxGLCanvas(); | |
108 | ||
109 | void SetCurrent(); | |
110 | void SetColour(const wxChar *colour); | |
111 | void SwapBuffers(); | |
112 | ||
113 | // void OnSize(wxSizeEvent& event); | |
114 | ||
115 | // void OnInternalIdle(); | |
116 | ||
117 | inline wxGLContext* GetContext() const { return m_glContext; } | |
118 | ||
119 | // implementation | |
120 | ||
121 | wxGLContext *m_glContext, | |
122 | *m_sharedContext; | |
123 | wxGLCanvas *m_sharedContextOf; | |
124 | void *m_vi; | |
125 | // GtkWidget *m_glWidget; | |
126 | // bool m_exposed; | |
127 | ||
128 | DECLARE_EVENT_TABLE() | |
129 | DECLARE_CLASS(wxGLCanvas) | |
130 | ||
131 | }; | |
132 | ||
133 | #endif | |
134 | // wxUSE_GLCANVAS | |
135 | ||
136 | #endif | |
137 | // _WX_GLCANVAS_H_ |