]>
Commit | Line | Data |
---|---|---|
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 | %{ | |
17 | #include "wx/wxPython/wxPython.h" | |
18 | #include "wx/wxPython/pyclasses.h" | |
19 | ||
20 | #include <wx/glcanvas.h> | |
21 | ||
22 | static const wxString wxPyGLCanvasNameStr(wxT("GLCanvas")); | |
23 | static const wxString wxPyEmptyString(wxT("")); | |
24 | %} | |
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | ||
28 | %import core.i | |
29 | %pythoncode { wx = core } | |
30 | ||
31 | %include _glcanvas_rename.i | |
32 | ||
33 | //--------------------------------------------------------------------------- | |
34 | ||
35 | class wxPalette; | |
36 | ||
37 | //--------------------------------------------------------------------------- | |
38 | ||
39 | class wxGLContext : public wxObject { | |
40 | public: | |
41 | #ifndef __WXMAC__ | |
42 | wxGLContext(bool isRGB, wxGLCanvas *win, | |
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 | ||
55 | #endif | |
56 | ~wxGLContext(); | |
57 | ||
58 | void SetCurrent(); | |
59 | void SetColour(const wxString& colour); | |
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 | ||
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 | ||
94 | %typemap(in) int *attribList (int *temp) { | |
95 | int i; | |
96 | if (PySequence_Check($input)) { | |
97 | int size = PyObject_Length($input); | |
98 | temp = new int[size+1]; // (int*)malloc((size + 1) * sizeof(int)); | |
99 | for (i = 0; i < size; i++) { | |
100 | temp[i] = PyInt_AsLong(PySequence_GetItem($input, i)); | |
101 | } | |
102 | temp[size] = 0; | |
103 | $1 = temp; | |
104 | } | |
105 | } | |
106 | ||
107 | %typemap(freearg) int *attribList | |
108 | { | |
109 | delete [] $1; | |
110 | } | |
111 | ||
112 | ||
113 | ||
114 | class wxGLCanvas : public wxWindow { | |
115 | public: | |
116 | %addtofunc wxGLCanvas "self._setOORInfo(self)" | |
117 | wxGLCanvas(wxWindow *parent, wxWindowID id = -1, | |
118 | const wxPoint& pos = wxDefaultPosition, | |
119 | const wxSize& size = wxDefaultSize, long style = 0, | |
120 | const wxString& name = wxPyGLCanvasNameStr, | |
121 | int *attribList = NULL, | |
122 | const wxPalette& palette = wxNullPalette); | |
123 | ||
124 | %addtofunc wxGLCanvas "val._setOORInfo(val)" | |
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, | |
132 | const wxString& name = wxPyGLCanvasNameStr, | |
133 | int *attribList = NULL, | |
134 | const wxPalette& palette = wxNullPalette ); | |
135 | ||
136 | ||
137 | void SetCurrent(); | |
138 | void SetColour(const wxString& colour); | |
139 | void SwapBuffers(); | |
140 | ||
141 | wxGLContext* GetContext(); | |
142 | ||
143 | #ifdef __WXMSW__ | |
144 | void SetupPixelFormat(int *attribList = NULL); | |
145 | void SetupPalette(const wxPalette& palette); | |
146 | wxPalette CreateDefaultPalette(); | |
147 | wxPalette* GetPalette(); | |
148 | #endif | |
149 | }; | |
150 | ||
151 | ||
152 | //--------------------------------------------------------------------------- | |
153 | ||
154 | %init %{ | |
155 | ||
156 | %} | |
157 | ||
158 | //--------------------------------------------------------------------------- | |
159 | //--------------------------------------------------------------------------- |