Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 2 | Copyright (c) 2000, BeOpen.com. |
| 3 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 4 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 5 | All rights reserved. |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 7 | See the file "Misc/COPYRIGHT" for information on usage and |
| 8 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 9 | ******************************************************************/ |
| 10 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 11 | /* |
| 12 | Input used to generate the Python module "glmodule.c". |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 13 | The stub generator is a Python script called "cgen.py". |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 14 | |
| 15 | Each definition must be contained on one line: |
| 16 | |
| 17 | <returntype> <name> <type> <arg> <type> <arg> |
| 18 | |
| 19 | <returntype> can be: void, short, long (XXX maybe others?) |
| 20 | |
| 21 | <type> can be: char, string, short, float, long, or double |
| 22 | string indicates a null terminated string; |
| 23 | if <type> is char and <arg> begins with a *, the * is stripped |
| 24 | and <type> is changed into string |
| 25 | |
| 26 | <arg> has the form <mode> or <mode>[<subscript>] |
| 27 | where <mode> can be |
| 28 | s: arg is sent |
| 29 | r: arg is received (arg is a pointer) |
| 30 | and <subscript> can be (N and I are numbers): |
| 31 | N |
| 32 | argI |
| 33 | retval |
| 34 | N*argI |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 35 | N*I |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 36 | N*retval |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 37 | In the case where the subscript consists of two parts |
| 38 | separated by *, the first part is the width of the matrix, and |
| 39 | the second part is the length of the matrix. This order is |
| 40 | opposite from the order used in C to declare a two-dimensional |
| 41 | matrix. |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 42 | */ |
| 43 | |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 44 | /* |
| 45 | * An attempt has been made to make this module switch threads on qread |
| 46 | * calls. It is far from safe, though. |
| 47 | */ |
| 48 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 49 | #include <gl.h> |
| 50 | #include <device.h> |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 51 | |
Guido van Rossum | ece35bc | 1996-12-09 18:52:11 +0000 | [diff] [blame] | 52 | #ifdef __sgi |
| 53 | extern int devport(); |
| 54 | extern int textwritemask(); |
| 55 | extern int pagewritemask(); |
| 56 | extern int gewrite(); |
| 57 | extern int gettp(); |
| 58 | #endif |
| 59 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 60 | #include "Python.h" |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 61 | #include "cgensupport.h" |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | Some stubs are too complicated for the stub generator. |
| 65 | We can include manually written versions of them here. |
| 66 | A line starting with '%' gives the name of the function so the stub |
| 67 | generator can include it in the table of functions. |
| 68 | */ |
| 69 | |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 70 | % qread |
| 71 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 72 | static PyObject * |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 73 | gl_qread(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 74 | PyObject *self; |
| 75 | PyObject *args; |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 76 | { |
| 77 | long retval; |
| 78 | short arg1 ; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 79 | Py_BEGIN_ALLOW_THREADS |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 80 | retval = qread( & arg1 ); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 81 | Py_END_ALLOW_THREADS |
| 82 | { PyObject *v = PyTuple_New( 2 ); |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 83 | if (v == NULL) return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 84 | PyTuple_SetItem(v, 0, mknewlongobject(retval)); |
| 85 | PyTuple_SetItem(v, 1, mknewshortobject(arg1)); |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 86 | return v; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 91 | /* |
| 92 | varray -- an array of v.. calls. |
| 93 | The argument is an array (maybe list or tuple) of points. |
| 94 | Each point must be a tuple or list of coordinates (x, y, z). |
| 95 | The points may be 2- or 3-dimensional but must all have the |
| 96 | same dimension. Float and int values may be mixed however. |
| 97 | The points are always converted to 3D double precision points |
| 98 | by assuming z=0.0 if necessary (as indicated in the man page), |
| 99 | and for each point v3d() is called. |
| 100 | */ |
| 101 | |
| 102 | % varray |
| 103 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 104 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 105 | gl_varray(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 106 | PyObject *self; |
| 107 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 108 | { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 109 | PyObject *v, *w=NULL; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 110 | int i, n, width; |
| 111 | double vec[3]; |
Sjoerd Mullender | f28b898 | 2000-08-18 10:00:28 +0000 | [diff] [blame] | 112 | PyObject * (*getitem)(PyObject *, int); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 113 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 114 | if (!PyArg_GetObject(args, 1, 0, &v)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 115 | return NULL; |
| 116 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 117 | if (PyList_Check(v)) { |
| 118 | n = PyList_Size(v); |
| 119 | getitem = PyList_GetItem; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 120 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 121 | else if (PyTuple_Check(v)) { |
| 122 | n = PyTuple_Size(v); |
| 123 | getitem = PyTuple_GetItem; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 124 | } |
| 125 | else { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 126 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 127 | return NULL; |
| 128 | } |
| 129 | |
| 130 | if (n == 0) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 131 | Py_INCREF(Py_None); |
| 132 | return Py_None; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 133 | } |
| 134 | if (n > 0) |
| 135 | w = (*getitem)(v, 0); |
| 136 | |
| 137 | width = 0; |
| 138 | if (w == NULL) { |
| 139 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 140 | else if (PyList_Check(w)) { |
| 141 | width = PyList_Size(w); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 142 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 143 | else if (PyTuple_Check(w)) { |
| 144 | width = PyTuple_Size(w); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | switch (width) { |
| 148 | case 2: |
| 149 | vec[2] = 0.0; |
| 150 | /* Fall through */ |
| 151 | case 3: |
| 152 | break; |
| 153 | default: |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 154 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 155 | return NULL; |
| 156 | } |
| 157 | |
| 158 | for (i = 0; i < n; i++) { |
| 159 | w = (*getitem)(v, i); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 160 | if (!PyArg_GetDoubleArray(w, 1, 0, width, vec)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 161 | return NULL; |
| 162 | v3d(vec); |
| 163 | } |
| 164 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 165 | Py_INCREF(Py_None); |
| 166 | return Py_None; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* |
| 170 | vnarray, nvarray -- an array of n3f and v3f calls. |
| 171 | The argument is an array (list or tuple) of pairs of points and normals. |
| 172 | Each pair is a tuple (NOT a list) of a point and a normal for that point. |
| 173 | Each point or normal must be a tuple (NOT a list) of coordinates (x, y, z). |
| 174 | Three coordinates must be given. Float and int values may be mixed. |
| 175 | For each pair, n3f() is called for the normal, and then v3f() is called |
| 176 | for the vector. |
| 177 | |
| 178 | vnarray and nvarray differ only in the order of the vector and normal in |
| 179 | the pair: vnarray expects (v, n) while nvarray expects (n, v). |
| 180 | */ |
| 181 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 182 | static PyObject *gen_nvarray(); /* Forward */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 183 | |
| 184 | % nvarray |
| 185 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 186 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 187 | gl_nvarray(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 188 | PyObject *self; |
| 189 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 190 | { |
| 191 | return gen_nvarray(args, 0); |
| 192 | } |
| 193 | |
| 194 | % vnarray |
| 195 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 196 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 197 | gl_vnarray(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 198 | PyObject *self; |
| 199 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 200 | { |
| 201 | return gen_nvarray(args, 1); |
| 202 | } |
| 203 | |
| 204 | /* Generic, internal version of {nv,nv}array: inorm indicates the |
| 205 | argument order, 0: normal first, 1: vector first. */ |
| 206 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 207 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 208 | gen_nvarray(args, inorm) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 209 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 210 | int inorm; |
| 211 | { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 212 | PyObject *v, *w, *wnorm, *wvec; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 213 | int i, n; |
| 214 | float norm[3], vec[3]; |
Sjoerd Mullender | f28b898 | 2000-08-18 10:00:28 +0000 | [diff] [blame] | 215 | PyObject * (*getitem)(PyObject *, int); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 216 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 217 | if (!PyArg_GetObject(args, 1, 0, &v)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 218 | return NULL; |
| 219 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 220 | if (PyList_Check(v)) { |
| 221 | n = PyList_Size(v); |
| 222 | getitem = PyList_GetItem; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 223 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 224 | else if (PyTuple_Check(v)) { |
| 225 | n = PyTuple_Size(v); |
| 226 | getitem = PyTuple_GetItem; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 227 | } |
| 228 | else { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 229 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 230 | return NULL; |
| 231 | } |
| 232 | |
| 233 | for (i = 0; i < n; i++) { |
| 234 | w = (*getitem)(v, i); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 235 | if (!PyTuple_Check(w) || PyTuple_Size(w) != 2) { |
| 236 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 237 | return NULL; |
| 238 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 239 | wnorm = PyTuple_GetItem(w, inorm); |
| 240 | wvec = PyTuple_GetItem(w, 1 - inorm); |
| 241 | if (!PyArg_GetFloatArray(wnorm, 1, 0, 3, norm) || |
| 242 | !PyArg_GetFloatArray(wvec, 1, 0, 3, vec)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 243 | return NULL; |
| 244 | n3f(norm); |
| 245 | v3f(vec); |
| 246 | } |
| 247 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 248 | Py_INCREF(Py_None); |
| 249 | return Py_None; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type). |
| 253 | The dimensions of ctl[] are computed as follows: |
| 254 | [len(s_knots) - s_order], [len(t_knots) - t_order] |
| 255 | */ |
| 256 | |
| 257 | % nurbssurface |
| 258 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 259 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 260 | gl_nurbssurface(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 261 | PyObject *self; |
| 262 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 263 | { |
| 264 | long arg1 ; |
| 265 | double * arg2 ; |
| 266 | long arg3 ; |
| 267 | double * arg4 ; |
| 268 | double *arg5 ; |
| 269 | long arg6 ; |
| 270 | long arg7 ; |
| 271 | long arg8 ; |
| 272 | long ncoords; |
| 273 | long s_byte_stride, t_byte_stride; |
| 274 | long s_nctl, t_nctl; |
| 275 | long s, t; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 276 | PyObject *v, *w, *pt; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 277 | double *pnext; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 278 | if (!PyArg_GetLongArraySize(args, 6, 0, &arg1)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 279 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 280 | if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) { |
| 281 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 282 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 283 | if (!PyArg_GetDoubleArray(args, 6, 0, arg1 , arg2)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 284 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 285 | if (!PyArg_GetLongArraySize(args, 6, 1, &arg3)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 286 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 287 | if ((arg4 = PyMem_NEW(double, arg3 )) == NULL) { |
| 288 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 289 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 290 | if (!PyArg_GetDoubleArray(args, 6, 1, arg3 , arg4)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 291 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 292 | if (!PyArg_GetLong(args, 6, 3, &arg6)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 293 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 294 | if (!PyArg_GetLong(args, 6, 4, &arg7)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 295 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 296 | if (!PyArg_GetLong(args, 6, 5, &arg8)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 297 | return NULL; |
| 298 | if (arg8 == N_XYZ) |
| 299 | ncoords = 3; |
| 300 | else if (arg8 == N_XYZW) |
| 301 | ncoords = 4; |
| 302 | else { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 303 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 304 | return NULL; |
| 305 | } |
| 306 | s_nctl = arg1 - arg6; |
| 307 | t_nctl = arg3 - arg7; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 308 | if (!PyArg_GetObject(args, 6, 2, &v)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 309 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 310 | if (!PyList_Check(v) || PyList_Size(v) != s_nctl) { |
| 311 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 312 | return NULL; |
| 313 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 314 | if ((arg5 = PyMem_NEW(double, s_nctl*t_nctl*ncoords )) == NULL) { |
| 315 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 316 | } |
| 317 | pnext = arg5; |
| 318 | for (s = 0; s < s_nctl; s++) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 319 | w = PyList_GetItem(v, s); |
| 320 | if (w == NULL || !PyList_Check(w) || |
| 321 | PyList_Size(w) != t_nctl) { |
| 322 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 323 | return NULL; |
| 324 | } |
| 325 | for (t = 0; t < t_nctl; t++) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 326 | pt = PyList_GetItem(w, t); |
| 327 | if (!PyArg_GetDoubleArray(pt, 1, 0, ncoords, pnext)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 328 | return NULL; |
| 329 | pnext += ncoords; |
| 330 | } |
| 331 | } |
| 332 | s_byte_stride = sizeof(double) * ncoords; |
| 333 | t_byte_stride = s_byte_stride * s_nctl; |
| 334 | nurbssurface( arg1 , arg2 , arg3 , arg4 , |
| 335 | s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 ); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 336 | PyMem_DEL(arg2); |
| 337 | PyMem_DEL(arg4); |
| 338 | PyMem_DEL(arg5); |
| 339 | Py_INCREF(Py_None); |
| 340 | return Py_None; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /* nurbscurve(knots, ctlpoints, order, type). |
| 344 | The length of ctlpoints is len(knots)-order. */ |
| 345 | |
| 346 | %nurbscurve |
| 347 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 348 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 349 | gl_nurbscurve(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 350 | PyObject *self; |
| 351 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 352 | { |
| 353 | long arg1 ; |
| 354 | double * arg2 ; |
| 355 | long arg3 ; |
| 356 | double * arg4 ; |
| 357 | long arg5 ; |
| 358 | long arg6 ; |
| 359 | int ncoords, npoints; |
| 360 | int i; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 361 | PyObject *v; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 362 | double *pnext; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 363 | if (!PyArg_GetLongArraySize(args, 4, 0, &arg1)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 364 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 365 | if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) { |
| 366 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 367 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 368 | if (!PyArg_GetDoubleArray(args, 4, 0, arg1 , arg2)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 369 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 370 | if (!PyArg_GetLong(args, 4, 2, &arg5)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 371 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 372 | if (!PyArg_GetLong(args, 4, 3, &arg6)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 373 | return NULL; |
| 374 | if (arg6 == N_ST) |
| 375 | ncoords = 2; |
| 376 | else if (arg6 == N_STW) |
| 377 | ncoords = 3; |
| 378 | else { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 379 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 380 | return NULL; |
| 381 | } |
| 382 | npoints = arg1 - arg5; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 383 | if (!PyArg_GetObject(args, 4, 1, &v)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 384 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 385 | if (!PyList_Check(v) || PyList_Size(v) != npoints) { |
| 386 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 387 | return NULL; |
| 388 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 389 | if ((arg4 = PyMem_NEW(double, npoints*ncoords )) == NULL) { |
| 390 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 391 | } |
| 392 | pnext = arg4; |
| 393 | for (i = 0; i < npoints; i++) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 394 | if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 395 | return NULL; |
| 396 | pnext += ncoords; |
| 397 | } |
| 398 | arg3 = (sizeof(double)) * ncoords; |
| 399 | nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 400 | PyMem_DEL(arg2); |
| 401 | PyMem_DEL(arg4); |
| 402 | Py_INCREF(Py_None); |
| 403 | return Py_None; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | /* pwlcurve(points, type). |
| 407 | Points is a list of points. Type must be N_ST. */ |
| 408 | |
| 409 | %pwlcurve |
| 410 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 411 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 412 | gl_pwlcurve(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 413 | PyObject *self; |
| 414 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 415 | { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 416 | PyObject *v; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 417 | long type; |
| 418 | double *data, *pnext; |
| 419 | long npoints, ncoords; |
| 420 | int i; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 421 | if (!PyArg_GetObject(args, 2, 0, &v)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 422 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 423 | if (!PyArg_GetLong(args, 2, 1, &type)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 424 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 425 | if (!PyList_Check(v)) { |
| 426 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 427 | return NULL; |
| 428 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 429 | npoints = PyList_Size(v); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 430 | if (type == N_ST) |
| 431 | ncoords = 2; |
| 432 | else { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 433 | PyErr_BadArgument(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 434 | return NULL; |
| 435 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 436 | if ((data = PyMem_NEW(double, npoints*ncoords)) == NULL) { |
| 437 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 438 | } |
| 439 | pnext = data; |
| 440 | for (i = 0; i < npoints; i++) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 441 | if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 442 | return NULL; |
| 443 | pnext += ncoords; |
| 444 | } |
| 445 | pwlcurve(npoints, data, sizeof(double)*ncoords, type); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 446 | PyMem_DEL(data); |
| 447 | Py_INCREF(Py_None); |
| 448 | return Py_None; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | |
| 452 | /* Picking and Selecting */ |
| 453 | |
| 454 | static short *pickbuffer = NULL; |
| 455 | static long pickbuffersize; |
| 456 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 457 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 458 | pick_select(args, func) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 459 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 460 | void (*func)(); |
| 461 | { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 462 | if (!PyArg_GetLong(args, 1, 0, &pickbuffersize)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 463 | return NULL; |
| 464 | if (pickbuffer != NULL) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 465 | PyErr_SetString(PyExc_RuntimeError, |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 466 | "pick/gselect: already picking/selecting"); |
| 467 | return NULL; |
| 468 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 469 | if ((pickbuffer = PyMem_NEW(short, pickbuffersize)) == NULL) { |
| 470 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 471 | } |
| 472 | (*func)(pickbuffer, pickbuffersize); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 473 | Py_INCREF(Py_None); |
| 474 | return Py_None; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 475 | } |
| 476 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 477 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 478 | endpick_select(args, func) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 479 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 480 | long (*func)(); |
| 481 | { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 482 | PyObject *v, *w; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 483 | int i, nhits, n; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 484 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 485 | return NULL; |
| 486 | if (pickbuffer == NULL) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 487 | PyErr_SetString(PyExc_RuntimeError, |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 488 | "endpick/endselect: not in pick/select mode"); |
| 489 | return NULL; |
| 490 | } |
| 491 | nhits = (*func)(pickbuffer); |
| 492 | if (nhits < 0) { |
| 493 | nhits = -nhits; /* How to report buffer overflow otherwise? */ |
| 494 | } |
| 495 | /* Scan the buffer to see how many integers */ |
| 496 | n = 0; |
| 497 | for (; nhits > 0; nhits--) { |
| 498 | n += 1 + pickbuffer[n]; |
| 499 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 500 | v = PyList_New(n); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 501 | if (v == NULL) |
| 502 | return NULL; |
| 503 | /* XXX Could do it nicer and interpret the data structure here, |
| 504 | returning a list of lists. But this can be done in Python... */ |
| 505 | for (i = 0; i < n; i++) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 506 | w = PyInt_FromLong((long)pickbuffer[i]); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 507 | if (w == NULL) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 508 | Py_DECREF(v); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 509 | return NULL; |
| 510 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 511 | PyList_SetItem(v, i, w); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 512 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 513 | PyMem_DEL(pickbuffer); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 514 | pickbuffer = NULL; |
| 515 | return v; |
| 516 | } |
| 517 | |
| 518 | extern void pick(), gselect(); |
| 519 | extern long endpick(), endselect(); |
| 520 | |
| 521 | %pick |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 522 | static PyObject *gl_pick(self, args) PyObject *self, *args; { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 523 | return pick_select(args, pick); |
| 524 | } |
| 525 | |
| 526 | %endpick |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 527 | static PyObject *gl_endpick(self, args) PyObject *self, *args; { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 528 | return endpick_select(args, endpick); |
| 529 | } |
| 530 | |
| 531 | %gselect |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 532 | static PyObject *gl_gselect(self, args) PyObject *self, *args; { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 533 | return pick_select(args, gselect); |
| 534 | } |
| 535 | |
| 536 | %endselect |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 537 | static PyObject *gl_endselect(self, args) PyObject *self, *args; { |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 538 | return endpick_select(args, endselect); |
| 539 | } |
| 540 | |
| 541 | |
| 542 | /* XXX The generator botches this one. Here's a quick hack to fix it. */ |
| 543 | |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 544 | /* XXX The generator botches this one. Here's a quick hack to fix it. */ |
| 545 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 546 | % getmatrix float r[16] |
| 547 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 548 | static PyObject * |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 549 | gl_getmatrix(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 550 | PyObject *self; |
| 551 | PyObject *args; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 552 | { |
Sjoerd Mullender | 3bb8a05 | 1993-10-22 12:04:32 +0000 | [diff] [blame] | 553 | Matrix arg1; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 554 | PyObject *v, *w; |
Sjoerd Mullender | 3bb8a05 | 1993-10-22 12:04:32 +0000 | [diff] [blame] | 555 | int i, j; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 556 | getmatrix( arg1 ); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 557 | v = PyList_New(16); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 558 | if (v == NULL) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 559 | return PyErr_NoMemory(); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 560 | } |
Sjoerd Mullender | 3bb8a05 | 1993-10-22 12:04:32 +0000 | [diff] [blame] | 561 | for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { |
| 562 | w = mknewfloatobject(arg1[i][j]); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 563 | if (w == NULL) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 564 | Py_DECREF(v); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 565 | return NULL; |
| 566 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 567 | PyList_SetItem(v, i*4+j, w); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 568 | } |
| 569 | return v; |
| 570 | } |
| 571 | |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 572 | /* Here's an alternate version that returns a 4x4 matrix instead of |
| 573 | a vector. Unfortunately it is incompatible with loadmatrix and |
| 574 | multmatrix... */ |
| 575 | |
| 576 | % altgetmatrix float r[4][4] |
| 577 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 578 | static PyObject * |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 579 | gl_altgetmatrix(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 580 | PyObject *self; |
| 581 | PyObject *args; |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 582 | { |
Sjoerd Mullender | 3bb8a05 | 1993-10-22 12:04:32 +0000 | [diff] [blame] | 583 | Matrix arg1; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 584 | PyObject *v, *w; |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 585 | int i, j; |
| 586 | getmatrix( arg1 ); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 587 | v = PyList_New(4); |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 588 | if (v == NULL) { |
| 589 | return NULL; |
| 590 | } |
| 591 | for (i = 0; i < 4; i++) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 592 | w = PyList_New(4); |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 593 | if (w == NULL) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 594 | Py_DECREF(v); |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 595 | return NULL; |
| 596 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 597 | PyList_SetItem(v, i, w); |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 598 | } |
| 599 | for (i = 0; i < 4; i++) { |
| 600 | for (j = 0; j < 4; j++) { |
| 601 | w = mknewfloatobject(arg1[i][j]); |
| 602 | if (w == NULL) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 603 | Py_DECREF(v); |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 604 | return NULL; |
| 605 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 606 | PyList_SetItem(PyList_GetItem(v, i), j, w); |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 607 | } |
| 608 | } |
| 609 | return v; |
| 610 | } |
| 611 | |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 612 | % lrectwrite |
| 613 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 614 | static PyObject * |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 615 | gl_lrectwrite(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 616 | PyObject *self; |
| 617 | PyObject *args; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 618 | { |
| 619 | short x1 ; |
| 620 | short y1 ; |
| 621 | short x2 ; |
| 622 | short y2 ; |
| 623 | string parray ; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 624 | PyObject *s; |
Guido van Rossum | ece35bc | 1996-12-09 18:52:11 +0000 | [diff] [blame] | 625 | #if 0 |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 626 | int pixcount; |
Guido van Rossum | ece35bc | 1996-12-09 18:52:11 +0000 | [diff] [blame] | 627 | #endif |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 628 | if (!PyArg_GetShort(args, 5, 0, &x1)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 629 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 630 | if (!PyArg_GetShort(args, 5, 1, &y1)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 631 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 632 | if (!PyArg_GetShort(args, 5, 2, &x2)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 633 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 634 | if (!PyArg_GetShort(args, 5, 3, &y2)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 635 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 636 | if (!PyArg_GetString(args, 5, 4, &parray)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 637 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 638 | if (!PyArg_GetObject(args, 5, 4, &s)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 639 | return NULL; |
Guido van Rossum | 6d0b5a7 | 1991-11-12 15:41:00 +0000 | [diff] [blame] | 640 | #if 0 |
| 641 | /* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */ |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 642 | pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 643 | if (!PyString_Check(s) || PyString_Size(s) != pixcount*sizeof(long)) { |
| 644 | PyErr_SetString(PyExc_RuntimeError, |
Guido van Rossum | 6d0b5a7 | 1991-11-12 15:41:00 +0000 | [diff] [blame] | 645 | "string arg to lrectwrite has wrong size"); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 646 | return NULL; |
| 647 | } |
Guido van Rossum | 6d0b5a7 | 1991-11-12 15:41:00 +0000 | [diff] [blame] | 648 | #endif |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 649 | lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray ); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 650 | Py_INCREF(Py_None); |
| 651 | return Py_None; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | % lrectread |
| 655 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 656 | static PyObject * |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 657 | gl_lrectread(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 658 | PyObject *self; |
| 659 | PyObject *args; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 660 | { |
| 661 | short x1 ; |
| 662 | short y1 ; |
| 663 | short x2 ; |
| 664 | short y2 ; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 665 | PyObject *parray; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 666 | int pixcount; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 667 | if (!PyArg_GetShort(args, 4, 0, &x1)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 668 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 669 | if (!PyArg_GetShort(args, 4, 1, &y1)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 670 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 671 | if (!PyArg_GetShort(args, 4, 2, &x2)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 672 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 673 | if (!PyArg_GetShort(args, 4, 3, &y2)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 674 | return NULL; |
| 675 | pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 676 | parray = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long)); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 677 | if (parray == NULL) |
| 678 | return NULL; /* No memory */ |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 679 | lrectread(x1, y1, x2, y2, (unsigned long *) PyString_AsString(parray)); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 680 | return parray; |
| 681 | } |
| 682 | |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 683 | % readdisplay |
| 684 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 685 | static PyObject * |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 686 | gl_readdisplay(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 687 | PyObject *self; |
| 688 | PyObject *args; |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 689 | { |
| 690 | short x1, y1, x2, y2; |
| 691 | unsigned long *parray, hints; |
| 692 | long size, size_ret; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 693 | PyObject *rv; |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 694 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 695 | if ( !PyArg_Parse(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) ) |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 696 | return 0; |
| 697 | size = (long)(x2+1-x1) * (long)(y2+1-y1); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 698 | rv = PyString_FromStringAndSize((char *)NULL, size*sizeof(long)); |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 699 | if ( rv == NULL ) |
| 700 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 701 | parray = (unsigned long *)PyString_AsString(rv); |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 702 | size_ret = readdisplay(x1, y1, x2, y2, parray, hints); |
| 703 | if ( size_ret != size ) { |
Guido van Rossum | ece35bc | 1996-12-09 18:52:11 +0000 | [diff] [blame] | 704 | printf("gl_readdisplay: got %ld pixels, expected %ld\n", |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 705 | size_ret, size); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 706 | PyErr_SetString(PyExc_RuntimeError, "readdisplay returned unexpected length"); |
Jack Jansen | 5fc6773 | 1993-02-16 09:25:15 +0000 | [diff] [blame] | 707 | return NULL; |
| 708 | } |
| 709 | return rv; |
| 710 | } |
| 711 | |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 712 | /* Desperately needed, here are tools to compress and decompress |
| 713 | the data manipulated by lrectread/lrectwrite. |
| 714 | |
| 715 | gl.packrect(width, height, packfactor, bigdata) --> smalldata |
| 716 | makes 'bigdata' 4*(packfactor**2) times smaller by: |
| 717 | - turning it into B/W (a factor 4) |
| 718 | - replacing squares of size pacfactor by one |
| 719 | representative |
| 720 | |
| 721 | gl.unpackrect(width, height, packfactor, smalldata) --> bigdata |
| 722 | is the inverse; the numeric arguments must be *the same*. |
| 723 | |
| 724 | Both work best if width and height are multiples of packfactor |
| 725 | (in fact unpackrect will leave garbage bytes). |
| 726 | */ |
| 727 | |
| 728 | % packrect |
| 729 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 730 | static PyObject * |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 731 | gl_packrect(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 732 | PyObject *self; |
| 733 | PyObject *args; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 734 | { |
| 735 | long width, height, packfactor; |
| 736 | char *s; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 737 | PyObject *unpacked, *packed; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 738 | int pixcount, packedcount, x, y, r, g, b; |
| 739 | unsigned long pixel; |
| 740 | unsigned char *p; |
| 741 | unsigned long *parray; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 742 | if (!PyArg_GetLong(args, 4, 0, &width)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 743 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 744 | if (!PyArg_GetLong(args, 4, 1, &height)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 745 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 746 | if (!PyArg_GetLong(args, 4, 2, &packfactor)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 747 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 748 | if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */ |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 749 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 750 | if (!PyArg_GetObject(args, 4, 3, &unpacked)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 751 | return NULL; |
| 752 | if (width <= 0 || height <= 0 || packfactor <= 0) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 753 | PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0"); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 754 | return NULL; |
| 755 | } |
| 756 | pixcount = width*height; |
| 757 | packedcount = ((width+packfactor-1)/packfactor) * |
| 758 | ((height+packfactor-1)/packfactor); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 759 | if (PyString_Size(unpacked) != pixcount*sizeof(long)) { |
| 760 | PyErr_SetString(PyExc_RuntimeError, |
Guido van Rossum | 6d0b5a7 | 1991-11-12 15:41:00 +0000 | [diff] [blame] | 761 | "string arg to packrect has wrong size"); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 762 | return NULL; |
| 763 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 764 | packed = PyString_FromStringAndSize((char *)NULL, packedcount); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 765 | if (packed == NULL) |
| 766 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 767 | parray = (unsigned long *) PyString_AsString(unpacked); |
| 768 | p = (unsigned char *) PyString_AsString(packed); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 769 | for (y = 0; y < height; y += packfactor, parray += packfactor*width) { |
| 770 | for (x = 0; x < width; x += packfactor) { |
| 771 | pixel = parray[x]; |
| 772 | r = pixel & 0xff; |
| 773 | g = (pixel >> 8) & 0xff; |
| 774 | b = (pixel >> 16) & 0xff; |
Guido van Rossum | 6d0b5a7 | 1991-11-12 15:41:00 +0000 | [diff] [blame] | 775 | *p++ = (30*r+59*g+11*b) / 100; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 776 | } |
| 777 | } |
| 778 | return packed; |
| 779 | } |
| 780 | |
| 781 | % unpackrect |
| 782 | |
| 783 | static unsigned long unpacktab[256]; |
| 784 | static int unpacktab_inited = 0; |
| 785 | |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 786 | static PyObject * |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 787 | gl_unpackrect(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 788 | PyObject *self; |
| 789 | PyObject *args; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 790 | { |
| 791 | long width, height, packfactor; |
| 792 | char *s; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 793 | PyObject *unpacked, *packed; |
Guido van Rossum | ece35bc | 1996-12-09 18:52:11 +0000 | [diff] [blame] | 794 | int pixcount, packedcount; |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 795 | register unsigned char *p; |
| 796 | register unsigned long *parray; |
| 797 | if (!unpacktab_inited) { |
| 798 | register int white; |
| 799 | for (white = 256; --white >= 0; ) |
| 800 | unpacktab[white] = white * 0x010101L; |
| 801 | unpacktab_inited++; |
| 802 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 803 | if (!PyArg_GetLong(args, 4, 0, &width)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 804 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 805 | if (!PyArg_GetLong(args, 4, 1, &height)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 806 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 807 | if (!PyArg_GetLong(args, 4, 2, &packfactor)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 808 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 809 | if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */ |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 810 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 811 | if (!PyArg_GetObject(args, 4, 3, &packed)) |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 812 | return NULL; |
| 813 | if (width <= 0 || height <= 0 || packfactor <= 0) { |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 814 | PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0"); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 815 | return NULL; |
| 816 | } |
| 817 | pixcount = width*height; |
| 818 | packedcount = ((width+packfactor-1)/packfactor) * |
| 819 | ((height+packfactor-1)/packfactor); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 820 | if (PyString_Size(packed) != packedcount) { |
| 821 | PyErr_SetString(PyExc_RuntimeError, |
Guido van Rossum | 6d0b5a7 | 1991-11-12 15:41:00 +0000 | [diff] [blame] | 822 | "string arg to unpackrect has wrong size"); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 823 | return NULL; |
| 824 | } |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 825 | unpacked = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long)); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 826 | if (unpacked == NULL) |
| 827 | return NULL; |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 828 | parray = (unsigned long *) PyString_AsString(unpacked); |
| 829 | p = (unsigned char *) PyString_AsString(packed); |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 830 | if (packfactor == 1 && width*height > 0) { |
| 831 | /* Just expand bytes to longs */ |
| 832 | register int x = width * height; |
| 833 | do { |
| 834 | *parray++ = unpacktab[*p++]; |
| 835 | } while (--x >= 0); |
| 836 | } |
| 837 | else { |
| 838 | register int y; |
| 839 | for (y = 0; y < height-packfactor+1; |
| 840 | y += packfactor, parray += packfactor*width) { |
| 841 | register int x; |
| 842 | for (x = 0; x < width-packfactor+1; x += packfactor) { |
| 843 | register unsigned long pixel = unpacktab[*p++]; |
| 844 | register int i; |
| 845 | for (i = packfactor*width; (i-=width) >= 0;) { |
| 846 | register int j; |
| 847 | for (j = packfactor; --j >= 0; ) |
| 848 | parray[i+x+j] = pixel; |
| 849 | } |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | return unpacked; |
| 854 | } |
| 855 | |
Guido van Rossum | aee0879 | 1992-09-08 09:05:33 +0000 | [diff] [blame] | 856 | % gversion |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 857 | static PyObject * |
Guido van Rossum | aee0879 | 1992-09-08 09:05:33 +0000 | [diff] [blame] | 858 | gl_gversion(self, args) |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 859 | PyObject *self; |
| 860 | PyObject *args; |
Guido van Rossum | aee0879 | 1992-09-08 09:05:33 +0000 | [diff] [blame] | 861 | { |
| 862 | char buf[20]; |
| 863 | gversion(buf); |
Guido van Rossum | 0a3eaf0 | 1997-04-29 15:39:28 +0000 | [diff] [blame] | 864 | return PyString_FromString(buf); |
Guido van Rossum | aee0879 | 1992-09-08 09:05:33 +0000 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | |
Guido van Rossum | 5c069fd | 1998-04-28 16:09:16 +0000 | [diff] [blame] | 868 | /* void clear - Manual because of clash with termcap */ |
| 869 | %clear |
| 870 | static PyObject * |
| 871 | gl_clear(self, args) |
| 872 | PyObject *self; |
| 873 | PyObject *args; |
| 874 | { |
| 875 | __GLclear( ); |
| 876 | Py_INCREF(Py_None); |
| 877 | return Py_None; |
| 878 | } |
| 879 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 880 | /* End of manually written stubs */ |
| 881 | |
| 882 | %% |
| 883 | |
| 884 | long getshade |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 885 | if !solaris void devport short s long s |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 886 | void rdr2i long s long s |
| 887 | void rectfs short s short s short s short s |
| 888 | void rects short s short s short s short s |
| 889 | void rmv2i long s long s |
| 890 | void noport |
| 891 | void popviewport |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 892 | void clearhitcode |
| 893 | void closeobj |
| 894 | void cursoff |
| 895 | void curson |
| 896 | void doublebuffer |
| 897 | void finish |
| 898 | void gconfig |
| 899 | void ginit |
| 900 | void greset |
| 901 | void multimap |
| 902 | void onemap |
| 903 | void popattributes |
| 904 | void popmatrix |
| 905 | void pushattributes |
| 906 | void pushmatrix |
| 907 | void pushviewport |
| 908 | void qreset |
| 909 | void RGBmode |
| 910 | void singlebuffer |
| 911 | void swapbuffers |
| 912 | void gsync |
Guido van Rossum | 06a6702 | 1992-02-26 15:19:45 +0000 | [diff] [blame] | 913 | void gflush |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 914 | void tpon |
| 915 | void tpoff |
| 916 | void clkon |
| 917 | void clkoff |
| 918 | void ringbell |
| 919 | #void callfunc |
| 920 | void gbegin |
| 921 | void textinit |
| 922 | void initnames |
| 923 | void pclos |
| 924 | void popname |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 925 | if !solaris void spclos |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 926 | void zclear |
| 927 | void screenspace |
| 928 | void reshapeviewport |
| 929 | void winpush |
| 930 | void winpop |
| 931 | void foreground |
| 932 | void endfullscrn |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 933 | if !solaris void endpupmode |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 934 | void fullscrn |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 935 | if !solaris void pupmode |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 936 | void winconstraints |
| 937 | void pagecolor short s |
| 938 | void textcolor short s |
| 939 | void color short s |
| 940 | void curveit short s |
| 941 | void font short s |
| 942 | void linewidth short s |
| 943 | void setlinestyle short s |
| 944 | void setmap short s |
| 945 | void swapinterval short s |
| 946 | void writemask short s |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 947 | if !solaris void textwritemask short s |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 948 | void qdevice short s |
| 949 | void unqdevice short s |
| 950 | void curvebasis short s |
| 951 | void curveprecision short s |
| 952 | void loadname short s |
| 953 | void passthrough short s |
| 954 | void pushname short s |
| 955 | void setmonitor short s |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 956 | if !solaris void setshade short s |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 957 | void setpattern short s |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 958 | if !solaris void pagewritemask short s |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 959 | # |
| 960 | void callobj long s |
| 961 | void delobj long s |
| 962 | void editobj long s |
| 963 | void makeobj long s |
| 964 | void maketag long s |
| 965 | void chunksize long s |
| 966 | void compactify long s |
| 967 | void deltag long s |
| 968 | void lsrepeat long s |
| 969 | void objinsert long s |
| 970 | void objreplace long s |
| 971 | void winclose long s |
| 972 | void blanktime long s |
| 973 | void freepup long s |
| 974 | # This is not in the library!? |
| 975 | ###void pupcolor long s |
| 976 | # |
| 977 | void backbuffer long s |
| 978 | void frontbuffer long s |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 979 | if !solaris void lsbackup long s |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 980 | void resetls long s |
| 981 | void lampon long s |
| 982 | void lampoff long s |
| 983 | void setbell long s |
| 984 | void blankscreen long s |
| 985 | void depthcue long s |
| 986 | void zbuffer long s |
| 987 | void backface long s |
| 988 | # |
| 989 | void cmov2i long s long s |
| 990 | void draw2i long s long s |
| 991 | void move2i long s long s |
| 992 | void pnt2i long s long s |
| 993 | void patchbasis long s long s |
| 994 | void patchprecision long s long s |
| 995 | void pdr2i long s long s |
| 996 | void pmv2i long s long s |
| 997 | void rpdr2i long s long s |
| 998 | void rpmv2i long s long s |
| 999 | void xfpt2i long s long s |
| 1000 | void objdelete long s long s |
| 1001 | void patchcurves long s long s |
| 1002 | void minsize long s long s |
| 1003 | void maxsize long s long s |
| 1004 | void keepaspect long s long s |
| 1005 | void prefsize long s long s |
| 1006 | void stepunit long s long s |
| 1007 | void fudge long s long s |
| 1008 | void winmove long s long s |
| 1009 | # |
| 1010 | void attachcursor short s short s |
| 1011 | void deflinestyle short s short s |
| 1012 | void noise short s short s |
| 1013 | void picksize short s short s |
| 1014 | void qenter short s short s |
| 1015 | void setdepth short s short s |
| 1016 | void cmov2s short s short s |
| 1017 | void draw2s short s short s |
| 1018 | void move2s short s short s |
| 1019 | void pdr2s short s short s |
| 1020 | void pmv2s short s short s |
| 1021 | void pnt2s short s short s |
| 1022 | void rdr2s short s short s |
| 1023 | void rmv2s short s short s |
| 1024 | void rpdr2s short s short s |
| 1025 | void rpmv2s short s short s |
| 1026 | void xfpt2s short s short s |
| 1027 | # |
| 1028 | void cmov2 float s float s |
| 1029 | void draw2 float s float s |
| 1030 | void move2 float s float s |
| 1031 | void pnt2 float s float s |
| 1032 | void pdr2 float s float s |
| 1033 | void pmv2 float s float s |
| 1034 | void rdr2 float s float s |
| 1035 | void rmv2 float s float s |
| 1036 | void rpdr2 float s float s |
| 1037 | void rpmv2 float s float s |
| 1038 | void xfpt2 float s float s |
| 1039 | # |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1040 | void loadmatrix float s[4*4] |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 1041 | # Really [4][4] |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1042 | void multmatrix float s[4*4] |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 1043 | # Really [4][4] |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1044 | void crv float s[3*4] |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 1045 | # Really [4][3] |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1046 | void rcrv float s[4*4] |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 1047 | # Really [4][4] |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1048 | # |
| 1049 | # Methods that have strings. |
| 1050 | # |
| 1051 | void addtopup long s char *s long s |
| 1052 | void charstr char *s |
| 1053 | void getport char *s |
| 1054 | long strwidth char *s |
| 1055 | long winopen char *s |
| 1056 | void wintitle char *s |
| 1057 | # |
| 1058 | # Methods that have 1 long (# of elements) and an array |
| 1059 | # |
| 1060 | void polf long s float s[3*arg1] |
| 1061 | void polf2 long s float s[2*arg1] |
| 1062 | void poly long s float s[3*arg1] |
| 1063 | void poly2 long s float s[2*arg1] |
| 1064 | void crvn long s float s[3*arg1] |
| 1065 | void rcrvn long s float s[4*arg1] |
| 1066 | # |
| 1067 | void polf2i long s long s[2*arg1] |
| 1068 | void polfi long s long s[3*arg1] |
| 1069 | void poly2i long s long s[2*arg1] |
| 1070 | void polyi long s long s[3*arg1] |
| 1071 | # |
| 1072 | void polf2s long s short s[2*arg1] |
| 1073 | void polfs long s short s[3*arg1] |
| 1074 | void polys long s short s[3*arg1] |
| 1075 | void poly2s long s short s[2*arg1] |
| 1076 | # |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1077 | void defcursor short s u_short s[128] |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 1078 | # Is this useful? |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1079 | void writepixels short s u_short s[arg1] |
Guido van Rossum | b316515 | 1991-08-16 08:59:21 +0000 | [diff] [blame] | 1080 | # Should be unsigned short... |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1081 | void defbasis long s float s[4*4] |
| 1082 | if !solaris void gewrite short s short s[arg1] |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1083 | # |
| 1084 | void rotate short s char s |
| 1085 | # This is not in the library!? |
| 1086 | ###void setbutton short s char s |
| 1087 | void rot float s char s |
| 1088 | # |
| 1089 | void circfi long s long s long s |
| 1090 | void circi long s long s long s |
| 1091 | void cmovi long s long s long s |
| 1092 | void drawi long s long s long s |
| 1093 | void movei long s long s long s |
| 1094 | void pnti long s long s long s |
| 1095 | void newtag long s long s long s |
| 1096 | void pdri long s long s long s |
| 1097 | void pmvi long s long s long s |
| 1098 | void rdri long s long s long s |
| 1099 | void rmvi long s long s long s |
| 1100 | void rpdri long s long s long s |
| 1101 | void rpmvi long s long s long s |
| 1102 | void xfpti long s long s long s |
| 1103 | # |
| 1104 | void circ float s float s float s |
| 1105 | void circf float s float s float s |
| 1106 | void cmov float s float s float s |
| 1107 | void draw float s float s float s |
| 1108 | void move float s float s float s |
| 1109 | void pnt float s float s float s |
| 1110 | void scale float s float s float s |
| 1111 | void translate float s float s float s |
| 1112 | void pdr float s float s float s |
| 1113 | void pmv float s float s float s |
| 1114 | void rdr float s float s float s |
| 1115 | void rmv float s float s float s |
| 1116 | void rpdr float s float s float s |
| 1117 | void rpmv float s float s float s |
| 1118 | void xfpt float s float s float s |
| 1119 | # |
| 1120 | void RGBcolor short s short s short s |
| 1121 | void RGBwritemask short s short s short s |
| 1122 | void setcursor short s short s short s |
| 1123 | void tie short s short s short s |
| 1124 | void circfs short s short s short s |
| 1125 | void circs short s short s short s |
| 1126 | void cmovs short s short s short s |
| 1127 | void draws short s short s short s |
| 1128 | void moves short s short s short s |
| 1129 | void pdrs short s short s short s |
| 1130 | void pmvs short s short s short s |
| 1131 | void pnts short s short s short s |
| 1132 | void rdrs short s short s short s |
| 1133 | void rmvs short s short s short s |
| 1134 | void rpdrs short s short s short s |
| 1135 | void rpmvs short s short s short s |
| 1136 | void xfpts short s short s short s |
| 1137 | void curorigin short s short s short s |
| 1138 | void cyclemap short s short s short s |
| 1139 | # |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1140 | void patch float s[4*4] float s[4*4] float s[4*4] |
| 1141 | void splf long s float s[3*arg1] u_short s[arg1] |
| 1142 | void splf2 long s float s[2*arg1] u_short s[arg1] |
| 1143 | void splfi long s long s[3*arg1] u_short s[arg1] |
| 1144 | void splf2i long s long s[2*arg1] u_short s[arg1] |
| 1145 | void splfs long s short s[3*arg1] u_short s[arg1] |
| 1146 | void splf2s long s short s[2*arg1] u_short s[arg1] |
| 1147 | ###void defpattern short s short s u_short s[arg2*arg2/16] |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1148 | # |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1149 | void rpatch float s[4*4] float s[4*4] float s[4*4] float s[4*4] |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1150 | # |
| 1151 | # routines that send 4 floats |
| 1152 | # |
| 1153 | void ortho2 float s float s float s float s |
| 1154 | void rect float s float s float s float s |
| 1155 | void rectf float s float s float s float s |
| 1156 | void xfpt4 float s float s float s float s |
| 1157 | # |
| 1158 | void textport short s short s short s short s |
| 1159 | void mapcolor short s short s short s short s |
| 1160 | void scrmask short s short s short s short s |
| 1161 | void setvaluator short s short s short s short s |
| 1162 | void viewport short s short s short s short s |
| 1163 | void shaderange short s short s short s short s |
| 1164 | void xfpt4s short s short s short s short s |
| 1165 | void rectfi long s long s long s long s |
| 1166 | void recti long s long s long s long s |
| 1167 | void xfpt4i long s long s long s long s |
| 1168 | void prefposition long s long s long s long s |
| 1169 | # |
| 1170 | void arc float s float s float s short s short s |
| 1171 | void arcf float s float s float s short s short s |
| 1172 | void arcfi long s long s long s short s short s |
| 1173 | void arci long s long s long s short s short s |
| 1174 | # |
| 1175 | void bbox2 short s short s float s float s float s float s |
| 1176 | void bbox2i short s short s long s long s long s long s |
| 1177 | void bbox2s short s short s short s short s short s short s |
| 1178 | void blink short s short s short s short s short s |
| 1179 | void ortho float s float s float s float s float s float s |
| 1180 | void window float s float s float s float s float s float s |
| 1181 | void lookat float s float s float s float s float s float s short s |
| 1182 | # |
| 1183 | void perspective short s float s float s float s |
| 1184 | void polarview float s short s short s short s |
| 1185 | # XXX getichararray not supported |
| 1186 | #void writeRGB short s char s[arg1] char s[arg1] char s[arg1] |
| 1187 | # |
| 1188 | void arcfs short s short s short s short s short s |
| 1189 | void arcs short s short s short s short s short s |
| 1190 | void rectcopy short s short s short s short s short s short s |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1191 | if !solaris void RGBcursor short s short s short s short s short s short s short s |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1192 | # |
| 1193 | long getbutton short s |
| 1194 | long getcmmode |
| 1195 | long getlsbackup |
| 1196 | long getresetls |
| 1197 | long getdcm |
| 1198 | long getzbuffer |
| 1199 | long ismex |
| 1200 | long isobj long s |
| 1201 | long isqueued short s |
| 1202 | long istag long s |
| 1203 | # |
| 1204 | long genobj |
| 1205 | long gentag |
| 1206 | long getbuffer |
| 1207 | long getcolor |
| 1208 | long getdisplaymode |
| 1209 | long getfont |
| 1210 | long getheight |
| 1211 | long gethitcode |
| 1212 | long getlstyle |
| 1213 | long getlwidth |
| 1214 | long getmap |
| 1215 | long getplanes |
| 1216 | long getwritemask |
| 1217 | long qtest |
| 1218 | long getlsrepeat |
| 1219 | long getmonitor |
| 1220 | long getopenobj |
| 1221 | long getpattern |
| 1222 | long winget |
| 1223 | long winattach |
| 1224 | long getothermonitor |
| 1225 | long newpup |
| 1226 | # |
| 1227 | long getvaluator short s |
| 1228 | void winset long s |
| 1229 | long dopup long s |
| 1230 | void getdepth short r short r |
| 1231 | void getcpos short r short r |
| 1232 | void getsize long r long r |
| 1233 | void getorigin long r long r |
| 1234 | void getviewport short r short r short r short r |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1235 | if !solaris void gettp short r short r short r short r |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1236 | void getgpos float r float r float r float r |
| 1237 | void winposition long s long s long s long s |
| 1238 | void gRGBcolor short r short r short r |
| 1239 | void gRGBmask short r short r short r |
| 1240 | void getscrmask short r short r short r short r |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 1241 | ###void gRGBcursor short r short r short r short r short r short r short r short r |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1242 | void getmcolor short s short r short r short r |
| 1243 | void mapw long s short s short s float r float r float r float r float r float r |
| 1244 | void mapw2 long s short s short s float r float r |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 1245 | ###void defrasterfont short s short s short s Fontchar s[arg3] short s short s[4*arg5] |
Guido van Rossum | 3978903 | 1992-08-13 14:23:56 +0000 | [diff] [blame] | 1246 | ###long qread short r |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1247 | void getcursor short r u_short r u_short r long r |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1248 | # |
| 1249 | # For these we receive arrays of stuff |
| 1250 | # |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 1251 | ###void getdev long s short s[arg1] short r[arg1] |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1252 | #XXX not generated correctly yet |
| 1253 | #void getmatrix float r[16] |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 1254 | ###long readpixels short s short r[retval] |
| 1255 | ###long readRGB short s char r[retval] char r[retval] char r[retval] |
| 1256 | ###long blkqread short s short r[arg1] |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1257 | # |
| 1258 | # New 4D routines |
| 1259 | # |
| 1260 | void cmode |
| 1261 | void concave long s |
| 1262 | void curstype long s |
| 1263 | void drawmode long s |
| 1264 | void gammaramp short s[256] short s[256] short s[256] |
| 1265 | long getbackface |
| 1266 | long getdescender |
| 1267 | long getdrawmode |
| 1268 | long getmmode |
| 1269 | long getsm |
| 1270 | long getvideo long s |
| 1271 | void imakebackground |
| 1272 | void lmbind short s short s |
| 1273 | void lmdef long s long s long s float s[arg3] |
| 1274 | void mmode long s |
| 1275 | void normal float s[3] |
| 1276 | void overlay long s |
| 1277 | void RGBrange short s short s short s short s short s short s short s short s |
Sjoerd Mullender | c4f169c | 1993-12-21 17:06:12 +0000 | [diff] [blame] | 1278 | if !solaris void setvideo long s long s |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1279 | void shademodel long s |
| 1280 | void underlay long s |
| 1281 | # |
| 1282 | # New Personal Iris/GT Routines |
| 1283 | # |
| 1284 | void bgnclosedline |
| 1285 | void bgnline |
| 1286 | void bgnpoint |
| 1287 | void bgnpolygon |
| 1288 | void bgnsurface |
| 1289 | void bgntmesh |
| 1290 | void bgntrim |
| 1291 | void endclosedline |
| 1292 | void endline |
| 1293 | void endpoint |
| 1294 | void endpolygon |
| 1295 | void endsurface |
| 1296 | void endtmesh |
| 1297 | void endtrim |
| 1298 | void blendfunction long s long s |
| 1299 | void c3f float s[3] |
| 1300 | void c3i long s[3] |
| 1301 | void c3s short s[3] |
| 1302 | void c4f float s[4] |
| 1303 | void c4i long s[4] |
| 1304 | void c4s short s[4] |
| 1305 | void colorf float s |
| 1306 | void cpack long s |
| 1307 | void czclear long s long s |
| 1308 | void dglclose long s |
| 1309 | long dglopen char *s long s |
| 1310 | long getgdesc long s |
| 1311 | void getnurbsproperty long s float r |
| 1312 | void glcompat long s long s |
| 1313 | void iconsize long s long s |
| 1314 | void icontitle char *s |
| 1315 | void lRGBrange short s short s short s short s short s short s long s long s |
| 1316 | void linesmooth long s |
| 1317 | void lmcolor long s |
| 1318 | void logicop long s |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 1319 | ###long lrectread short s short s short s short s long r[retval] |
| 1320 | ###void lrectwrite short s short s short s short s long s[(arg2-arg1+1)*(arg4-arg3+1)] |
| 1321 | ### Now manual, with string last arg |
| 1322 | ###long rectread short s short s short s short s short r[retval] |
| 1323 | ###void rectwrite short s short s short s short s short s[(arg2-arg1+1)*(arg4-arg3+1)] |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 1324 | void lsetdepth long s long s |
| 1325 | void lshaderange short s short s long s long s |
| 1326 | void n3f float s[3] |
| 1327 | void noborder |
| 1328 | void pntsmooth long s |
| 1329 | void readsource long s |
| 1330 | void rectzoom float s float s |
| 1331 | void sbox float s float s float s float s |
| 1332 | void sboxi long s long s long s long s |
| 1333 | void sboxs short s short s short s short s |
| 1334 | void sboxf float s float s float s float s |
| 1335 | void sboxfi long s long s long s long s |
| 1336 | void sboxfs short s short s short s short s |
| 1337 | void setnurbsproperty long s float s |
| 1338 | void setpup long s long s long s |
| 1339 | void smoothline long s |
| 1340 | void subpixel long s |
| 1341 | void swaptmesh |
| 1342 | long swinopen long s |
| 1343 | void v2f float s[2] |
| 1344 | void v2i long s[2] |
| 1345 | void v2s short s[2] |
| 1346 | void v3f float s[3] |
| 1347 | void v3i long s[3] |
| 1348 | void v3s short s[3] |
| 1349 | void v4f float s[4] |
| 1350 | void v4i long s[4] |
| 1351 | void v4s short s[4] |
| 1352 | void videocmd long s |
| 1353 | long windepth long s |
| 1354 | void wmpack long s |
| 1355 | void zdraw long s |
| 1356 | void zfunction long s |
| 1357 | void zsource long s |
| 1358 | void zwritemask long s |
| 1359 | # |
| 1360 | # uses doubles |
| 1361 | # |
| 1362 | void v2d double s[2] |
| 1363 | void v3d double s[3] |
| 1364 | void v4d double s[4] |
Guido van Rossum | d26d9ed | 1991-10-20 20:13:40 +0000 | [diff] [blame] | 1365 | # |
| 1366 | # Why isn't this here? |
| 1367 | # |
| 1368 | void pixmode long s long s |
Guido van Rossum | dd9ed83 | 1992-06-29 17:10:40 +0000 | [diff] [blame] | 1369 | # |
| 1370 | # New in IRIX 4.0 |
| 1371 | # |
| 1372 | long qgetfd |
Jack Jansen | fa1b9f6 | 1993-02-19 12:53:12 +0000 | [diff] [blame] | 1373 | void dither long s |