| 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 "export.h" |
| 18 | #ifdef __WXMSW__ |
| 19 | #include "myglcanvas.h" |
| 20 | #else |
| 21 | #include <wx/glcanvas.h> |
| 22 | #endif |
| 23 | |
| 24 | %} |
| 25 | |
| 26 | //--------------------------------------------------------------------------- |
| 27 | |
| 28 | %include typemaps.i |
| 29 | %include my_typemaps.i |
| 30 | |
| 31 | %extern wx.i |
| 32 | %extern windows.i |
| 33 | %extern windows2.i |
| 34 | %extern windows3.i |
| 35 | %extern frames.i |
| 36 | %extern _defs.i |
| 37 | %extern misc.i |
| 38 | %extern gdi.i |
| 39 | %extern controls.i |
| 40 | %extern events.i |
| 41 | |
| 42 | |
| 43 | %pragma(python) code = "import wx" |
| 44 | |
| 45 | //--------------------------------------------------------------------------- |
| 46 | |
| 47 | class wxPalette; |
| 48 | class wxWindow; |
| 49 | class wxSize; |
| 50 | class wxPoint; |
| 51 | class wxGLCanvas; |
| 52 | |
| 53 | //--------------------------------------------------------------------------- |
| 54 | |
| 55 | class wxGLContext : public wxObject { |
| 56 | public: |
| 57 | #ifndef __WXMAC__ // fix this? |
| 58 | wxGLContext(bool isRGB, wxGLCanvas *win, |
| 59 | const wxPalette& palette = wxNullPalette); |
| 60 | #endif |
| 61 | ~wxGLContext(); |
| 62 | |
| 63 | void SetCurrent(); |
| 64 | void SetColour(const char *colour); |
| 65 | void SwapBuffers(); |
| 66 | |
| 67 | #ifdef __WXGTK__ |
| 68 | void SetupPixelFormat(); |
| 69 | void SetupPalette(const wxPalette& palette); |
| 70 | wxPalette CreateDefaultPalette(); |
| 71 | wxPalette* GetPalette(); |
| 72 | #endif |
| 73 | |
| 74 | wxWindow* GetWindow(); |
| 75 | }; |
| 76 | |
| 77 | //--------------------------------------------------------------------------- |
| 78 | |
| 79 | enum { |
| 80 | WX_GL_RGBA, // use true color palette |
| 81 | WX_GL_BUFFER_SIZE, // bits for buffer if not WX_GL_RGBA |
| 82 | WX_GL_LEVEL, // 0 for main buffer, >0 for overlay, <0 for underlay |
| 83 | WX_GL_DOUBLEBUFFER, // use doublebuffer |
| 84 | WX_GL_STEREO, // use stereoscopic display |
| 85 | WX_GL_AUX_BUFFERS, // number of auxiliary buffers |
| 86 | WX_GL_MIN_RED, // use red buffer with most bits (> MIN_RED bits) |
| 87 | WX_GL_MIN_GREEN, // use green buffer with most bits (> MIN_GREEN bits) |
| 88 | WX_GL_MIN_BLUE, // use blue buffer with most bits (> MIN_BLUE bits) |
| 89 | WX_GL_MIN_ALPHA, // use blue buffer with most bits (> MIN_ALPHA bits) |
| 90 | WX_GL_DEPTH_SIZE, // bits for Z-buffer (0,16,32) |
| 91 | WX_GL_STENCIL_SIZE, // bits for stencil buffer |
| 92 | WX_GL_MIN_ACCUM_RED, // use red accum buffer with most bits (> MIN_ACCUM_RED bits) |
| 93 | WX_GL_MIN_ACCUM_GREEN, // use green buffer with most bits (> MIN_ACCUM_GREEN bits) |
| 94 | WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits) |
| 95 | WX_GL_MIN_ACCUM_ALPHA // use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) |
| 96 | }; |
| 97 | |
| 98 | |
| 99 | %typemap(python, in) int *attribList (int *temp) { |
| 100 | int i; |
| 101 | if (PySequence_Check($source)) { |
| 102 | int size = PyObject_Length($source); |
| 103 | temp = new int[size+1]; // (int*)malloc((size + 1) * sizeof(int)); |
| 104 | for (i = 0; i < size; i++) { |
| 105 | temp[i] = PyInt_AsLong(PySequence_GetItem($source, i)); |
| 106 | } |
| 107 | temp[size] = 0; |
| 108 | $target = temp; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | %typemap(python, freearg) int *attribList |
| 113 | { |
| 114 | delete [] $source; |
| 115 | } |
| 116 | |
| 117 | |
| 118 | |
| 119 | class wxGLCanvas : public wxWindow { |
| 120 | public: |
| 121 | wxGLCanvas(wxWindow *parent, wxWindowID id = -1, |
| 122 | const wxPoint& pos = wxDefaultPosition, |
| 123 | const wxSize& size = wxDefaultSize, long style = 0, |
| 124 | const char* name = "GLCanvas", |
| 125 | int *attribList = NULL, |
| 126 | const wxPalette& palette = wxNullPalette); |
| 127 | |
| 128 | %name(wxGLCanvasWithContext) |
| 129 | wxGLCanvas( wxWindow *parent, |
| 130 | const wxGLContext *shared = NULL, |
| 131 | wxWindowID id = -1, |
| 132 | const wxPoint& pos = wxDefaultPosition, |
| 133 | const wxSize& size = wxDefaultSize, |
| 134 | long style = 0, |
| 135 | const char* name = "GLCanvas", |
| 136 | int *attribList = NULL, |
| 137 | const wxPalette& palette = wxNullPalette ); |
| 138 | |
| 139 | // bool Create(wxWindow *parent, wxWindowID id, |
| 140 | // const wxPoint& pos, const wxSize& size, long style, const wxString& name); |
| 141 | |
| 142 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
| 143 | %pragma(python) addtomethod = "wxGLCanvasWithContext:val._setOORInfo(self)" |
| 144 | |
| 145 | void SetCurrent(); |
| 146 | void SetColour(const char *colour); |
| 147 | void SwapBuffers(); |
| 148 | |
| 149 | wxGLContext* GetContext(); |
| 150 | |
| 151 | #ifdef __WXMSW__ |
| 152 | void SetupPixelFormat(int *attribList = NULL); |
| 153 | void SetupPalette(const wxPalette& palette); |
| 154 | wxPalette CreateDefaultPalette(); |
| 155 | wxPalette* GetPalette(); |
| 156 | #endif |
| 157 | }; |
| 158 | |
| 159 | |
| 160 | //--------------------------------------------------------------------------- |
| 161 | |
| 162 | %init %{ |
| 163 | |
| 164 | wxClassInfo::CleanUpClasses(); |
| 165 | wxClassInfo::InitializeClasses(); |
| 166 | |
| 167 | %} |
| 168 | |
| 169 | //--------------------------------------------------------------------------- |
| 170 | //--------------------------------------------------------------------------- |