cstubs 32.8 KB
Newer Older
1
/***********************************************************
Guido van Rossum's avatar
Guido van Rossum committed
2 3 4 5 6 7 8
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
All rights reserved.

See the file "Misc/COPYRIGHT" for information on usage and
redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9 10
******************************************************************/

Guido van Rossum's avatar
Guido van Rossum committed
11 12
/*
Input used to generate the Python module "glmodule.c".
13
The stub generator is a Python script called "cgen.py".
Guido van Rossum's avatar
Guido van Rossum committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

Each definition must be contained on one line:

<returntype> <name> <type> <arg> <type> <arg>

<returntype> can be: void, short, long (XXX maybe others?)

<type> can be: char, string, short, float, long, or double
	string indicates a null terminated string;
	if <type> is char and <arg> begins with a *, the * is stripped
	and <type> is changed into string

<arg> has the form <mode> or <mode>[<subscript>]
	where <mode> can be
		s: arg is sent
		r: arg is received		(arg is a pointer)
	and <subscript> can be (N and I are numbers):
		N
		argI
		retval
		N*argI
35
		N*I
Guido van Rossum's avatar
Guido van Rossum committed
36
		N*retval
37 38 39 40 41
	In the case where the subscript consists of two parts
	separated by *, the first part is the width of the matrix, and
	the second part is the length of the matrix.  This order is
	opposite from the order used in C to declare a two-dimensional
	matrix.
Guido van Rossum's avatar
Guido van Rossum committed
42 43
*/

44 45 46 47 48
/*
 * An attempt has been made to make this module switch threads on qread
 * calls. It is far from safe, though.
 */

Guido van Rossum's avatar
Guido van Rossum committed
49 50
#include <gl.h>
#include <device.h>
Guido van Rossum's avatar
Guido van Rossum committed
51

52 53 54 55 56 57 58 59
#ifdef __sgi
extern int devport();
extern int textwritemask();
extern int pagewritemask();
extern int gewrite();
extern int gettp();
#endif

Guido van Rossum's avatar
Guido van Rossum committed
60
#include "Python.h"
Guido van Rossum's avatar
Guido van Rossum committed
61 62 63 64 65 66 67 68 69
#include "cgensupport.h"

/*
Some stubs are too complicated for the stub generator.
We can include manually written versions of them here.
A line starting with '%' gives the name of the function so the stub
generator can include it in the table of functions.
*/

70 71
% qread

