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