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