Guido van Rossum's avatar
Guido van Rossum committed
72
static PyObject *
73
gl_qread(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
74 75
	PyObject *self;
	PyObject *args;
76 77 78
{
	long retval;
	short arg1 ;
Guido van Rossum's avatar
Guido van Rossum committed
79
	Py_BEGIN_ALLOW_THREADS
80
	retval = qread( & arg1 );
Guido van Rossum's avatar
Guido van Rossum committed
81 82
	Py_END_ALLOW_THREADS
	{ PyObject *v = PyTuple_New( 2 );
83
	  if (v == NULL) return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
84 85
	  PyTuple_SetItem(v, 0, mknewlongobject(retval));
	  PyTuple_SetItem(v, 1, mknewshortobject(arg1));
86 87 88 89 90
	  return v;
	}
}


Guido van Rossum's avatar
Guido van Rossum committed
91 92 93 94 95 96 97 98 99 100 101 102 103
/*
varray -- an array of v.. calls.
The argument is an array (maybe list or tuple) of points.
Each point must be a tuple or list of coordinates (x, y, z).
The points may be 2- or 3-dimensional but must all have the
same dimension.  Float and int values may be mixed however.
The points are always converted to 3D double precision points
by assuming z=0.0 if necessary (as indicated in the man page),
and for each point v3d() is called.
*/

% varray

Guido van Rossum's avatar
Guido van Rossum committed
104
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
105
gl_varray(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
106 107
	PyObject *self;
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
108
{
Guido van Rossum's avatar
Guido van Rossum committed
109
	PyObject *v, *w=NULL;
Guido van Rossum's avatar
Guido van Rossum committed
110 111
	int i, n, width;
	double vec[3];
112
	PyObject * (*getitem)(PyObject *, int);
Guido van Rossum's avatar
Guido van Rossum committed
113
	
Guido van Rossum's avatar
Guido van Rossum committed
114
	if (!PyArg_GetObject(args, 1, 0, &v))
Guido van Rossum's avatar
Guido van Rossum committed
115 116
		return NULL;
	
Guido van Rossum's avatar
Guido van Rossum committed
117 118 119
	if (PyList_Check(v)) {
		n = PyList_Size(v);
		getitem = PyList_GetItem;
Guido van Rossum's avatar
Guido van Rossum committed
120
	}
Guido van Rossum's avatar
Guido van Rossum committed
121 122 123
	else if (PyTuple_Check(v)) {
		n = PyTuple_Size(v);
		getitem = PyTuple_GetItem;
Guido van Rossum's avatar
Guido van Rossum committed
124 125
	}
	else {
Guido van Rossum's avatar
Guido van Rossum committed
126
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
127 128 129 130
		return NULL;
	}
	
	if (n == 0) {
Guido van Rossum's avatar
Guido van Rossum committed
131 132
		Py_INCREF(Py_None);
		return Py_None;
Guido van Rossum's avatar
Guido van Rossum committed
133 134 135 136 137 138 139
	}
	if (n > 0)
		w = (*getitem)(v, 0);
	
	width = 0;
	if (w == NULL) {
	}
Guido van Rossum's avatar
Guido van Rossum committed
140 141
	else if (PyList_Check(w)) {
		width = PyList_Size(w);
Guido van Rossum's avatar
Guido van Rossum committed
142
	}
Guido van Rossum's avatar
Guido van Rossum committed
143 144
	else if (PyTuple_Check(w)) {
		width = PyTuple_Size(w);
Guido van Rossum's avatar
Guido van Rossum committed
145 146 147 148 149 150 151 152 153
	}
	
	switch (width) {
	case 2:
		vec[2] = 0.0;
		/* Fall through */
	case 3:
		break;
	default:
Guido van Rossum's avatar
Guido van Rossum committed
154
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
155 156 157 158 159
		return NULL;
	}
	
	for (i = 0; i < n; i++) {
		w = (*getitem)(v, i);
Guido van Rossum's avatar
Guido van Rossum committed
160
		if (!PyArg_GetDoubleArray(w, 1, 0, width, vec))
Guido van Rossum's avatar
Guido van Rossum committed
161 162 163 164
			return NULL;
		v3d(vec);
	}
	
Guido van Rossum's avatar
Guido van Rossum committed
165 166
	Py_INCREF(Py_None);
	return Py_None;
Guido van Rossum's avatar
Guido van Rossum committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
}

/*
vnarray, nvarray -- an array of n3f and v3f calls.
The argument is an array (list or tuple) of pairs of points and normals.
Each pair is a tuple (NOT a list) of a point and a normal for that point.
Each point or normal must be a tuple (NOT a list) of coordinates (x, y, z).
Three coordinates must be given.  Float and int values may be mixed.
For each pair, n3f() is called for the normal, and then v3f() is called
for the vector.

vnarray and nvarray differ only in the order of the vector and normal in
the pair: vnarray expects (v, n) while nvarray expects (n, v).
*/

Guido van Rossum's avatar
Guido van Rossum committed
182
static PyObject *gen_nvarray(); /* Forward */
Guido van Rossum's avatar
Guido van Rossum committed
183 184 185

% nvarray

Guido van Rossum's avatar
Guido van Rossum committed
186
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
187
gl_nvarray(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
188 189
	PyObject *self;
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
190 191 192 193 194 195
{
	return gen_nvarray(args, 0);
}

% vnarray

Guido van Rossum's avatar
Guido van Rossum committed
196
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
197
gl_vnarray(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
198 199
	PyObject *self;
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
200 201 202 203 204 205 206
{
	return gen_nvarray(args, 1);
}

/* Generic, internal version of {nv,nv}array: inorm indicates the
   argument order, 0: normal first, 1: vector first. */

Guido van Rossum's avatar
Guido van Rossum committed
207
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
208
gen_nvarray(args, inorm)
Guido van Rossum's avatar
Guido van Rossum committed
209
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
210 211
	int inorm;
{
Guido van Rossum's avatar
Guido van Rossum committed
212
	PyObject *v, *w, *wnorm, *wvec;
Guido van Rossum's avatar
Guido van Rossum committed
213 214
	int i, n;
	float norm[3], vec[3];
215
	PyObject * (*getitem)(PyObject *, int);
Guido van Rossum's avatar
Guido van Rossum committed
216
	
Guido van Rossum's avatar
Guido van Rossum committed
217
	if (!PyArg_GetObject(args, 1, 0, &v))
Guido van Rossum's avatar
Guido van Rossum committed
218 219
		return NULL;
	
Guido van Rossum's avatar
Guido van Rossum committed
220 221 222
	if (PyList_Check(v)) {
		n = PyList_Size(v);
		getitem = PyList_GetItem;
Guido van Rossum's avatar
Guido van Rossum committed
223
	}
Guido van Rossum's avatar
Guido van Rossum committed
224 225 226
	else if (PyTuple_Check(v)) {
		n = PyTuple_Size(v);
		getitem = PyTuple_GetItem;
Guido van Rossum's avatar
Guido van Rossum committed
227 228
	}
	else {
Guido van Rossum's avatar
Guido van Rossum committed
229
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
230 231 232 233 234
		return NULL;
	}
	
	for (i = 0; i < n; i++) {
		w = (*getitem)(v, i);
Guido van Rossum's avatar
Guido van Rossum committed
235 236
		if (!PyTuple_Check(w) || PyTuple_Size(w) != 2) {
			PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
237 238
			return NULL;
		}
Guido van Rossum's avatar
Guido van Rossum committed
239 240 241 242
		wnorm = PyTuple_GetItem(w, inorm);
		wvec = PyTuple_GetItem(w, 1 - inorm);
		if (!PyArg_GetFloatArray(wnorm, 1, 0, 3, norm) ||
			!PyArg_GetFloatArray(wvec, 1, 0, 3, vec))
Guido van Rossum's avatar
Guido van Rossum committed
243 244 245 246 247
			return NULL;
		n3f(norm);
		v3f(vec);
	}
	
Guido van Rossum's avatar
Guido van Rossum committed
248 249
	Py_INCREF(Py_None);
	return Py_None;
Guido van Rossum's avatar
Guido van Rossum committed
250 251 252 253 254 255 256 257 258
}

/* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type).
   The dimensions of ctl[] are computed as follows:
   [len(s_knots) - s_order], [len(t_knots) - t_order]
*/

% nurbssurface

Guido van Rossum's avatar
Guido van Rossum committed
259
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
260
gl_nurbssurface(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
261 262
	PyObject *self;
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
263 264 265 266 267 268 269 270 271 272 273 274 275
{
	long arg1 ;
	double * arg2 ;
	long arg3 ;
	double * arg4 ;
	double *arg5 ;
	long arg6 ;
	long arg7 ;
	long arg8 ;
	long ncoords;
	long s_byte_stride, t_byte_stride;
	long s_nctl, t_nctl;
	long s, t;
Guido van Rossum's avatar
Guido van Rossum committed
276
	PyObject *v, *w, *pt;
Guido van Rossum's avatar
Guido van Rossum committed
277
	double *pnext;
Guido van Rossum's avatar
Guido van Rossum committed
278
	if (!PyArg_GetLongArraySize(args, 6, 0, &arg1))
Guido van Rossum's avatar
Guido van Rossum committed
279
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
280 281
	if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) {
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
282
	}
Guido van Rossum's avatar
Guido van Rossum committed
283
	if (!PyArg_GetDoubleArray(args, 6, 0, arg1 , arg2))
Guido van Rossum's avatar
Guido van Rossum committed
284
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
285
	if (!PyArg_GetLongArraySize(args, 6, 1, &arg3))
Guido van Rossum's avatar
Guido van Rossum committed
286
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
287 288
	if ((arg4 = PyMem_NEW(double, arg3 )) == NULL) {
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
289
	}
Guido van Rossum's avatar
Guido van Rossum committed
290
	if (!PyArg_GetDoubleArray(args, 6, 1, arg3 , arg4))
Guido van Rossum's avatar
Guido van Rossum committed
291
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
292
	if (!PyArg_GetLong(args, 6, 3, &arg6))
Guido van Rossum's avatar
Guido van Rossum committed
293
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
294
	if (!PyArg_GetLong(args, 6, 4, &arg7))
Guido van Rossum's avatar
Guido van Rossum committed
295
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
296
	if (!PyArg_GetLong(args, 6, 5, &arg8))
Guido van Rossum's avatar
Guido van Rossum committed
297 298 299 300 301 302
		return NULL;
	if (arg8 == N_XYZ)
		ncoords = 3;
	else if (arg8 == N_XYZW)
		ncoords = 4;
	else {
Guido van Rossum's avatar
Guido van Rossum committed
303
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
304 305 306 307
		return NULL;
	}
	s_nctl = arg1 - arg6;
	t_nctl = arg3 - arg7;
Guido van Rossum's avatar
Guido van Rossum committed
308
	if (!PyArg_GetObject(args, 6, 2, &v))
Guido van Rossum's avatar
Guido van Rossum committed
309
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
310 311
	if (!PyList_Check(v) || PyList_Size(v) != s_nctl) {
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
312 313
		return NULL;
	}
Guido van Rossum's avatar
Guido van Rossum committed
314 315
	if ((arg5 = PyMem_NEW(double, s_nctl*t_nctl*ncoords )) == NULL) {
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
316 317 318
	}
	pnext = arg5;
	for (s = 0; s < s_nctl; s++) {
Guido van Rossum's avatar
Guido van Rossum committed
319 320 321 322
		w = PyList_GetItem(v, s);
		if (w == NULL || !PyList_Check(w) ||
					PyList_Size(w) != t_nctl) {
			PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
323 324 325
			return NULL;
		}
		for (t = 0; t < t_nctl; t++) {
Guido van Rossum's avatar
Guido van Rossum committed
326 327
			pt = PyList_GetItem(w, t);
			if (!PyArg_GetDoubleArray(pt, 1, 0, ncoords, pnext))
Guido van Rossum's avatar
Guido van Rossum committed
328 329 330 331 332 333 334 335
				return NULL;
			pnext += ncoords;
		}
	}
	s_byte_stride = sizeof(double) * ncoords;
	t_byte_stride = s_byte_stride * s_nctl;
	nurbssurface( arg1 , arg2 , arg3 , arg4 ,
		s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 );
Guido van Rossum's avatar
Guido van Rossum committed
336 337 338 339 340
	PyMem_DEL(arg2);
	PyMem_DEL(arg4);
	PyMem_DEL(arg5);
	Py_INCREF(Py_None);
	return Py_None;
Guido van Rossum's avatar
Guido van Rossum committed
341 342 343 344 345 346 347
}

/* nurbscurve(knots, ctlpoints, order, type).
   The length of ctlpoints is len(knots)-order. */

%nurbscurve

Guido van Rossum's avatar
Guido van Rossum committed
348
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
349
gl_nurbscurve(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
350 351
	PyObject *self;
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
352 353 354 355 356 357 358 359 360
{
	long arg1 ;
	double * arg2 ;
	long arg3 ;
	double * arg4 ;
	long arg5 ;
	long arg6 ;
	int ncoords, npoints;
	int i;
Guido van Rossum's avatar
Guido van Rossum committed
361
	PyObject *v;
Guido van Rossum's avatar
Guido van Rossum committed
362
	double *pnext;
Guido van Rossum's avatar
Guido van Rossum committed
363
	if (!PyArg_GetLongArraySize(args, 4, 0, &arg1))
Guido van Rossum's avatar
Guido van Rossum committed
364
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
365 366
	if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) {
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
367
	}
Guido van Rossum's avatar
Guido van Rossum committed
368
	if (!PyArg_GetDoubleArray(args, 4, 0, arg1 , arg2))
Guido van Rossum's avatar
Guido van Rossum committed
369
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
370
	if (!PyArg_GetLong(args, 4, 2, &arg5))
Guido van Rossum's avatar
Guido van Rossum committed
371
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
372
	if (!PyArg_GetLong(args, 4, 3, &arg6))
Guido van Rossum's avatar
Guido van Rossum committed
373 374 375 376 377 378
		return NULL;
	if (arg6 == N_ST)
		ncoords = 2;
	else if (arg6 == N_STW)
		ncoords = 3;
	else {
Guido van Rossum's avatar
Guido van Rossum committed
379
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
380 381 382
		return NULL;
	}
	npoints = arg1 - arg5;
Guido van Rossum's avatar
Guido van Rossum committed
383
	if (!PyArg_GetObject(args, 4, 1, &v))
Guido van Rossum's avatar
Guido van Rossum committed
384
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
385 386
	if (!PyList_Check(v) || PyList_Size(v) != npoints) {
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
387 388
		return NULL;
	}
Guido van Rossum's avatar
Guido van Rossum committed
389 390
	if ((arg4 = PyMem_NEW(double, npoints*ncoords )) == NULL) {
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
391 392 393
	}
	pnext = arg4;
	for (i = 0; i < npoints; i++) {
Guido van Rossum's avatar
Guido van Rossum committed
394
		if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext))
Guido van Rossum's avatar
Guido van Rossum committed
395 396 397 398 399
			return NULL;
		pnext += ncoords;
	}
	arg3 = (sizeof(double)) * ncoords;
	nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 );
Guido van Rossum's avatar
Guido van Rossum committed
400 401 402 403
	PyMem_DEL(arg2);
	PyMem_DEL(arg4);
	Py_INCREF(Py_None);
	return Py_None;
Guido van Rossum's avatar
Guido van Rossum committed
404 405 406 407 408 409 410
}

/* pwlcurve(points, type).
   Points is a list of points. Type must be N_ST. */

%pwlcurve

Guido van Rossum's avatar
Guido van Rossum committed
411
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
412
gl_pwlcurve(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
413 414
	PyObject *self;
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
415
{
Guido van Rossum's avatar
Guido van Rossum committed
416
	PyObject *v;
Guido van Rossum's avatar
Guido van Rossum committed
417 418 419 420
	long type;
	double *data, *pnext;
	long npoints, ncoords;
	int i;
Guido van Rossum's avatar
Guido van Rossum committed
421
	if (!PyArg_GetObject(args, 2, 0, &v))
Guido van Rossum's avatar
Guido van Rossum committed
422
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
423
	if (!PyArg_GetLong(args, 2, 1, &type))
Guido van Rossum's avatar
Guido van Rossum committed
424
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
425 426
	if (!PyList_Check(v)) {
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
427 428
		return NULL;
	}
Guido van Rossum's avatar
Guido van Rossum committed
429
	npoints = PyList_Size(v);
Guido van Rossum's avatar
Guido van Rossum committed
430 431 432
	if (type == N_ST)
		ncoords = 2;
	else {
Guido van Rossum's avatar
Guido van Rossum committed
433
		PyErr_BadArgument();
Guido van Rossum's avatar
Guido van Rossum committed
434 435
		return NULL;
	}
Guido van Rossum's avatar
Guido van Rossum committed
436 437
	if ((data = PyMem_NEW(double, npoints*ncoords)) == NULL) {
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
438 439 440
	}
	pnext = data;
	for (i = 0; i < npoints; i++) {
Guido van Rossum's avatar
Guido van Rossum committed
441
		if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext))
Guido van Rossum's avatar
Guido van Rossum committed
442 443 444 445
			return NULL;
		pnext += ncoords;
	}
	pwlcurve(npoints, data, sizeof(double)*ncoords, type);
Guido van Rossum's avatar
Guido van Rossum committed
446 447 448
	PyMem_DEL(data);
	Py_INCREF(Py_None);
	return Py_None;
Guido van Rossum's avatar
Guido van Rossum committed
449 450 451 452 453 454 455 456
}


