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