]>
Commit | Line | Data |
---|---|---|
4b123bb9 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: glcanvas.i | |
3 | // Purpose: SWIG definitions for the OpenGL wxWindows classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 15-Mar-1999 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module glcanvas | |
15 | ||
16 | %{ | |
6e2129f9 | 17 | #include "wxPython.h" |
b6e2edde RD |
18 | |
19 | #ifdef __WXMAC__ // avoid a bug in Carbon headers | |
20 | #define scalb scalbn | |
21 | #endif | |
22 | ||
0220cbc1 | 23 | #ifdef __WXMSW__ |
19cf4f80 | 24 | #include "myglcanvas.h" |
0220cbc1 RD |
25 | #else |
26 | #include <wx/glcanvas.h> | |
27 | #endif | |
28 | ||
4b123bb9 HH |
29 | %} |
30 | ||
31 | //--------------------------------------------------------------------------- | |
32 | ||
33 | %include typemaps.i | |
34 | %include my_typemaps.i | |
35 | ||
36 | %extern wx.i | |
37 | %extern windows.i | |
38 | %extern windows2.i | |
39 | %extern windows3.i | |
40 | %extern frames.i | |
41 | %extern _defs.i | |
42 | %extern misc.i | |
43 | %extern gdi.i | |
44 | %extern controls.i | |
45 | %extern events.i | |
46 | ||
47 | ||
4b123bb9 HH |
48 | %pragma(python) code = "import wx" |
49 | ||
137b5242 RD |
50 | //---------------------------------------------------------------------- |
51 | ||
52 | %{ | |
53 | // Put some wx default wxChar* values into wxStrings. | |
54 | static const wxString wxPyGLCanvasNameStr(wxT("GLCanvas")); | |
55 | static const wxString wxPyEmptyString(wxT("")); | |
56 | %} | |
57 | ||
4b123bb9 HH |
58 | //--------------------------------------------------------------------------- |
59 | ||
60 | class wxPalette; | |
61 | class wxWindow; | |
62 | class wxSize; | |
63 | class wxPoint; | |
64 | class wxGLCanvas; | |
65 | ||
66 | //--------------------------------------------------------------------------- | |
67 | ||
9416aa89 | 68 | class wxGLContext : public wxObject { |
4b123bb9 | 69 | public: |
b6e5c445 | 70 | #ifndef __WXMAC__ // fix this? |
0122b7e3 RD |
71 | wxGLContext(bool isRGB, wxGLCanvas *win, |
72 | const wxPalette& palette = wxNullPalette); | |
b6e5c445 | 73 | #endif |
4b123bb9 HH |
74 | ~wxGLContext(); |
75 | ||
76 | void SetCurrent(); | |
1e4a197e | 77 | void SetColour(const wxString& colour); |
4b123bb9 HH |
78 | void SwapBuffers(); |
79 | ||
80 | #ifdef __WXGTK__ | |
81 | void SetupPixelFormat(); | |
82 | void SetupPalette(const wxPalette& palette); | |
83 | wxPalette CreateDefaultPalette(); | |
84 | wxPalette* GetPalette(); | |
85 | #endif | |
86 | ||
87 | wxWindow* GetWindow(); | |
88 | }; | |
89 | ||
90 | //--------------------------------------------------------------------------- | |
91 | ||
c3819e4a RD |
92 | enum { |
93 | WX_GL_RGBA, // use true color palette | |
94 | WX_GL_BUFFER_SIZE, // bits for buffer if not WX_GL_RGBA | |
95 | WX_GL_LEVEL, // 0 for main buffer, >0 for overlay, <0 for underlay | |
96 | WX_GL_DOUBLEBUFFER, // use doublebuffer | |
97 | WX_GL_STEREO, // use stereoscopic display | |
98 | WX_GL_AUX_BUFFERS, // number of auxiliary buffers | |
99 | WX_GL_MIN_RED, // use red buffer with most bits (> MIN_RED bits) | |
100 | WX_GL_MIN_GREEN, // use green buffer with most bits (> MIN_GREEN bits) | |
101 | WX_GL_MIN_BLUE, // use blue buffer with most bits (> MIN_BLUE bits) | |
102 | WX_GL_MIN_ALPHA, // use blue buffer with most bits (> MIN_ALPHA bits) | |
103 | WX_GL_DEPTH_SIZE, // bits for Z-buffer (0,16,32) | |
104 | WX_GL_STENCIL_SIZE, // bits for stencil buffer | |
105 | WX_GL_MIN_ACCUM_RED, // use red accum buffer with most bits (> MIN_ACCUM_RED bits) | |
106 | WX_GL_MIN_ACCUM_GREEN, // use green buffer with most bits (> MIN_ACCUM_GREEN bits) | |
107 | WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits) | |
108 | WX_GL_MIN_ACCUM_ALPHA // use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) | |
109 | }; | |
110 | ||
111 | ||
c368d904 RD |
112 | %typemap(python, in) int *attribList (int *temp) { |
113 | int i; | |
114 | if (PySequence_Check($source)) { | |
115 | int size = PyObject_Length($source); | |
116 | temp = new int[size+1]; // (int*)malloc((size + 1) * sizeof(int)); | |
117 | for (i = 0; i < size; i++) { | |
118 | temp[i] = PyInt_AsLong(PySequence_GetItem($source, i)); | |
119 | } | |
120 | temp[size] = 0; | |
121 | $target = temp; | |
122 | } | |
123 | } | |
124 | ||
125 | %typemap(python, freearg) int *attribList | |
126 | { | |
127 | delete [] $source; | |
128 | } | |
129 | ||
130 | ||
131 | ||
ab11ebfa | 132 | class wxGLCanvas : public wxWindow { |
4b123bb9 HH |
133 | public: |
134 | wxGLCanvas(wxWindow *parent, wxWindowID id = -1, | |
1e7ecb7b RD |
135 | const wxPoint& pos = wxDefaultPosition, |
136 | const wxSize& size = wxDefaultSize, long style = 0, | |
137b5242 | 137 | const wxString& name = wxPyGLCanvasNameStr, |
c368d904 | 138 | int *attribList = NULL, |
4b123bb9 HH |
139 | const wxPalette& palette = wxNullPalette); |
140 | ||
0122b7e3 RD |
141 | %name(wxGLCanvasWithContext) |
142 | wxGLCanvas( wxWindow *parent, | |
143 | const wxGLContext *shared = NULL, | |
144 | wxWindowID id = -1, | |
145 | const wxPoint& pos = wxDefaultPosition, | |
146 | const wxSize& size = wxDefaultSize, | |
147 | long style = 0, | |
137b5242 | 148 | const wxString& name = wxPyGLCanvasNameStr, |
0122b7e3 RD |
149 | int *attribList = NULL, |
150 | const wxPalette& palette = wxNullPalette ); | |
151 | ||
0220cbc1 RD |
152 | // bool Create(wxWindow *parent, wxWindowID id, |
153 | // const wxPoint& pos, const wxSize& size, long style, const wxString& name); | |
0122b7e3 RD |
154 | |
155 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
156 | %pragma(python) addtomethod = "wxGLCanvasWithContext:val._setOORInfo(self)" | |
4b123bb9 HH |
157 | |
158 | void SetCurrent(); | |
1e4a197e | 159 | void SetColour(const wxString& colour); |
4b123bb9 HH |
160 | void SwapBuffers(); |
161 | ||
162 | wxGLContext* GetContext(); | |
0122b7e3 | 163 | |
0220cbc1 RD |
164 | #ifdef __WXMSW__ |
165 | void SetupPixelFormat(int *attribList = NULL); | |
166 | void SetupPalette(const wxPalette& palette); | |
167 | wxPalette CreateDefaultPalette(); | |
168 | wxPalette* GetPalette(); | |
169 | #endif | |
4b123bb9 HH |
170 | }; |
171 | ||
172 | ||
173 | //--------------------------------------------------------------------------- | |
174 | ||
4b123bb9 HH |
175 | %init %{ |
176 | ||
4b123bb9 HH |
177 | %} |
178 | ||
179 | //--------------------------------------------------------------------------- | |
180 | //--------------------------------------------------------------------------- |