/* Picking and Selecting */

static short *pickbuffer = NULL;
static long pickbuffersize;

Guido van Rossum's avatar
Guido van Rossum committed
457
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
458
pick_select(args, func)
Guido van Rossum's avatar
Guido van Rossum committed
459
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
460 461
	void (*func)();
{
Guido van Rossum's avatar
Guido van Rossum committed
462
	if (!PyArg_GetLong(args, 1, 0, &pickbuffersize))
Guido van Rossum's avatar
Guido van Rossum committed
463 464
		return NULL;
	if (pickbuffer != NULL) {
Guido van Rossum's avatar
Guido van Rossum committed
465
		PyErr_SetString(PyExc_RuntimeError,
Guido van Rossum's avatar
Guido van Rossum committed
466 467 468
			"pick/gselect: already picking/selecting");
		return NULL;
	}
Guido van Rossum's avatar
Guido van Rossum committed
469 470
	if ((pickbuffer = PyMem_NEW(short, pickbuffersize)) == NULL) {
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
471 472
	}
	(*func)(pickbuffer, pickbuffersize);
Guido van Rossum's avatar
Guido van Rossum committed
473 474
	Py_INCREF(Py_None);
	return Py_None;
Guido van Rossum's avatar
Guido van Rossum committed
475 476
}

