]>
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 | ||
c8fac2b6 RD |
14 | %define DOCSTRING |
15 | "`GLCanvas` provides an OpenGL Context on a `wx.Window`." | |
16 | %enddef | |
b2eb030f RD |
17 | |
18 | %module(package="wx", docstring=DOCSTRING) glcanvas | |
4b123bb9 HH |
19 | |
20 | %{ | |
d14a1e28 RD |
21 | #include "wx/wxPython/wxPython.h" |
22 | #include "wx/wxPython/pyclasses.h" | |
b6e2edde | 23 | |
0220cbc1 | 24 | #include <wx/glcanvas.h> |
0220cbc1 | 25 | |
4b123bb9 HH |
26 | %} |
27 | ||
28 | //--------------------------------------------------------------------------- | |
29 | ||
d14a1e28 | 30 | %import core.i |
54f9ee45 | 31 | %pythoncode { wx = _core } |
99109c0f | 32 | %pythoncode { __docfilter__ = wx.__DocFilter(globals()) } |
137b5242 | 33 | |
b2dc1044 | 34 | |
089142a5 | 35 | MAKE_CONST_WXSTRING2(GLCanvasNameStr, wxT("GLCanvas")); |
b2dc1044 RD |
36 | MAKE_CONST_WXSTRING_NOSWIG(EmptyString); |
37 | ||
4b123bb9 HH |
38 | //--------------------------------------------------------------------------- |
39 | ||
40 | class wxPalette; | |
4b123bb9 HH |
41 | |
42 | //--------------------------------------------------------------------------- | |
43 | ||
ab1f7d2a RD |
44 | MustHaveApp(wxGLContext); |
45 | ||
9416aa89 | 46 | class wxGLContext : public wxObject { |
4b123bb9 | 47 | public: |
8e1a5d3a | 48 | wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL); |
4b123bb9 HH |
49 | ~wxGLContext(); |
50 | ||
925430af | 51 | void SetCurrent(const wxGLCanvas& win); |
4b123bb9 HH |
52 | }; |
53 | ||
54 | //--------------------------------------------------------------------------- | |
55 | ||
c3819e4a RD |
56 | enum { |
57 | WX_GL_RGBA, // use true color palette | |
58 | WX_GL_BUFFER_SIZE, // bits for buffer if not WX_GL_RGBA | |
59 | WX_GL_LEVEL, // 0 for main buffer, >0 for overlay, <0 for underlay | |
60 | WX_GL_DOUBLEBUFFER, // use doublebuffer | |
61 | WX_GL_STEREO, // use stereoscopic display | |
62 | WX_GL_AUX_BUFFERS, // number of auxiliary buffers | |
63 | WX_GL_MIN_RED, // use red buffer with most bits (> MIN_RED bits) | |
64 | WX_GL_MIN_GREEN, // use green buffer with most bits (> MIN_GREEN bits) | |
65 | WX_GL_MIN_BLUE, // use blue buffer with most bits (> MIN_BLUE bits) | |
66 | WX_GL_MIN_ALPHA, // use blue buffer with most bits (> MIN_ALPHA bits) | |
67 | WX_GL_DEPTH_SIZE, // bits for Z-buffer (0,16,32) | |
68 | WX_GL_STENCIL_SIZE, // bits for stencil buffer | |
69 | WX_GL_MIN_ACCUM_RED, // use red accum buffer with most bits (> MIN_ACCUM_RED bits) | |
70 | WX_GL_MIN_ACCUM_GREEN, // use green buffer with most bits (> MIN_ACCUM_GREEN bits) | |
71 | WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits) | |
72 | WX_GL_MIN_ACCUM_ALPHA // use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) | |
73 | }; | |
74 | ||
75 | ||
b4aa9fec | 76 | %typemap(in) const int *attribList (int *temp) { |
c368d904 | 77 | int i; |
d14a1e28 RD |
78 | if (PySequence_Check($input)) { |
79 | int size = PyObject_Length($input); | |
c368d904 RD |
80 | temp = new int[size+1]; // (int*)malloc((size + 1) * sizeof(int)); |
81 | for (i = 0; i < size; i++) { | |
d14a1e28 | 82 | temp[i] = PyInt_AsLong(PySequence_GetItem($input, i)); |
c368d904 RD |
83 | } |
84 | temp[size] = 0; | |
d14a1e28 | 85 | $1 = temp; |
c368d904 RD |
86 | } |
87 | } | |
88 | ||
d14a1e28 | 89 | %typemap(freearg) int *attribList |
c368d904 | 90 | { |
d14a1e28 | 91 | delete [] $1; |
c368d904 RD |
92 | } |
93 | ||
94 | ||
95 | ||
ab1f7d2a RD |
96 | MustHaveApp(wxGLCanvas); |
97 | ||
ab11ebfa | 98 | class wxGLCanvas : public wxWindow { |
4b123bb9 | 99 | public: |
2b9048c5 | 100 | %pythonAppend wxGLCanvas "self._setOORInfo(self)" |
b4aa9fec RD |
101 | wxGLCanvas(wxWindow *parent, |
102 | wxWindowID id = -1, | |
103 | const int *attribList = NULL, | |
1e7ecb7b | 104 | const wxPoint& pos = wxDefaultPosition, |
b4aa9fec RD |
105 | const wxSize& size = wxDefaultSize, |
106 | long style = 0, | |
137b5242 | 107 | const wxString& name = wxPyGLCanvasNameStr, |
4b123bb9 HH |
108 | const wxPalette& palette = wxNullPalette); |
109 | ||
b4aa9fec RD |
110 | bool Create(wxWindow *parent, |
111 | wxWindowID id = wxID_ANY, | |
112 | const wxPoint& pos = wxDefaultPosition, | |
113 | const wxSize& size = wxDefaultSize, | |
114 | long style = 0, | |
115 | const wxString& name = wxGLCanvasName, | |
116 | const int *attribList = NULL, | |
117 | const wxPalette& palette = wxNullPalette); | |
118 | ||
2b9048c5 | 119 | %pythonAppend wxGLCanvas "val._setOORInfo(val)" |
1b8c7ba6 | 120 | %RenameCtor(GLCanvasWithContext, |
0122b7e3 RD |
121 | wxGLCanvas( wxWindow *parent, |
122 | const wxGLContext *shared = NULL, | |
123 | wxWindowID id = -1, | |
124 | const wxPoint& pos = wxDefaultPosition, | |
125 | const wxSize& size = wxDefaultSize, | |
126 | long style = 0, | |
137b5242 | 127 | const wxString& name = wxPyGLCanvasNameStr, |
b4aa9fec | 128 | const int *attribList = NULL, |
1b8c7ba6 | 129 | const wxPalette& palette = wxNullPalette )); |
0122b7e3 | 130 | |
7f442096 | 131 | %nokwargs SetCurrent; |
b4aa9fec | 132 | void SetCurrent(const wxGLContext& context); |
1e4a197e | 133 | void SetColour(const wxString& colour); |
4b123bb9 HH |
134 | void SwapBuffers(); |
135 | ||
b4aa9fec | 136 | // deprecated... |
4b123bb9 | 137 | wxGLContext* GetContext(); |
b4aa9fec | 138 | void SetCurrent(); |
0122b7e3 | 139 | |
e6c222e7 RD |
140 | #ifdef __WXGTK__ |
141 | bool InitVisual(const int *attribList); | |
142 | ||
143 | // What about these? | |
144 | // // return GLX version: 13 means 1.3 &c | |
145 | // static int GetGLXVersion(); | |
146 | ||
147 | // // get the X11 handle of this window | |
148 | // virtual Window GetXWindow() const = 0; | |
149 | ||
150 | #endif | |
b4aa9fec | 151 | |
0220cbc1 | 152 | #ifdef __WXMSW__ |
b4aa9fec | 153 | // void SetupPixelFormat(int *attribList = NULL); |
0220cbc1 RD |
154 | void SetupPalette(const wxPalette& palette); |
155 | wxPalette CreateDefaultPalette(); | |
156 | wxPalette* GetPalette(); | |
157 | #endif | |
e70b4d2d RD |
158 | |
159 | %property(Context, GetContext, doc="See `GetContext`"); | |
4b123bb9 HH |
160 | }; |
161 | ||
162 | ||
163 | //--------------------------------------------------------------------------- | |
164 | ||
4b123bb9 HH |
165 | %init %{ |
166 | ||
4b123bb9 HH |
167 | %} |
168 | ||
169 | //--------------------------------------------------------------------------- | |
170 | //--------------------------------------------------------------------------- |