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