Guido van Rossum's avatar
Guido van Rossum committed
477
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
478
endpick_select(args, func)
Guido van Rossum's avatar
Guido van Rossum committed
479
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
480 481
	long (*func)();
{
Guido van Rossum's avatar
Guido van Rossum committed
482
	PyObject *v, *w;
Guido van Rossum's avatar
Guido van Rossum committed
483
	int i, nhits, n;
Guido van Rossum's avatar
Guido van Rossum committed
484
	if (!PyArg_NoArgs(args))
Guido van Rossum's avatar
Guido van Rossum committed
485 486
		return NULL;
	if (pickbuffer == NULL) {
Guido van Rossum's avatar
Guido van Rossum committed
487
		PyErr_SetString(PyExc_RuntimeError,
Guido van Rossum's avatar
Guido van Rossum committed
488 489 490 491 492 493 494 495 496 497 498 499
			"endpick/endselect: not in pick/select mode");
		return NULL;
	}
	nhits = (*func)(pickbuffer);
	if (nhits < 0) {
		nhits = -nhits; /* How to report buffer overflow otherwise? */
	}
	/* Scan the buffer to see how many integers */
	n = 0;
	for (; nhits > 0; nhits--) {
		n += 1 + pickbuffer[n];
	}
Guido van Rossum's avatar
Guido van Rossum committed
500
	v = PyList_New(n);
Guido van Rossum's avatar
Guido van Rossum committed
501 502 503 504 505
	if (v == NULL)
		return NULL;
	/* XXX Could do it nicer and interpret the data structure here,
	   returning a list of lists. But this can be done in Python... */
	for (i = 0; i < n; i++) {
Guido van Rossum's avatar
Guido van Rossum committed
506
		w = PyInt_FromLong((long)pickbuffer[i]);
Guido van Rossum's avatar
Guido van Rossum committed
507
		if (w == NULL) {
Guido van Rossum's avatar
Guido van Rossum committed
508
			Py_DECREF(v);
Guido van Rossum's avatar
Guido van Rossum committed
509 510
			return NULL;
		}
Guido van Rossum's avatar
Guido van Rossum committed
511
		PyList_SetItem(v, i, w);
Guido van Rossum's avatar
Guido van Rossum committed
512
	}
Guido van Rossum's avatar
Guido van Rossum committed
513
	PyMem_DEL(pickbuffer);
Guido van Rossum's avatar
Guido van Rossum committed
514 515 516 517 518 519 520 521
	pickbuffer = NULL;
	return v;
}

extern void pick(), gselect();
extern long endpick(), endselect();

%pick
Guido van Rossum's avatar
Guido van Rossum committed
522
static PyObject *gl_pick(self, args) PyObject *self, *args; {
Guido van Rossum's avatar
Guido van Rossum committed
523 524 525 526
	return pick_select(args, pick);
}

%endpick
Guido van Rossum's avatar
Guido van Rossum committed
527
static PyObject *gl_endpick(self, args) PyObject *self, *args; {
Guido van Rossum's avatar
Guido van Rossum committed
528 529 530 531
	return endpick_select(args, endpick);
}

%gselect
Guido van Rossum's avatar
Guido van Rossum committed
532
static PyObject *gl_gselect(self, args) PyObject *self, *args; {
Guido van Rossum's avatar
Guido van Rossum committed
533 534 535 536
	return pick_select(args, gselect);
}

%endselect
Guido van Rossum's avatar
Guido van Rossum committed
537
static PyObject *gl_endselect(self, args) PyObject *self, *args; {
Guido van Rossum's avatar
Guido van Rossum committed
538 539 540 541
	return endpick_select(args, endselect);
}


542 543
/* XXX The generator botches this one.  Here's a quick hack to fix it. */

Guido van Rossum's avatar
Guido van Rossum committed
544 545 546 547
/* XXX The generator botches this one.  Here's a quick hack to fix it. */

% getmatrix float r[16]

Guido van Rossum's avatar
Guido van Rossum committed
548
static PyObject *
Guido van Rossum's avatar
Guido van Rossum committed
549
gl_getmatrix(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
550 551
	PyObject *self;
	PyObject *args;
Guido van Rossum's avatar
Guido van Rossum committed
552
{
553
	Matrix arg1;
Guido van Rossum's avatar
Guido van Rossum committed
554
	PyObject *v, *w;
555
	int i, j;
Guido van Rossum's avatar
Guido van Rossum committed
556
	getmatrix( arg1 );
Guido van Rossum's avatar
Guido van Rossum committed
557
	v = PyList_New(16);
Guido van Rossum's avatar
Guido van Rossum committed
558
	if (v == NULL) {
Guido van Rossum's avatar
Guido van Rossum committed
559
		return PyErr_NoMemory();
Guido van Rossum's avatar
Guido van Rossum committed
560
	}
561 562
	for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) {
		w = mknewfloatobject(arg1[i][j]);
Guido van Rossum's avatar
Guido van Rossum committed
563
		if (w == NULL) {
Guido van Rossum's avatar
Guido van Rossum committed
564
			Py_DECREF(v);
Guido van Rossum's avatar
Guido van Rossum committed
565 566
			return NULL;
		}
Guido van Rossum's avatar
Guido van Rossum committed
567
		PyList_SetItem(v, i*4+j, w);
Guido van Rossum's avatar
Guido van Rossum committed
568 569 570 571
	}
	return v;
}

572 573 574 575 576 577
/* Here's an alternate version that returns a 4x4 matrix instead of
   a vector.  Unfortunately it is incompatible with loadmatrix and
   multmatrix... */

% altgetmatrix float r[4][4]

