]>
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: |
d14a1e28 | 48 | #ifndef __WXMAC__ |
0122b7e3 | 49 | wxGLContext(bool isRGB, wxGLCanvas *win, |
d14a1e28 RD |
50 | const wxPalette& palette = wxNullPalette, |
51 | const wxGLContext* other = NULL); | |
52 | #else | |
53 | %extend { | |
54 | wxGLContext(bool isRGB, wxGLCanvas *win, | |
55 | const wxPalette& palette = wxNullPalette, | |
56 | const wxGLContext* other = NULL) { | |
57 | AGLPixelFormat fmt; // TODO: How should this be initialized? | |
58 | return new wxGLContext(fmt, win, palette, other); | |
59 | } | |
60 | } | |
61 | ||
b6e5c445 | 62 | #endif |
4b123bb9 HH |
63 | ~wxGLContext(); |
64 | ||
65 | void SetCurrent(); | |
1e4a197e | 66 | void SetColour(const wxString& colour); |
4b123bb9 HH |
67 | void SwapBuffers(); |
68 | ||
69 | #ifdef __WXGTK__ | |
70 | void SetupPixelFormat(); | |
71 | void SetupPalette(const wxPalette& palette); | |
72 | wxPalette CreateDefaultPalette(); | |
73 | wxPalette* GetPalette(); | |
74 | #endif | |
75 | ||
76 | wxWindow* GetWindow(); | |
77 | }; | |
78 | ||
79 | //--------------------------------------------------------------------------- | |
80 | ||
c3819e4a RD |
81 | enum { |
82 | WX_GL_RGBA, // use true color palette | |
83 | WX_GL_BUFFER_SIZE, // bits for buffer if not WX_GL_RGBA | |
84 | WX_GL_LEVEL, // 0 for main buffer, >0 for overlay, <0 for underlay | |
85 | WX_GL_DOUBLEBUFFER, // use doublebuffer | |
86 | WX_GL_STEREO, // use stereoscopic display | |
87 | WX_GL_AUX_BUFFERS, // number of auxiliary buffers | |
88 | WX_GL_MIN_RED, // use red buffer with most bits (> MIN_RED bits) | |
89 | WX_GL_MIN_GREEN, // use green buffer with most bits (> MIN_GREEN bits) | |
90 | WX_GL_MIN_BLUE, // use blue buffer with most bits (> MIN_BLUE bits) | |
91 | WX_GL_MIN_ALPHA, // use blue buffer with most bits (> MIN_ALPHA bits) | |
92 | WX_GL_DEPTH_SIZE, // bits for Z-buffer (0,16,32) | |
93 | WX_GL_STENCIL_SIZE, // bits for stencil buffer | |
94 | WX_GL_MIN_ACCUM_RED, // use red accum buffer with most bits (> MIN_ACCUM_RED bits) | |
95 | WX_GL_MIN_ACCUM_GREEN, // use green buffer with most bits (> MIN_ACCUM_GREEN bits) | |
96 | WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits) | |
97 | WX_GL_MIN_ACCUM_ALPHA // use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) | |
98 | }; | |
99 | ||
100 | ||
d14a1e28 | 101 | %typemap(in) int *attribList (int *temp) { |
c368d904 | 102 | int i; |
d14a1e28 RD |
103 | if (PySequence_Check($input)) { |
104 | int size = PyObject_Length($input); | |
c368d904 RD |
105 | temp = new int[size+1]; // (int*)malloc((size + 1) * sizeof(int)); |
106 | for (i = 0; i < size; i++) { | |
d14a1e28 | 107 | temp[i] = PyInt_AsLong(PySequence_GetItem($input, i)); |
c368d904 RD |
108 | } |
109 | temp[size] = 0; | |
d14a1e28 | 110 | $1 = temp; |
c368d904 RD |
111 | } |
112 | } | |
113 | ||
d14a1e28 | 114 | %typemap(freearg) int *attribList |
c368d904 | 115 | { |
d14a1e28 | 116 | delete [] $1; |
c368d904 RD |
117 | } |
118 | ||
119 | ||
120 | ||
ab1f7d2a RD |
121 | MustHaveApp(wxGLCanvas); |
122 | ||
ab11ebfa | 123 | class wxGLCanvas : public wxWindow { |
4b123bb9 | 124 | public: |
2b9048c5 | 125 | %pythonAppend wxGLCanvas "self._setOORInfo(self)" |
4b123bb9 | 126 | wxGLCanvas(wxWindow *parent, wxWindowID id = -1, |
1e7ecb7b RD |
127 | const wxPoint& pos = wxDefaultPosition, |
128 | const wxSize& size = wxDefaultSize, long style = 0, | |
137b5242 | 129 | const wxString& name = wxPyGLCanvasNameStr, |
c368d904 | 130 | int *attribList = NULL, |
4b123bb9 HH |
131 | const wxPalette& palette = wxNullPalette); |
132 | ||
2b9048c5 | 133 | %pythonAppend wxGLCanvas "val._setOORInfo(val)" |
1b8c7ba6 | 134 | %RenameCtor(GLCanvasWithContext, |
0122b7e3 RD |
135 | wxGLCanvas( wxWindow *parent, |
136 | const wxGLContext *shared = NULL, | |
137 | wxWindowID id = -1, | |
138 | const wxPoint& pos = wxDefaultPosition, | |
139 | const wxSize& size = wxDefaultSize, | |
140 | long style = 0, | |
137b5242 | 141 | const wxString& name = wxPyGLCanvasNameStr, |
0122b7e3 | 142 | int *attribList = NULL, |
1b8c7ba6 | 143 | const wxPalette& palette = wxNullPalette )); |
0122b7e3 | 144 | |
4b123bb9 HH |
145 | |
146 | void SetCurrent(); | |
1e4a197e | 147 | void SetColour(const wxString& colour); |
4b123bb9 HH |
148 | void SwapBuffers(); |
149 | ||
150 | wxGLContext* GetContext(); | |
0122b7e3 | 151 | |
0220cbc1 RD |
152 | #ifdef __WXMSW__ |
153 | void SetupPixelFormat(int *attribList = NULL); | |
154 | void SetupPalette(const wxPalette& palette); | |
155 | wxPalette CreateDefaultPalette(); | |
156 | wxPalette* GetPalette(); | |
157 | #endif | |
4b123bb9 HH |
158 | }; |
159 | ||
160 | ||
161 | //--------------------------------------------------------------------------- | |
162 | ||
4b123bb9 HH |
163 | %init %{ |
164 | ||
4b123bb9 HH |
165 | %} |
166 | ||
167 | //--------------------------------------------------------------------------- | |
168 | //--------------------------------------------------------------------------- |