Guido van Rossum's avatar
Guido van Rossum committed
578
static PyObject *
579
gl_altgetmatrix(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
580 581
	PyObject *self;
	PyObject *args;
582
{
583
	Matrix arg1;
Guido van Rossum's avatar
Guido van Rossum committed
584
	PyObject *v, *w;
585 586
	int i, j;
	getmatrix( arg1 );
Guido van Rossum's avatar
Guido van Rossum committed
587
	v = PyList_New(4);
588 589 590 591
	if (v == NULL) {
		return NULL;
	}
	for (i = 0; i < 4; i++) {
Guido van Rossum's avatar
Guido van Rossum committed
592
		w = PyList_New(4);
593
		if (w == NULL) {
Guido van Rossum's avatar
Guido van Rossum committed
594
			Py_DECREF(v);
595 596
			return NULL;
		}
Guido van Rossum's avatar
Guido van Rossum committed
597
		PyList_SetItem(v, i, w);
598 599 600 601 602
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			w = mknewfloatobject(arg1[i][j]);
			if (w == NULL) {
Guido van Rossum's avatar
Guido van Rossum committed
603
				Py_DECREF(v);
604 605
				return NULL;
			}
Guido van Rossum's avatar
Guido van Rossum committed
606
			PyList_SetItem(PyList_GetItem(v, i), j, w);
607 608 609 610 611
		}
	}
	return v;
}

612 613
% lrectwrite

Guido van Rossum's avatar
Guido van Rossum committed
614
static PyObject *
615
gl_lrectwrite(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
616 617
	PyObject *self;
	PyObject *args;
618 619 620 621 622 623
{
	short x1 ;
	short y1 ;
	short x2 ;
	short y2 ;
	string parray ;
Guido van Rossum's avatar
Guido van Rossum committed
624
	PyObject *s;
625
#if 0
626
	int pixcount;
627
#endif
Guido van Rossum's avatar
Guido van Rossum committed
628
	if (!PyArg_GetShort(args, 5, 0, &x1))
629
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
630
	if (!PyArg_GetShort(args, 5, 1, &y1))
631
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
632
	if (!PyArg_GetShort(args, 5, 2, &x2))
633
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
634
	if (!PyArg_GetShort(args, 5, 3, &y2))
635
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
636
	if (!PyArg_GetString(args, 5, 4, &parray))
637
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
638
	if (!PyArg_GetObject(args, 5, 4, &s))
639
		return NULL;
640 641
#if 0
/* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */
642
	pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
Guido van Rossum's avatar
Guido van Rossum committed
643 644
	if (!PyString_Check(s) || PyString_Size(s) != pixcount*sizeof(long)) {
		PyErr_SetString(PyExc_RuntimeError,
645
			   "string arg to lrectwrite has wrong size");
646 647
		return NULL;
	}
648
#endif
649
	lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray );
Guido van Rossum's avatar
Guido van Rossum committed
650 651
	Py_INCREF(Py_None);
	return Py_None;
652 653 654 655
}

% lrectread

Guido van Rossum's avatar
Guido van Rossum committed
656
static PyObject *
657
gl_lrectread(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
658 659
	PyObject *self;
	PyObject *args;
660 661 662 663 664
{
	short x1 ;
	short y1 ;
	short x2 ;
	short y2 ;
Guido van Rossum's avatar
Guido van Rossum committed
665
	PyObject *parray;
666
	int pixcount;
Guido van Rossum's avatar
Guido van Rossum committed
667
	if (!PyArg_GetShort(args, 4, 0, &x1))
668
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
669
	if (!PyArg_GetShort(args, 4, 1, &y1))
670
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
671
	if (!PyArg_GetShort(args, 4, 2, &x2))
672
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
673
	if (!PyArg_GetShort(args, 4, 3, &y2))
674 675
		return NULL;
	pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
Guido van Rossum's avatar
Guido van Rossum committed
676
	parray = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
677 678
	if (parray == NULL)
		return NULL; /* No memory */
Guido van Rossum's avatar
Guido van Rossum committed
679
	lrectread(x1, y1, x2, y2, (unsigned long *) PyString_AsString(parray));
680 681 682
	return parray;
}

Jack Jansen's avatar
Jack Jansen committed
683 684
% readdisplay

Guido van Rossum's avatar
Guido van Rossum committed
685
static PyObject *
Jack Jansen's avatar
Jack Jansen committed
686
gl_readdisplay(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
687 688
	PyObject *self;
        PyObject *args;
Jack Jansen's avatar
Jack Jansen committed
689 690 691 692
{
        short x1, y1, x2, y2;
	unsigned long *parray, hints;
	long size, size_ret;
Guido van Rossum's avatar
Guido van Rossum committed
693
	PyObject *rv;
Jack Jansen's avatar
Jack Jansen committed
694

Guido van Rossum's avatar
Guido van Rossum committed
695
	if ( !PyArg_Parse(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
Jack Jansen's avatar
Jack Jansen committed
696 697
	  return 0;
	size = (long)(x2+1-x1) * (long)(y2+1-y1);
Guido van Rossum's avatar
Guido van Rossum committed
698
	rv = PyString_FromStringAndSize((char *)NULL, size*sizeof(long));
Jack Jansen's avatar
Jack Jansen committed
699 700
	if ( rv == NULL )
	  return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
701
	parray = (unsigned long *)PyString_AsString(rv);
Jack Jansen's avatar
Jack Jansen committed
702 703
	size_ret = readdisplay(x1, y1, x2, y2, parray, hints);
	if ( size_ret != size ) {
704
	    printf("gl_readdisplay: got %ld pixels, expected %ld\n",
Jack Jansen's avatar
Jack Jansen committed
705
		   size_ret, size);
Guido van Rossum's avatar
Guido van Rossum committed
706
	    PyErr_SetString(PyExc_RuntimeError, "readdisplay returned unexpected length");
Jack Jansen's avatar
Jack Jansen committed
707 708 709 710 711
	    return NULL;
	}
	return rv;
}

712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
/* Desperately needed, here are tools to compress and decompress
   the data manipulated by lrectread/lrectwrite.

   gl.packrect(width, height, packfactor, bigdata) --> smalldata
		makes 'bigdata' 4*(packfactor**2) times smaller by:
		- turning it into B/W (a factor 4)
		- replacing squares of size pacfactor by one
		  representative

   gl.unpackrect(width, height, packfactor, smalldata) --> bigdata
		is the inverse; the numeric arguments must be *the same*.

   Both work best if width and height are multiples of packfactor
   (in fact unpackrect will leave garbage bytes).
*/

% packrect

Guido van Rossum's avatar
Guido van Rossum committed
730
static PyObject *
731
gl_packrect(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
732 733
	PyObject *self;
	PyObject *args;
734 735 736
{
	long width, height, packfactor;
	char *s;
Guido van Rossum's avatar
Guido van Rossum committed
737
	PyObject *unpacked, *packed;
738 739 740 741
	int pixcount, packedcount, x, y, r, g, b;
	unsigned long pixel;
	unsigned char *p;
	unsigned long *parray;
Guido van Rossum's avatar
Guido van Rossum committed
742
	if (!PyArg_GetLong(args, 4, 0, &width))
743
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
744
	if (!PyArg_GetLong(args, 4, 1, &height))
745
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
746
	if (!PyArg_GetLong(args, 4, 2, &packfactor))
747
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
748
	if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */
749
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
750
	if (!PyArg_GetObject(args, 4, 3, &unpacked))
751 752
		return NULL;
	if (width <= 0 || height <= 0 || packfactor <= 0) {
Guido van Rossum's avatar
Guido van Rossum committed
753
		PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0");
754 755 756 757 758
		return NULL;
	}
	pixcount = width*height;
	packedcount = ((width+packfactor-1)/packfactor) *
		((height+packfactor-1)/packfactor);
Guido van Rossum's avatar
Guido van Rossum committed
759 760
	if (PyString_Size(unpacked) != pixcount*sizeof(long)) {
		PyErr_SetString(PyExc_RuntimeError,
761
			   "string arg to packrect has wrong size");
762 763
		return NULL;
	}
Guido van Rossum's avatar
Guido van Rossum committed
764
	packed = PyString_FromStringAndSize((char *)NULL, packedcount);
765 766
	if (packed == NULL)
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
767 768
	parray = (unsigned long *) PyString_AsString(unpacked);
	p = (unsigned char *) PyString_AsString(packed);
769 770 771 772 773 774
	for (y = 0; y < height; y += packfactor, parray += packfactor*width) {
		for (x = 0; x < width; x += packfactor) {
			pixel = parray[x];
			r = pixel & 0xff;
			g = (pixel >> 8) & 0xff;
			b = (pixel >> 16) & 0xff;
775
			*p++ = (30*r+59*g+11*b) / 100;
776 777 778 779 780 781 782 783 784 785
		}
	}
	return packed;
}

% unpackrect

static unsigned long unpacktab[256];
static int unpacktab_inited = 0;

Guido van Rossum's avatar
Guido van Rossum committed
786
static PyObject *
787
gl_unpackrect(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
788 789
	PyObject *self;
	PyObject *args;
790 791 792
{
	long width, height, packfactor;
	char *s;
Guido van Rossum's avatar
Guido van Rossum committed
793
	PyObject *unpacked, *packed;
794
	int pixcount, packedcount;
795 796 797 798 799 800 801 802
	register unsigned char *p;
	register unsigned long *parray;
	if (!unpacktab_inited) {
		register int white;
		for (white = 256; --white >= 0; )
			unpacktab[white] = white * 0x010101L;
		unpacktab_inited++;
	}
Guido van Rossum's avatar
Guido van Rossum committed
803
	if (!PyArg_GetLong(args, 4, 0, &width))
804
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
805
	if (!PyArg_GetLong(args, 4, 1, &height))
806
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
807
	if (!PyArg_GetLong(args, 4, 2, &packfactor))
808
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
809
	if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */
810
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
811
	if (!PyArg_GetObject(args, 4, 3, &packed))
812 813
		return NULL;
	if (width <= 0 || height <= 0 || packfactor <= 0) {
Guido van Rossum's avatar
Guido van Rossum committed
814
		PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0");
815 816 817 818 819
		return NULL;
	}
	pixcount = width*height;
	packedcount = ((width+packfactor-1)/packfactor) *
		((height+packfactor-1)/packfactor);
Guido van Rossum's avatar
Guido van Rossum committed
820 821
	if (PyString_Size(packed) != packedcount) {
		PyErr_SetString(PyExc_RuntimeError,
822
			   "string arg to unpackrect has wrong size");
823 824
		return NULL;
	}
Guido van Rossum's avatar
Guido van Rossum committed
825
	unpacked = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
826 827
	if (unpacked == NULL)
		return NULL;
Guido van Rossum's avatar
Guido van Rossum committed
828 829
	parray = (unsigned long *) PyString_AsString(unpacked);
	p = (unsigned char *) PyString_AsString(packed);
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855
	if (packfactor == 1 && width*height > 0) {
		/* Just expand bytes to longs */
		register int x = width * height;
		do {
			*parray++ = unpacktab[*p++];
		} while (--x >= 0);
	}
	else {
		register int y;
		for (y = 0; y < height-packfactor+1;
		     y += packfactor, parray += packfactor*width) {
			register int x;
			for (x = 0; x < width-packfactor+1; x += packfactor) {
				register unsigned long pixel = unpacktab[*p++];
				register int i;
				for (i = packfactor*width; (i-=width) >= 0;) {
					register int j;
					for (j = packfactor; --j >= 0; )
						parray[i+x+j] = pixel;
				}
			}
		}
	}
	return unpacked;
}

856
% gversion
Guido van Rossum's avatar
Guido van Rossum committed
857
static PyObject *
858
gl_gversion(self, args)
Guido van Rossum's avatar
Guido van Rossum committed
859 860
	PyObject *self;
	PyObject *args;
861 862 863
{
	char buf[20];
	gversion(buf);
Guido van Rossum's avatar
Guido van Rossum committed
864
	return PyString_FromString(buf);
865 866 867
}


868 869 870 871 872 873 874 875 876 877 878 879
/* void clear - Manual because of clash with termcap */
%clear
static PyObject *
gl_clear(self, args)
	PyObject *self;
	PyObject *args;
{
	__GLclear( );
	Py_INCREF(Py_None);
	return Py_None;
}

Guido van Rossum's avatar
Guido van Rossum committed
880 881 882 883 884
/* End of manually written stubs */

%%

long 	getshade
885
if !solaris	void 	devport 	short s long s
Guido van Rossum's avatar
Guido van Rossum committed
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912
void 	rdr2i 		long s long s
void	rectfs 		short s short s short s short s
void 	rects 		short s short s short s short s
void 	rmv2i 		long s long s
void	noport
void	popviewport
void	clearhitcode
void	closeobj
void	cursoff
void	curson
void	doublebuffer
void 	finish
void	gconfig
void	ginit
void	greset
void	multimap
void	onemap
void	popattributes
void	popmatrix
void	pushattributes
void	pushmatrix
void	pushviewport
void	qreset
void	RGBmode
void	singlebuffer
void	swapbuffers
void	gsync
Guido van Rossum's avatar
Guido van Rossum committed
913
void	gflush
Guido van Rossum's avatar
Guido van Rossum committed
914 915 916 917 918 919 920 921 922 923 924
void	tpon
void	tpoff
void	clkon
void	clkoff
void	ringbell
#void	callfunc
void	gbegin
void	textinit
void	initnames
void	pclos
void	popname
925
if !solaris	void	spclos
Guido van Rossum's avatar
Guido van Rossum committed
926 927 928 929 930 931 932
void	zclear
void	screenspace
void	reshapeviewport
void	winpush
void	winpop
void	foreground
void	endfullscrn
933
if !solaris	void	endpupmode
Guido van Rossum's avatar
Guido van Rossum committed
934
void	fullscrn
935
if !solaris	void	pupmode
Guido van Rossum's avatar
Guido van Rossum committed
936 937 938 939 940 941 942 943 944 945 946
void	winconstraints
void	pagecolor 	short s
void	textcolor 	short s
void 	color 	  	short s
void	curveit		short s
void	font		short s
void 	linewidth	short s
void    setlinestyle	short s
void	setmap		short s
void	swapinterval	short s
void	writemask	short s
947
if !solaris	void	textwritemask	short s
Guido van Rossum's avatar
Guido van Rossum committed
948 949 950 951 952 953 954 955
void	qdevice		short s
void	unqdevice	short s
void	curvebasis	short s
void	curveprecision	short s
void	loadname	short s
void	passthrough	short s
void	pushname	short s
void	setmonitor	short s
956
if !solaris	void	setshade	short s
Guido van Rossum's avatar
Guido van Rossum committed
957
void	setpattern	short s
958
if !solaris	void	pagewritemask	short s
Guido van Rossum's avatar
Guido van Rossum committed
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978
#
void	callobj		long s
void	delobj		long s
void 	editobj		long s
void	makeobj		long s
void	maketag		long s
void	chunksize	long s
void	compactify	long s
void	deltag		long s
void	lsrepeat	long s
void	objinsert	long s
void 	objreplace	long s
void	winclose	long s
void	blanktime	long s
void 	freepup		long s
# This is not in the library!?
###void	pupcolor	long s
#
void	backbuffer	long s
void 	frontbuffer	long s
979
if !solaris	void	lsbackup	long s
Guido van Rossum's avatar
Guido van Rossum committed
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
void	resetls		long s
void	lampon		long s
void	lampoff		long s
void	setbell		long s
void	blankscreen	long s
void 	depthcue	long s
void	zbuffer		long s
void	backface	long s
#
void 	cmov2i		long s long s
void 	draw2i		long s long s
void	move2i		long s long s
void	pnt2i		long s long s
void 	patchbasis	long s long s
void 	patchprecision	long s long s
void	pdr2i		long s long s
void	pmv2i		long s long s
void	rpdr2i		long s long s
void	rpmv2i		long s long s
void	xfpt2i		long s long s
void	objdelete	long s long s
void	patchcurves	long s long s
void	minsize		long s long s
void 	maxsize		long s long s
void	keepaspect	long s long s
void	prefsize	long s long s
void	stepunit	long s long s
void 	fudge		long s long s
void 	winmove		long s long s
#
void 	attachcursor	short s short s
void 	deflinestyle	short s short s
void 	noise		short s short s
void 	picksize	short s short s
void 	qenter		short s short s
void 	setdepth	short s short s
void 	cmov2s		short s short s
void 	draw2s		short s	short s
void 	move2s		short s short s
void 	pdr2s		short s short s
void 	pmv2s		short s short s
void 	pnt2s		short s short s
void 	rdr2s		short s short s
void 	rmv2s		short s short s
void 	rpdr2s		short s short s
void 	rpmv2s		short s short s
void 	xfpt2s		short s short s
#
void cmov2		float s float s
void draw2		float s float s
void move2		float s float s
void pnt2		float s float s
void pdr2		float s float s
void pmv2		float s float s
void rdr2		float s float s
void rmv2		float s float s
void rpdr2		float s float s
void rpmv2		float s float s
void xfpt2		float s float s
#
1040
void loadmatrix		float s[4*4]
1041
# Really [4][4]
1042
void multmatrix		float s[4*4]
1043
# Really [4][4]
1044
void crv			float s[3*4]
1045
# Really [4][3]
1046
void rcrv			float s[4*4]
1047
# Really [4][4]
Guido van Rossum's avatar
Guido van Rossum committed
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
#
# Methods that have strings.  
#
void addtopup		long s char *s long s
void charstr		char *s
void getport	 	char *s
long strwidth		char *s
long winopen		char *s
void wintitle		char *s
#
# Methods that have 1 long (# of elements) and an array 
#
void polf		long s float s[3*arg1]
void polf2		long s float s[2*arg1]
void poly		long s float s[3*arg1]
void poly2		long s float s[2*arg1]
void crvn		long s float s[3*arg1]
void rcrvn		long s float s[4*arg1]
#
void polf2i		long s long s[2*arg1]
void polfi		long s long s[3*arg1]
void poly2i		long s long s[2*arg1]
void polyi		long s long s[3*arg1]
#
void polf2s		long s short s[2*arg1]
void polfs		long s short s[3*arg1]
void polys		long s short s[3*arg1]
void poly2s		long s short s[2*arg1]
#
1077
void defcursor		short s u_short s[128]
1078
# Is this useful?
1079
void writepixels	short s u_short s[arg1]
1080
# Should be unsigned short...
1081 1082
void defbasis		long s float s[4*4]
if !solaris	void gewrite		short s short s[arg1]
Guido van Rossum's avatar
Guido van Rossum committed
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139
#
void rotate		short s char s
# This is not in the library!?
###void setbutton		short s char s
void rot		float s char s
#
void circfi		long s long s long s
void circi		long s long s long s
void cmovi		long s long s long s
void drawi		long s long s long s
void movei		long s long s long s
void pnti 		long s long s long s
void newtag		long s long s long s
void pdri  		long s long s long s
void pmvi  		long s long s long s
void rdri  		long s long s long s
void rmvi  		long s long s long s
void rpdri 		long s long s long s
void rpmvi 		long s long s long s
void xfpti 		long s long s long s
#
void circ		float s float s float s
void circf		float s float s float s
void cmov		float s float s float s
void draw		float s float s float s
void move		float s float s float s
void pnt		float s float s float s
void scale		float s float s float s
void translate		float s float s float s
void pdr		float s float s float s
void pmv		float s float s float s
void rdr		float s float s float s
void rmv		float s float s float s
void rpdr		float s float s float s
void rpmv		float s float s float s
void xfpt		float s float s float s
#
void RGBcolor		short s short s short s
void RGBwritemask	short s short s short s
void setcursor		short s short s short s
void tie		short s short s short s
void circfs		short s short s short s
void circs		short s short s short s
void cmovs		short s short s short s
void draws		short s short s short s
void moves		short s short s short s
void pdrs		short s short s short s
void pmvs		short s short s short s
void pnts		short s short s short s
void rdrs		short s short s short s
void rmvs		short s short s short s
void rpdrs		short s short s short s
void rpmvs		short s short s short s
void xfpts		short s short s short s
void curorigin		short s short s short s
void cyclemap		short s short s short s
#
1140 1141 1142 1143 1144 1145 1146 1147
void patch		float s[4*4] float s[4*4] float s[4*4]
void splf		long s float s[3*arg1] u_short s[arg1]
void splf2		long s float s[2*arg1] u_short s[arg1]
void splfi		long s long s[3*arg1] u_short s[arg1]
void splf2i		long s long s[2*arg1] u_short s[arg1]
void splfs		long s short s[3*arg1] u_short s[arg1]
void splf2s		long s short s[2*arg1] u_short s[arg1]
###void defpattern		short s short s u_short s[arg2*arg2/16]
Guido van Rossum's avatar
Guido van Rossum committed
1148
#
1149
void rpatch		float s[4*4] float s[4*4] float s[4*4] float s[4*4]
Guido van Rossum's avatar
Guido van Rossum committed
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190
#
# routines that send 4 floats
#
void ortho2		float s float s float s float s
void rect		float s float s float s float s
void rectf		float s float s float s float s
void xfpt4		float s float s float s float s
#
void textport		short s short s short s short s
void mapcolor		short s short s short s short s
void scrmask		short s short s short s short s
void setvaluator	short s short s short s short s
void viewport		short s short s short s short s
void shaderange		short s short s short s short s
void xfpt4s		short s short s short s short s
void rectfi		long s long s long s long s
void recti		long s long s long s long s
void xfpt4i		long s long s long s long s
void prefposition	long s long s long s long s
#
void arc		float s float s float s short s short s
void arcf		float s float s float s short s short s
void arcfi		long s long s long s short s short s
void arci		long s long s long s short s short s
#
void bbox2		short s short s float s float s float s float s
void bbox2i		short s short s long s long s long s long s
void bbox2s		short s short s short s short s short s short s
void blink		short s short s short s short s short s
void ortho		float s float s float s float s float s float s
void window		float s float s float s float s float s float s
void lookat		float s float s float s float s float s float s short s
#
void perspective	short s float s float s float s
void polarview		float s short s short s short s
# XXX getichararray not supported
#void writeRGB		short s char s[arg1] char s[arg1] char s[arg1]
#
void arcfs		short s short s short s short s short s
void arcs		short s short s short s short s short s
void rectcopy		short s short s short s short s short s short s
1191
if !solaris	void RGBcursor		short s short s short s short s short s short s short s
Guido van Rossum's avatar
Guido van Rossum committed
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234
#
long getbutton		short s
long getcmmode
long getlsbackup
long getresetls
long getdcm
long getzbuffer
long ismex
long isobj		long s
long isqueued		short s
long istag		long s
#
long genobj
long gentag
long getbuffer
long getcolor
long getdisplaymode
long getfont
long getheight
long gethitcode
long getlstyle
long getlwidth
long getmap
long getplanes
long getwritemask
long qtest
long getlsrepeat
long getmonitor
long getopenobj
long getpattern
long winget
long winattach
long getothermonitor
long newpup
#
long getvaluator	short s
void winset		long s
long dopup		long s
void getdepth		short r short r
void getcpos		short r short r
void getsize		long r long r
void getorigin		long r long r
void getviewport	short r short r short r short r
1235
if !solaris	void gettp		short r short r short r short r
Guido van Rossum's avatar
Guido van Rossum committed
1236 1237 1238 1239 1240
void getgpos		float r float r float r float r
void winposition	long s long s long s long s
void gRGBcolor		short r short r short r
void gRGBmask		short r short r short r
void getscrmask	short r short r short r short r
1241
###void gRGBcursor	short r short r short r short r short r short r short r short r
Guido van Rossum's avatar
Guido van Rossum committed
1242 1243 1244
void getmcolor		short s short r short r short r
void mapw		long s short s short s float r float r float r float r float r float r
void mapw2		long s short s short s float r float r
1245
###void defrasterfont	short s short s short s Fontchar s[arg3] short s short s[4*arg5]
1246
###long qread		short r
1247
void getcursor		short r u_short r u_short r long r
Guido van Rossum's avatar
Guido van Rossum committed
1248 1249 1250
#
#   For these we receive arrays of stuff
#
1251
###void getdev 		long s short s[arg1] short r[arg1]
Guido van Rossum's avatar
Guido van Rossum committed
1252 1253
#XXX not generated correctly yet
#void getmatrix		float r[16]
1254 1255 1256
###long readpixels		short s short r[retval]
###long readRGB		short s char r[retval] char r[retval] char r[retval]
###long blkqread		short s short r[arg1]
Guido van Rossum's avatar
Guido van Rossum committed
1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
#
#   New 4D routines
#
void cmode
void concave		long s
void curstype		long s
void drawmode		long s
void gammaramp		short s[256] short s[256] short s[256]
long getbackface
long getdescender
long getdrawmode
long getmmode
long getsm
long getvideo		long s
void imakebackground
void lmbind		short s short s
void lmdef		long s long s long s float s[arg3]
void mmode		long s
void normal		float s[3]
void overlay		long s
void RGBrange		short s short s short s short s short s short s short s short s
1278
if !solaris	void setvideo 		long s long s
Guido van Rossum's avatar
Guido van Rossum committed
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318
void shademodel		long s
void underlay		long s
#
# New Personal Iris/GT Routines
#
void bgnclosedline
void bgnline
void bgnpoint
void bgnpolygon
void bgnsurface
void bgntmesh
void bgntrim
void endclosedline
void endline
void endpoint
void endpolygon
void endsurface
void endtmesh
void endtrim
void blendfunction	long s long s
void c3f		float s[3]
void c3i		long  s[3]
void c3s		short s[3]
void c4f		float s[4]
void c4i		long  s[4]
void c4s		short s[4]
void colorf		float s
void cpack		long s
void czclear		long s long s
void dglclose		long s
long dglopen		char *s long s
long getgdesc		long s
void getnurbsproperty	long s float r
void glcompat		long s long s
void iconsize 		long s long s
void icontitle		char *s
void lRGBrange		short s short s short s short s short s short s long s long s
void linesmooth		long s
void lmcolor		long s
void logicop		long s
1319 1320 1321 1322 1323
###long lrectread	 	short s short s short s short s long r[retval]
###void lrectwrite		short s short s short s short s long s[(arg2-arg1+1)*(arg4-arg3+1)]
### Now manual, with string last arg
###long rectread	 	short s short s short s short s short r[retval]
###void rectwrite		short s short s short s short s short s[(arg2-arg1+1)*(arg4-arg3+1)]
Guido van Rossum's avatar
Guido van Rossum committed
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
void lsetdepth		long s long s
void lshaderange	short s short s long s long s
void n3f		float s[3]
void noborder
void pntsmooth		long s
void readsource		long s
void rectzoom		float s float s
void sbox		float s float s float s float s
void sboxi		long s long s long s long s
void sboxs		short s short s short s short s
void sboxf		float s float s float s float s
void sboxfi		long s long s long s long s
void sboxfs		short s short s short s short s
void setnurbsproperty	long s float s
void setpup 		long s long s long s
void smoothline		long s
void subpixel		long s
void swaptmesh
long swinopen		long s
void v2f		float s[2]
void v2i		long  s[2]
void v2s		short s[2]
void v3f		float s[3]
void v3i		long  s[3]
void v3s		short s[3]
void v4f		float s[4]
void v4i		long  s[4]
void v4s		short s[4]
void videocmd		long s
long windepth		long s
void wmpack		long s
void zdraw		long s
void zfunction		long s
void zsource		long s
void zwritemask		long s
#
#   uses doubles
#
void v2d		double s[2]
void v3d		double s[3]
void v4d		double s[4]
1365 1366 1367 1368
#
# Why isn't this here?
#
void pixmode		long s long s
1369 1370 1371 1372
#
# New in IRIX 4.0
#
long qgetfd
Jack Jansen's avatar
Jack Jansen committed
1373
void dither		long s