GLXWorkstation.st
author Claus Gittinger <cg@exept.de>
Fri, 10 Nov 1995 18:01:33 +0100
changeset 216 f4fd44038317
parent 214 5316b1373129
child 218 10072d9beba5
permissions -rw-r--r--
*** empty log message ***

"
COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

XWorkstation subclass:#GLXWorkstation
       instanceVariableNames:'activeWindow hasStereoExtension glOK'
       classVariableNames:   ''
       poolDictionaries:''
       category:'Interface-Graphics'
!

GLXWorkstation comment:'
COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

$Header: /cvs/stx/stx/libview/GLXWorkstation.st,v 1.35 1995-11-10 17:00:56 cg Exp $
'!

!GLXWorkstation class methodsFor:'documentation'!

copyright
"
COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

version
"
$Header: /cvs/stx/stx/libview/GLXWorkstation.st,v 1.35 1995-11-10 17:00:56 cg Exp $
"
!

documentation
"
    this class was originally written as a demo on how an interface to
    a c graphics library could be implemented. In the mean time, it has become
    quite complete ...

    It provides an interface to either a real GL (on SGI workstations)
    or a simulated VGL (i.e. GL-light; low nicotine).
    The GL simulation is derived from the PD vogl library, with slight
    modifictions to support multiple GL views.

    Most of the hard work was done by Jeff (thanks indeed) ...


    Some notes:

    I do not really know what most of these functions do - for more
    detail, see the GL man pages (on SGI) or the doc provided with VGL.

    The interface offered here provides a very very low level (i.e one-to-one)
    interface to GL functions. More high-level stuff is required, to make
    3D drawing be more object-oriented. 
    (see a bit of this in 'clients/IRIS-specials')

    Some functions are duplicated, Jeff and I developed those in parallel -
    for now, both will remain - finally they will be merged and duplicates removed ...
    (examples are makeobj and makeObject).

    Also, in a hurry to implement all those methods, many do no or only
    limited argument checking - make certain, that you pass the correct
    arguments.

    There might be some confusion in the v3[sifd] functions: basically they
    all do the same, and could be mapped onto one st-method (such as vertex3).
    However, the C-functions expect different argument types - I dont know if
    one or another of these functions suffers from any performance penalties.
    Therefore, I leave the direct 1-to-1 mapping; GL experts might know more
    about this (I use v3f in all of my code).

    written june 93 by claus
    VGL stuff dec 93
    many many additions jan 94 by Jeff McAffer <jeff@is.s.u-tokyo.ac.jp>

    Since this is a demo (consider it a free add-on goody) there is 
    *** NO WARRANTY ** for this.

    Notice: this should be rewritten to use the openGL library functions
    (actually, to not loose the VGL interface, another OpenGLWorkstation
     class should be written)
"
! !

!GLXWorkstation primitiveDefinitions!

%{
/*
 * on SGI, this class is compiled with -DGLX, while
 * for simulation (using vogl), this is compiled with -DVGL
 */

/*
 * define this to enable:
 *    blendcolor getgconfig getmultisample leftbuffer rightbuffer monobuffer
 *    msalpha msmask mspattern mssize multisample stereobuffer
 *    t3s t3i t3f t3d t4s t4i t4f t4d tlutbind zbsize
 *
 * these are not available on all gl's
 */

/* #define FULL_GLX */

/*
 * this is stupid, GLX defines String, which is also defined here ...
 */
# define String GLX_String

#include <stdio.h>

#ifdef GLX
# include <gl/glws.h>
# include <gl/sphere.h>
#else
# undef memset
# include <vogl.h>
# undef move
# include <X11/Xlib.h>
#endif

/*
 * XSGIStereo extension - if available
 */
#ifdef XSGIStereo
# include <X11/extensions/SGIStereo.h>
#endif

#ifndef NULL
# define NULL (char *)0         /* sigh */
#endif

typedef enum {
    GLXcolorIndexSingleBuffer,
    GLXcolorIndexDoubleBuffer,
    GLXrgbSingleBuffer,
    GLXrgbDoubleBuffer
} GLXWindowType;

/*
extern Window GLXCreateWindow();
*/

#ifdef THISCONTEXT_IN_REGISTER
  extern OBJ __thisContext__;
# define ENTERGLX       __thisContext__ = __thisContext
# define LEAVEGLX       __thisContext = __thisContext__; __thisContext__ = 0;
#else
# define ENTERGLX    /* nothing */
# define LEAVEGLX     /* nothing */
#endif

#undef String

/*
 * some defines - tired of typing ...
 * most of these macros/functions extract values from smalltalk objects and
 * put/pack them into corresponding c variables.
 *
 */
#define myDpy           (Display *)(__MKCP(_INST(displayId)))
#define ISCONNECTED     (_INST(displayId) != nil)
#define _WindowVal(o)   (Window)(__MKCP(o))

/*
 * set the GLXWindow for followup drawing
 */
#define SETWIN(aGLXWindowId)                            \
    if (_INST(activeWindow) != aGLXWindowId) {          \
	if (! ISCONNECTED ) {                           \
	    RETURN (false);                             \
	}                                               \
	if (! __isExternalAddress(aGLXWindowId)) {      \
	    RETURN (false);                             \
	}                                               \
	if (GLXwinset(myDpy, _WindowVal(aGLXWindowId)) < 0) { \
	    RETURN (false);                             \
	}                                               \
	_INST(activeWindow) = aGLXWindowId;             \
	__STORE(self, aGLXWindowId);                    \
    } else {                                            \
	if (aGLXWindowId == nil) {                      \
	    RETURN (false);                             \
	}                                               \
    }

#define _MKBOOLEAN(b)   ((b==FALSE) ? false : true)
#define _booleanVal(b)  ((b==false) ? (Boolean)FALSE : (Boolean)TRUE)
#define _coordVal(c)                             \
    ((__isFloat(c)) ? (Coord)(_floatVal(c))      \
		    : (Coord)(__intVal(c)))
#define _icoordVal(c)      ((Icoord)(__intVal(c)))
#define _scoordVal(c)      ((Scoord)(__intVal(c)))
#define _screencoordVal(c) ((Screencoord)(__intVal(c)))
#define _colorindexVal(c)  ((Colorindex)(__intVal(c)))
#define _linestyleVal(l)   ((Linestyle)(__intVal(l)))
#define _shortVal(l)       ((short)(__intVal(l)))
#define _longVal(l)        ((long)(__intVal(l)))
#define _deviceVal(l)      ((Device)(__intVal(l)))
#define _tagVal(l)         ((Tag)(__intVal(l)))
#define _objectVal(l)      ((Object)(__intVal(l)))
#define _offsetVal(l)      ((Offset)(__intVal(l)))
#define _rgbVal(l)         ((RGBvalue)(__intVal(l)))
#define _angleVal(c)       ((Angle)(__intVal(c)))

/*
 * check for and fetch a boolean from ST-arg into C-dst
 * ST-object must be true or false. Return wth false if invalid.
 */
#define _BOOLEAN_(arg, dst)             \
    if (arg==true)                      \
	dst = (Boolean)TRUE;            \
    else if (arg==false)                \
	dst = (Boolean)FALSE;           \
    else { RETURN(false); }

/*
 * check for and fetch a coord from ST-arg into C-dst
 * ST-object must be Float, SmallInteger or Fraction.
 * Return wth false if invalid.
 */
#define _COORD_(arg, dst)               \
    if (__isFloat(arg))                 \
	dst = (Coord)(_floatVal(arg));  \
    else if (__isSmallInteger(arg))     \
	dst = (Coord)(__intVal(arg));    \
    else if (__isFraction(arg)          \
	  && __isSmallInteger(_FractionInstPtr(arg)->f_numerator)       \
	  && __isSmallInteger(_FractionInstPtr(arg)->f_denominator)) {  \
	float n, d;                                                     \
									\
	n = (float)(__intVal(_FractionInstPtr(arg)->f_numerator));       \
	d = (float)(__intVal(_FractionInstPtr(arg)->f_denominator));     \
	dst = (Coord)(n / d);                                           \
    } else { RETURN(false); }

/*
 * check for and fetch an icoord from ST-arg into C-dst
 * ST-object must be SmallInteger. Return wth false if invalid. 
 */
#define _ICOORD_(arg, dst)              \
    if (__isSmallInteger(arg))          \
      dst = (Icoord)(__intVal(arg));     \
    else { RETURN(false); }

/*
 * check for and fetch an scoord from ST-arg into C-dst
 * ST-object must be SmallInteger. Return wth false if invalid. 
 */
#define _SCOORD_(arg, dst)              \
    if (__isSmallInteger(arg))          \
      dst = (Scoord)(__intVal(arg));     \
    else { RETURN(false); }

#define _SCREENCOORD_(arg, dst)          \
    if (__isSmallInteger(arg))           \
      dst = (Screencoord)(__intVal(arg)); \
    else { RETURN(false); }

#define _COLORINDEX_(arg, dst)           \
    if (__isSmallInteger(arg))           \
      dst = (Colorindex)(__intVal(arg));  \
    else { RETURN(false); }

#define _ANGLE_(arg, dst)               \
    if (__isSmallInteger(arg))          \
	dst = (Angle)(__intVal(arg));    \
    else { RETURN(false); }

#define _FLOAT_(arg, dst)               \
    if (__isFloat(arg))                 \
	dst = (float)(_floatVal(arg));  \
    else if (__isSmallInteger(arg))     \
	dst = (float)(__intVal(arg));    \
    else if (__isFraction(arg)          \
	  && __isSmallInteger(_FractionInstPtr(arg)->f_numerator)       \
	  && __isSmallInteger(_FractionInstPtr(arg)->f_denominator)) {  \
	float n, d;                                                     \
									\
	n = (float)(__intVal(_FractionInstPtr(arg)->f_numerator));       \
	d = (float)(__intVal(_FractionInstPtr(arg)->f_denominator));     \
	dst = (float)(n / d);                                           \
    } else { RETURN(false); }

#define _INT_(arg, dst)                 \
    if (__isSmallInteger(arg))          \
	dst = (int)(__intVal(arg));      \
    else { RETURN(false); }

#define _indexedArea(object)            \
    (((char *) (_InstPtr(object)))      \
	+ OHDR_SIZE                     \
	+ (__intVal(_ClassInstPtr(__qClass(object))->c_ninstvars)) * sizeof(OBJ))
%}
! !

!GLXWorkstation primitiveVariables!

%{
/*
 * remembered info from private error handler
 */
static char lastErrorMsg[80] = "";
static unsigned lastRequestCode = 0;
static unsigned lastMinorCode = 0;
static unsigned lastResource = 0;

%}
! !

!GLXWorkstation primitiveFunctions!

%{

/*
 * catch X-errors and forward as errorInterrupt:#DisplayError,
 * (which itself invokes my handler and optionally raises an exceptionSignal)
 * the implementation below is somewhat wrong: it will
 * report all errors for Display, even though there could be
 * more than one display connection. (being fixed, new errorInterrupt mechanism
 * allows passing an additional argument, which is the displayID ...)
 *
 * this dublicates the functionality as found in XWorkstation;
 * the reason is to allow dynamic loading systems to load this module
 * before XWorkstation (which was not possible otherwise, due to unresolved
 * external references while loading this one)
 */
static
__XErrorHandler__(dpy, event)
    Display *dpy;
    XErrorEvent *event;
{
    XGetErrorText(dpy, event->error_code, lastErrorMsg, 80);
    if (lastErrorMsg[0] == '\0') {
	sprintf(lastErrorMsg, "code: %d", event->error_code);
    }
    lastRequestCode = event->request_code;
    lastMinorCode = event->minor_code;
    lastResource = event->resourceid;

    fprintf(stderr, "XWORKSTAT: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n",
		    event->request_code, event->request_code,
		    event->minor_code, event->minor_code, event->resourceid);
    fprintf(stderr, "XWORKSTAT: x-error message is '%s'\n", lastErrorMsg);

    __errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy));
    return 0;
}

/* 
 * begin moved from GLXsupport.c
 */

/*
 * GLXsupport.c:
 *
 *   This file provides a helper function "GLXCreateWindow", which does
 * all the necessary magic to create an X window suitable for GL drawing 
 * to take place within.   see the definition of GLXCreateWindow for a 
 * description of how to call it.
 *
 * claus: I really had no time to look into all this,
 * this file has been just copied from a 4Dgifts demo ..
 * (will need more than a day to show more ...)
 */
#if defined(GLX) || defined(VGL)

#include        <X11/Xlib.h>
#include        <X11/Xutil.h>
#ifndef VGL
# include        <gl/glws.h>  
#endif
#include        <signal.h>
#include        <setjmp.h>
#include        "stcIntern.h"

/*
 * glxhelper.h:
 *
 *   List of drawing modes supported by GLXCreateWindow (in glxhelper.c).
 * More than this are possible with mixed model, but this is just an 
 * example.  You can either expand this list (and the corresponding code in 
 * GLXCreateWindow) or call the mixed model calls yourself, using 
 * GLXCreateWindow as an example.
 */

static char *typeToName[] = {
    "color index single buffer",
    "color index double buffer",
    "rgb single buffer",
    "rgb double buffer",
};

#ifndef VGL
/*
 * Dorky little helper function used to build up a GLXconfig array.
 */

static void set_entry (GLXconfig* ptr, int b, int m, int a)
{
    ptr->buffer = b;
    ptr->mode = m;
    ptr->arg = a;
}
#endif /* VGL */

static JMP_BUF errorReturn;

static void
glAbort() {
    longjmp(errorReturn, 1);
}

/*
 * GLXCreateWindow(dpy, parent, x, y, w, h, boderWidth, type)
 *
 * Return value is the X window id of the newly created window.
 *
 * Arguments are:
 *      dpy             The X "Display*" returned by XOpenDisplay
 *      parent          The parent of the newly created window,
 *                      a typical value for this is
 *                      RootWindow(dpy, DefaultScreen(dpy))
 *      x,y             The location of the window to be created,
 *                      y coordinate is measured from the top down.
 *      w,h             size of the new window
 *      borderWidth     the X border size for this window, should probably
 *                      be zero.
 *      type            the GLXWindowType (see glxhelper.h) desribing the
 *                      typer of GL drawing to be done in this window
 */
static Window 
GLXCreateWindow(dpy, parent, x, y, w, h, borderWidth, type)
    Display* dpy;
    Window parent;
    GLXWindowType type;
{
#ifdef VGL
    Visual visual;
#else
    GLXconfig params[50];
    GLXconfig* next;
    GLXconfig* retconfig;
    Colormap cmap = DefaultColormap(dpy, DefaultScreen(dpy));
    XVisualInfo *vis;
#endif
    XVisualInfo template;
    XColor white;
    XSetWindowAttributes cwa;
    XWindowAttributes   pwa;
    int scr, i, nret;
    Window win;
#ifdef IRIX5
    SIG_PF oldSig;
#else
    void *oldSig;
#endif

    if (setjmp(errorReturn)) {
	printf("hard error in GL - return\n");
	signal(SIGSEGV, oldSig);
	return 0;
    }
    __CONT__

#ifdef VGL
    /*
     * I know what VGL supports; its somewhat unclean to hard code it here
     */
    switch (type) {
      case GLXcolorIndexSingleBuffer:
      case GLXcolorIndexDoubleBuffer:
	break;

      case GLXrgbSingleBuffer:
      case GLXrgbDoubleBuffer:
	printf("Sorry, VGL can't support %s type of windows\n", typeToName[type]);
	return 0;
    }

    scr = DefaultScreen(dpy);
    visual.visualid = CopyFromParent;
    cwa.border_pixel = 0;  /* Even if we don't use it, it must be something */
    if (w <= 0) {
	printf("VGL: bad width: %d\n", w);
	w = 1;
    }
    if (h <= 0) {
	printf("VGL: bad height: %d\n", h);
	h = 1;
    }
    win = XCreateWindow(dpy, parent, x, y, w, h,
			     borderWidth, DisplayPlanes(dpy, scr), 
			     InputOutput, &visual,
			     CWBorderPixel, &cwa);

    /*
     * on iris, seg-violations occur in te GL, if too many
     * views are created ... just to make certain, we catch those
     * in GL too.
     */
    oldSig = signal(SIGSEGV, glAbort);
    i = GLXlink(dpy, win);
    signal(SIGSEGV, oldSig);

    if (i < 0) {
	printf("GLXlink returned %d\n", i);
	return 0;
    }
#else /* not VGL */
    /*
     * This builds an array in "params" that describes for GLXgetconfig(3G)
     * the type of GL drawing that will be done.
     */
    next = params;
    switch (type) {
      case GLXcolorIndexSingleBuffer:
	set_entry(next++, GLX_NORMAL, GLX_RGB, FALSE);
	set_entry(next++, GLX_NORMAL, GLX_DOUBLE, FALSE);
	break;
      case GLXcolorIndexDoubleBuffer:
	set_entry(next++, GLX_NORMAL, GLX_RGB, FALSE);
	set_entry(next++, GLX_NORMAL, GLX_DOUBLE, TRUE);
	break;
      case GLXrgbSingleBuffer:
	set_entry(next++, GLX_NORMAL, GLX_RGB, TRUE);
	set_entry(next++, GLX_NORMAL, GLX_DOUBLE, FALSE);
	break;
      case GLXrgbDoubleBuffer:
	set_entry(next++, GLX_NORMAL, GLX_RGB, TRUE);
	set_entry(next++, GLX_NORMAL, GLX_DOUBLE, TRUE);
	break;
    }
    set_entry(next, 0, 0, 0); /* The input to GLXgetconfig is null terminated */

    /*
     * Get configuration data for a window based on above parameters
     * First we have to find out which screen the parent window is on,
     * then we can call GXLgetconfig()
     */
    XGetWindowAttributes(dpy, parent, &pwa);
    retconfig = GLXgetconfig(dpy, XScreenNumberOfScreen(pwa.screen), params);
    if (retconfig == 0) {
	printf("Sorry, can't support %s type of windows\n", typeToName[type]);
	return 0;
    }

    /*
     * Scan through config info, pulling info needed to create a window
     * that supports the rendering mode.
     */
    for (next = retconfig; next->buffer; next++) {
	unsigned long buffer = next->buffer;
	unsigned long mode = next->mode;
	unsigned long value = next->arg;
	switch (mode) {
	  case GLX_COLORMAP:
	    if (buffer == GLX_NORMAL) {
		cmap = value;
	    }
	    break;
	  case GLX_VISUAL:
	    if (buffer == GLX_NORMAL) {
		template.visualid = value;
		template.screen = DefaultScreen(dpy);
		vis = XGetVisualInfo(dpy, VisualScreenMask|VisualIDMask,
					  &template, &nret);
	    }
	    break;
	}
    }

    /*
     * Create the window
     */
    cwa.colormap = cmap;
    cwa.border_pixel = 0;  /* Even if we don't use it, it must be something */
    win = XCreateWindow(dpy, parent, x, y, w, h,
			     borderWidth, vis->depth, InputOutput, vis->visual,
			     CWColormap|CWBorderPixel, &cwa);

    /*
     * Rescan configuration info and find window slot that getconfig
     * provided.  Fill it in with the window we just created.
     */
    for (next = retconfig; next->buffer; next++) {
	if ((next->buffer == GLX_NORMAL) && (next->mode == GLX_WINDOW)) {
	    next->arg = win;
	    break;
	}
    }

    /*
     * Now "retconfig" contains all the information the GL needs to
     * configure the window and its own internal state.
     */
    /*
     * on iris, seg-violations occur in te GL, if too many
     * views are created ...
     */
    oldSig = signal(SIGSEGV, glAbort);
    i = GLXlink(dpy, retconfig);
    signal(SIGSEGV, oldSig);

    if (i < 0) {
	printf("GLXlink returned %d\n", i);
	return 0;
    }

    /*
     * The GL sets its own X error handlers, which exits - this is not what we want
     */
    XSetErrorHandler(__XErrorHandler__);
#endif
    return win;
}

static
GLXUnlinkWindow(dpy, win)
    Display* dpy;
    Window win;
{
    /*
     * only needed for VGL - GLX does it automatically
     */
#ifdef VGL
    GLXunlink(dpy, win);
#endif
}

#endif /* GLX or VGL */

/* 
 * end moved from GLXsupport.c
 */

/*
 * helper for rotation - call rot()
 */
static OBJ
doRotate(angle, axis)
    OBJ angle;
    char axis;
{
    Angle a_angle;
    float f_angle;

    if (__isFloat(angle)) {
	f_angle = (float)(_floatVal(angle));
	if (f_angle != 0.0)
	    rot(f_angle, axis);
	return (true);
    }
    if (__isFraction(angle)
     && __isSmallInteger(_FractionInstPtr(angle)->f_numerator)
     && __isSmallInteger(_FractionInstPtr(angle)->f_denominator)) {
	float n, d;

	n = (float)(__intVal(_FractionInstPtr(angle)->f_numerator));
	d = (float)(__intVal(_FractionInstPtr(angle)->f_denominator));
	f_angle = n / d;
	if (f_angle != 0.0)
	    rot(f_angle, axis);
	return (true);
    }
    if (__isSmallInteger(angle)) {
	f_angle = (float)(__intVal(angle));
	if (f_angle != 0.0)
	    rot(f_angle, axis);
	return (true);
    }
    return false;
}

/*
 * fetch integers from an st-array (elements must be smallIntegers)
 */
static long *
getLongsFromInto(obj, vec, count)
   OBJ obj;
   long *vec;
{
    OBJ cls, o;
    int nByte, i, ninstVars, nInstBytes;
    char *pElem;

    if (! _isNonNilObject(obj)) return (long *)NULL;
    cls = __qClass(obj);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);
    nByte = __qSize(obj) - nInstBytes;
    pElem = (char *)(_InstPtr(obj)) + nInstBytes;
    if (nByte < (count * sizeof(OBJ))) return (long *)NULL;
    for (i=0; i<count; i++) {
	o = *(OBJ *)pElem;
	if (! __isSmallInteger(o)) return (long *)NULL;
	vec[i] = (long)__intVal(o);
	pElem += sizeof(OBJ);
    }
    return vec;
}

/*
 * fetch shorts from an st-array (elements must be smallIntegers)
 */
static short *
getShortsFromInto(obj, vec, count)
   OBJ obj;
   short *vec;
{
    OBJ cls, o;
    int nByte, i, ninstVars, nInstBytes;
    char *pElem;

    if (! _isNonNilObject(obj)) return (short *)NULL;
    cls = __qClass(obj);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);
    nByte = __qSize(obj) - nInstBytes;
    pElem = (char *)(_InstPtr(obj)) + nInstBytes;
    if (nByte < (count * sizeof(OBJ))) return (short *)NULL;
    for (i=0; i<count; i++) {
	o = *(OBJ *)pElem;
	if (! __isSmallInteger(o)) return (short *)NULL;
	vec[i] = (short)__intVal(o);
	pElem += sizeof(OBJ);
    }
    return vec;
}

/*
 * fetch floats from an st-object into a c-float array 
 * which may be a floatArray, doubleArray or array-of-something,
 * where something may be a float, fraction or smallInteger,
 */
static float *
getFloatsFromInto(obj, vec, count)
   OBJ obj;
   float *vec;
{
    OBJ cls;
    int nByte;
    OBJ o;
    int i, ninstVars, nInstBytes;
    char *pElem;

    if (! _isNonNilObject(obj)) return (float *)0;

    cls = __qClass(obj);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);
    nByte = __qSize(obj) - nInstBytes;
    pElem = (char *)(_InstPtr(obj)) + nInstBytes;

    switch (__intVal(_ClassInstPtr(cls)->c_flags) & ARRAYMASK) {
      case FLOATARRAY:
	/*
	 * best speed for float array
	 * - the data is already as we want it
	 */
	if (nByte < (count * sizeof(float))) return (float *)0;
	return (float *)pElem;

      case DOUBLEARRAY:
	/*
	 * for double array, have to copy-and-cast
	 */
	if (nByte < (count * sizeof(double))) return (float *)0;
	for (i=0; i<count; i++) {
	    vec[i] = *((double *)pElem);
	    pElem += sizeof(double);
	}
	return vec;

      case POINTERARRAY:
	/*
	 * for other array, have to fetch, check and store
	 * the elements can be floats, smallintegers or fractions
	 */
	if (nByte < (count * sizeof(OBJ))) return (float *)0;
	/* get elements one-by-one */
	for (i=0; i<count; i++) {
	    o = *(OBJ *)pElem;
	    if (__isFloat(o)) {
		vec[i] = _floatVal(o);
	    } else if (__isSmallInteger(o)) {
		vec[i] = (float)(__intVal(o));
	    } else if (__isFraction(o)
		    && __isSmallInteger(_FractionInstPtr(o)->f_numerator)
		    && __isSmallInteger(_FractionInstPtr(o)->f_denominator)) {
		float n, d;

		n = (float)(__intVal(_FractionInstPtr(o)->f_numerator));
		d = (float)(__intVal(_FractionInstPtr(o)->f_denominator));
		vec[i] = n / d;
	    } else
		return 0;
	    pElem += sizeof(OBJ);
	}
	return vec;
    }
    return (float *)0;
}

/*
 * fetch doubles from an st-object into a c-double array 
 * which may be a floatArray, doubleArray or array-of-something,
 * where something may be a float, fraction or smallInteger,
 */
static double *
getDoublesFromInto(obj, vec, count)
   OBJ obj;
   double *vec;
{
    OBJ cls, o;
    int nByte, i, ninstVars, nInstBytes;
    char *pElem;

    if (! _isNonNilObject(obj)) return (double *)0;
    cls = __qClass(obj);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);
    nByte = __qSize(obj) - nInstBytes;
    pElem = (char *)(_InstPtr(obj)) + nInstBytes;

    switch (__intVal(_ClassInstPtr(cls)->c_flags) & ARRAYMASK) {
      case DOUBLEARRAY:
	/* best speed for double array - the data is already as we want it */
	if (nByte < (count * sizeof(double))) return (double *)0;
	return (double *)pElem;

      case FLOATARRAY:
	if (nByte < (count * sizeof(float))) return (double *)0;
	for (i=0; i<count; i++) {
	    vec[i] = *((float *)pElem);
	    pElem += sizeof(float);
	}
	return vec;

      case POINTERARRAY:
	if (nByte < (count * sizeof(OBJ))) return (double *)0;
	/* get elements one-by-one */
	for (i=0; i<count; i++) {
	    o = *(OBJ *)pElem;
	    if (__isFloat(o)) 
		vec[i] = _floatVal(o);
	    else if (__isSmallInteger(o)) 
		vec[i] = (double)(__intVal(o));
	    else if (__isFraction(o)
		     && __isSmallInteger(_FractionInstPtr(o)->f_numerator)
		     && __isSmallInteger(_FractionInstPtr(o)->f_denominator)) {
		double n, d;

		n = (double)(__intVal(_FractionInstPtr(o)->f_numerator));
		d = (double)(__intVal(_FractionInstPtr(o)->f_denominator));
		vec[i] = n / d;

	    } else 
		return 0;
	    pElem += sizeof(OBJ);
	}
	return vec;
    }
    return (double *)0;
}

/*
 * move from a c-float array into an st-object,
 * the st-object MUST be either a float- or double array
 */
static
putFloatsFromInto(vec, obj, count)
   OBJ obj;
   float *vec;
{
    OBJ cls;
    int nByte;
    OBJ o;
    int i, ninstVars, nInstBytes;
    char *pElem;

    if (! _isNonNilObject(obj)) return 0;

    cls = __qClass(obj);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);
    nByte = __qSize(obj) - nInstBytes;
    pElem = (char *)(_InstPtr(obj)) + nInstBytes;

    switch (__intVal(_ClassInstPtr(cls)->c_flags) & ARRAYMASK) {
      case FLOATARRAY:
	if (nByte < (count * sizeof(float))) return 0;
	for (i=0; i<count; i++) {
	    *(float *)pElem = vec[i];
	    pElem += sizeof(float);
	}
	return 1;

      case DOUBLEARRAY:
	if (nByte < (count * sizeof(float))) return 0;
	for (i=0; i<count; i++) {
	    *(double *)pElem = vec[i];
	    pElem += sizeof(double);
	}
	return 1;
    }
    /* not implemented for others */

    return 0;
}

static Matrix*
getFloatsFromMatrixInto(obj, mp)
    OBJ obj;
    Matrix *mp;
{
    OBJ cls;
    extern OBJ FloatArray, DoubleArray, Array;
    int nByte;
    OBJ o;
    int ninstVars, nInstBytes;
    char *pElem;
    int x = 0;
    int i,j;

    if (! _isNonNilObject(obj)) return (Matrix *)0;

    cls = __qClass(obj);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);
    nByte = __qSize(obj) - nInstBytes;
    pElem = (char *)(_InstPtr(obj)) + nInstBytes;

    switch (__intVal(_ClassInstPtr(cls)->c_flags) & ARRAYMASK) {
      case FLOATARRAY:
	/*
	 * very easy for FLOATARRAY objects - no copying needed
	 */
	if (nByte < (16 * sizeof(float))) return (Matrix *)0;
	return (Matrix *) _FloatArrayInstPtr(obj)->f_element;
    
      case DOUBLEARRAY:
	/*
	 * for DOUBLEARRAY objects copy and cast
	 */
	if (nByte < (16 * sizeof(double))) return (Matrix *)0;
	for (i=0; i<4; i++) {
	    for (j=0; j<4; j++) {
		(*mp)[i][j] = _DoubleArrayInstPtr(obj)->d_element[x];
		x++;
	    }
	}
	return mp;

      case POINTERARRAY:
	if (nByte < (16 * sizeof(OBJ))) return (Matrix *)0;
	/* 
	 * get elements one-by-one 
	 */
	for (i=0; i<4; i++) {
	    for (j=0; j<4; j++) {
		o = _ArrayInstPtr(obj)->a_element[x];
		if (__isFloat(o)) {
		    (*mp)[i][j] = _floatVal(o);
		} else if (__isSmallInteger(o)) {
		    (*mp)[i][j] = (double)__intVal(o);
		} else if (__isFraction(o)
		    && __isSmallInteger(_FractionInstPtr(o)->f_numerator)
		    && __isSmallInteger(_FractionInstPtr(o)->f_denominator)) {
		    double n, d;

		    n = (double)(__intVal(_FractionInstPtr(o)->f_numerator));
		    d = (double)(__intVal(_FractionInstPtr(o)->f_denominator));
		    (*mp)[i][j] = n / d;
		} else
		    return (Matrix *)0;
		x++;
	    }
	}
	return mp;
    }
    return (Matrix *)0;
}

static float*
getFloatsFromFloatArrayInto(obj, fp)
    OBJ obj;
    float *fp;
{
    OBJ cls;
    extern OBJ FloatArray, DoubleArray, Array;
    int ninstVars;

    if (! _isNonNilObject(obj)) return (float *)0;
    cls = __qClass(obj);
    if (cls == FloatArray)
	return _FloatArrayInstPtr(obj)->f_element;

    if ((__intVal(_ClassInstPtr(cls)->c_flags) & ARRAYMASK) == FLOATARRAY) {
	ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
	return (float *) &(_InstPtr(obj)->i_instvars[ninstVars]);
    }

    /*
     * need more here (i.e. convert from array-of-floats)
     */
    return (float *)0;
}

%}
! !

!GLXWorkstation class methodsFor:'error handling'!

requestCodeOfLastError
%{  /* NOCONTEXT */

    RETURN ( _MKSMALLINT(lastRequestCode) );
%}
!

minorCodeOfLastError
%{  /* NOCONTEXT */

    RETURN ( _MKSMALLINT(lastMinorCode) );
%}
!

resourceIdOfLastError
%{  /* NOCONTEXT */

    RETURN ( _MKSMALLINT(lastResource) );
%}
!

errorStringOfLastError
%{
    RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) );
%}
! !

!GLXWorkstation methodsFor:'initialization'!

initializeFor:aDisplayName
    (super initializeFor:aDisplayName) isNil ifTrue:[^ nil].
%{
    if (_INST(displayId) != nil) {
	XSetErrorHandler(__XErrorHandler__);
    }
%}
!

initializeScreenProperties
    super initializeScreenProperties.

    "/ GL has a 'bug' (or feature ?)
    "/ which makes it exit (instead of giving an error return)
    "/ if a gl view is opened on a non-gl capable remote display.
    "/ we certainly do not want this here.
    "/ Since I cannot tell in advance if the remote display is gl capable,
    "/ and its too late once we know its not, we simply disallow any remote gl.
    "/ Sorry. (I guess, there are some query functions for that available, but I
    "/ have no documentation).

%{
# ifdef GLX
%}.
    glOK := (displayName = ':0') or:[displayName = ':0.0'].
%{
#else
%}.
    glOK := true.
%{
#endif
%}.

%{
    Display *dpy = myDpy;
    int dummy;

    if (ISCONNECTED) {
#if defined(XSGIStereo) && defined(GLX)
	if (_INST(glOK) != true)
	    _INST(hasStereoExtension) = false;
	else
	    if (XQueryExtension(dpy, "SGIFullScreenStereo", &dummy, &dummy, &dummy))
		_INST(hasStereoExtension) = true;
	    else
#endif
	      _INST(hasStereoExtension) = false;
    }
%}
! !

!GLXWorkstation methodsFor:'queries'!

supportsGLDrawing
    "return true, if this device supports 3D GL drawing."

    ^ glOK

    "
     Display supportsGLDrawing 
    "
!

glVersion
    "return a string describing the GL version.
     For informative use only; portable applications do not depend
     on the returned string."

%{  /* NOCONTEXT */
#ifdef VGL
    RETURN (__MKSTRING("vogl" COMMA_CON));
#else
    char buffer[128];

    if (_INST(glOK) == true) {
	gversion(buffer);
	RETURN (__MKSTRING(buffer COMMA_CON));
    } else {
	RETURN (nil);
    }
#endif
%}

    "
     Display glVersion 
    "
!

supportsRGB
    "return true, if this gl workstation supports rgb
     (in addition to indexed) colors. Actually, we return true
     for a real GL engine, false for the simulator here.
     For portable applications, always combine this with a query
     if the display supports GL drawing at all."

%{  /* NOCONTEXT */
#ifdef GLX
    RETURN ( _INST(glOK) );
#endif
%}.
    ^ false

    "
     Display supportsRGB 
    "
!

supportsLight
    "return true, if this gl workstation supports light sources
     (i.e. if its a real GL).
     For portable applications, always combine this with a query
     if the display supports GL drawing at all."

%{  /* NOCONTEXT */
#ifdef GLX
    RETURN ( _INST(glOK) );
#endif
%}.
    ^ false

    "
     Display supportsLight 
    "
!

supportsTextures
    "return true, if this gl workstation supports texture mapping
     (i.e. if its a real GL).
     For portable applications, always combine this with a query
     if the display supports GL drawing at all."

%{  /* NOCONTEXT */
#ifdef GLX
    if (getgdesc(GD_TEXTURE) != 0) {
	RETURN ( _INST(glOK) );
    }
#endif
%}.
    ^ false

    "
     Display supportsTextures 
    "
!

supportsDoubleBuffer
    "return true, if this gl workstation supports double buffering.
     For portable applications, always combine this with a query
     if the display supports GL drawing at all."

%{  /* NOCONTEXT */

#ifdef GLX
    if (getgdesc(GD_BITS_NORM_DBL_RED) != 0) {
	RETURN ( _INST(glOK) );
    }
#endif
%}.
    ^ false

    "
     Display supportsDoubleBuffer 
    "
!

supportsZBuffer
    "return true, if this gl workstation has z buffer support.
     For portable applications, always combine this with a query
     if the display supports GL drawing at all."

%{  /* NOCONTEXT */

#ifdef GLX
    if (getgdesc(GD_BITS_NORM_ZBUFFER) != 0) {
	RETURN ( _INST(glOK) );
    }
#endif
%}.
    ^ false

    "
     Display supportsZBuffer 
    "
!

maxZValue
    "return the max. Z value (only valid if z-buffer is supported)"
%{  
#ifdef GLX
    long zMax;
    extern OBJ _MKLARGEINT();

    if (_INST(glOK) == true) {
	zMax = getgdesc(GD_ZMAX);

	if ((zMax >= _MIN_INT) && (zMax <= _MAX_INT)) {
	    RETURN ( _MKSMALLINT(zMax) );
	}
	RETURN ( _MKLARGEINT(zMax) );
    }
#endif
%}.
    ^ nil
!

hasStereoExtension
    "return true, if this workstation supports stereo GL drawing.
     Both the server must support it, and the feature must have been
     enabled in the smalltalk system, for true to be returned."

    ^ hasStereoExtension

    "
     Display hasStereoExtension 
    "
! !

!GLXWorkstation methodsFor:'window creation'!

createGLXWindowFor:aView left:xpos top:ypos width:wwidth height:wheight type:glxType
    |ext wsuperView wsuperViewId windowId|

    glOK ifFalse:[^ nil].

    wsuperView := aView superView.
    wsuperView notNil ifTrue:[
	wsuperViewId := wsuperView id
    ].

%{
    Display *dpy = myDpy;
    int screen = __intVal(_INST(screen));
    Window newWindow, parentWindow;
    extern Window GLXCreateWindow();
    int t;

    if (__isSmallInteger(xpos) && __isSmallInteger(ypos)
     && __isSmallInteger(wwidth) && __isSmallInteger(wheight)) {
	if (__isExternalAddress(wsuperViewId)) {
	    parentWindow = _WindowVal(wsuperViewId);
	} else {
	    parentWindow = RootWindow(dpy, screen);
	}

	if (glxType == @symbol(colorIndexSingleBuffer))
	    t = GLXcolorIndexSingleBuffer;
	else if (glxType == @symbol(colorIndexDoubleBuffer))
	    t = GLXcolorIndexDoubleBuffer;
	else if (glxType == @symbol(rgbSingleBuffer))
	    t = GLXrgbSingleBuffer;
	else if (glxType == @symbol(rgbDoubleBuffer))
	    t = GLXrgbDoubleBuffer;
	else {
	    RETURN ( nil );
	}

	ENTERGLX;
	newWindow = GLXCreateWindow(dpy, parentWindow,
				    __intVal(xpos), __intVal(ypos),
				    __intVal(wwidth), __intVal(wheight),
				    0, t);
	LEAVEGLX;

	if (! newWindow) {
	    RETURN ( nil );
	}

	windowId = __MKOBJ(newWindow);
    }
%}.
    windowId notNil ifTrue:[
	self addKnownView:aView withId:windowId.
    ].
    ^ windowId
!

unlinkGLXView:aGLXWindowId
    "remove X/GLX link"
%{
    if (__isExternalAddress(aGLXWindowId)) {
	ENTERGLX;
	GLXUnlinkWindow(myDpy, _WindowVal(aGLXWindowId));
	LEAVEGLX;
    }
%}
! !

!GLXWorkstation methodsFor:'viewing'!

glxPerspectiveFovy:fovy aspect:aspect near:near far:far in:aGLXWindowId
    "define perspective projection"

%{  /* NOCONTEXT */

    Angle a_fovy;
    Coord c_near, c_far;
    float f_aspect;

    _ANGLE_ (fovy, a_fovy)
    _FLOAT_ (aspect, f_aspect)
    _COORD_ (near, c_near)
    _COORD_ (far, c_far)

    SETWIN(aGLXWindowId)
    perspective(a_fovy, f_aspect, c_near, c_far);

    RETURN (true);
%}
!

glxWindowLeft: left right: right bottom: bottom top: top near: near far: far in: aGLXWindowId
    "this one was added independently by JEFF - kept for his programs ..."

    self glxWindowLeft:left right:right top:top bottom:bottom near:near far:far in:aGLXWindowId
!

glxWindowLeft:left right:right top:top bottom:bottom near:near far:far in:aGLXWindowId
    "define perspective viewing pyramid"

%{  /* NOCONTEXT */
    Coord c_left, c_right, c_top, c_bot, c_near, c_far;

    _COORD_ (left, c_left)
    _COORD_ (right, c_right)
    _COORD_ (top, c_top)
    _COORD_ (bottom, c_bot)
    _COORD_ (near, c_near)
    _COORD_ (far, c_far)
    SETWIN(aGLXWindowId)
    window(c_left, c_right, c_bot, c_top, c_near, c_far);

    RETURN (true);
%}
!

glxLookatVx:vx vy:vy vz:vz px:px py:py pz:pz twist:twist in:aGLXWindowId
    "define viewing transformation"

%{  /* NOCONTEXT */

    Coord f_vx, f_vy, f_vz, f_px, f_py, f_pz;
    Angle a_twist;

    _COORD_ (vx, f_vx)
    _COORD_ (vy, f_vy)
    _COORD_ (vz, f_vz)
    _COORD_ (px, f_px)
    _COORD_ (py, f_py)
    _COORD_ (pz, f_pz)
    _ANGLE_ (twist, a_twist)
    SETWIN(aGLXWindowId)
    lookat(f_vx, f_vy, f_vz, f_px, f_py, f_pz, a_twist);
    RETURN (true);
%}
! 

glxOrthoLeft: left right: right bottom: bottom top: top near: near far: far in: aGLXWindowId
    "define orthogonal projection"

%{  /* NOCONTEXT */
    float f_left, f_right, f_bottom, f_top,
	  f_near, f_far;

    _FLOAT_(left, f_left)
    _FLOAT_(right, f_right)
    _FLOAT_(bottom, f_bottom)
    _FLOAT_(top, f_top)
    _FLOAT_(near, f_near)
    _FLOAT_(far, f_far)
    SETWIN(aGLXWindowId)
    ortho(f_left, f_right, f_bottom, f_top, f_near, f_far);
    RETURN (true);
%}
!

glxOrtho2Left: left right: right bottom: bottom top: top in: aGLXWindowId
    "define 2D orthogonal projection"

%{  /* NOCONTEXT */
    float f_left, f_right, f_top, f_bottom;

    SETWIN(aGLXWindowId)
    _FLOAT_(left, f_left)
    _FLOAT_(right, f_right)
    _FLOAT_(bottom, f_bottom)
    _FLOAT_(top, f_top)
    ortho2(f_left, f_right, f_bottom, f_top);
%}
.
    ^ true
!

glxPolarviewDist: dist azim: azim inc: inc twist: twist in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_dist;
    Angle a_azim, a_inc, a_twist;

    _COORD_(dist, c_dist)
    _ANGLE_(azim, a_azim)
    _ANGLE_(inc, a_inc)
    _ANGLE_(twist, a_twist)
    SETWIN(aGLXWindowId)
    polarview(c_dist, a_azim, a_inc, a_twist);
    RETURN (true);
%}
! 

glxReshapeViewPortIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    reshapeviewport();
%}
.
    ^ true
!

glxViewportLeft:left right:right bottom:bottom top:top in:aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    viewport(_screencoordVal(left), _screencoordVal(right), 
	     _screencoordVal(bottom), _screencoordVal(top));
    RETURN (true);
%}
! !

!GLXWorkstation methodsFor:'window control'!

glxWinclose:gwid in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    winclose(_longVal(gwid));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxWinconstraintsIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    winconstraints();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxWindepth: gwid in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(windepth(_longVal(gwid))));
#endif
%}
.
    ^ false
! 

glxWingetIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(winget()));
#endif
%}
.
    ^ false
! 

glxWinmoveX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    winmove(_longVal(x), _longVal(y));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxWinpopIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    winpop();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxWinpositionX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    winposition(_longVal(x1), _longVal(y1), _longVal(x2), _longVal(y2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxWinpushIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    winpush();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxWinset: gwid in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    winset(_longVal(gwid));
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'transformations'!

glxTranslateX:x in:aGLXWindowId
    "translate current matrix on X axis"

%{  /* NOCONTEXT */

    Coord c_x;

    _COORD_ (x, c_x)
    SETWIN(aGLXWindowId)
    translate(c_x, (Coord)0, (Coord)0);
    RETURN (true);
%}
!

glxTranslateY:y in:aGLXWindowId
    "translate current matrix on Y axis"

%{  /* NOCONTEXT */

    Coord c_y;

    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    translate((Coord)0, c_y, (Coord)0);
    RETURN (true);
%}
!

glxTranslateZ:z in:aGLXWindowId
    "translate current matrix on Z axis"

%{  /* NOCONTEXT */

    Coord c_z;

    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    translate((Coord)0, (Coord)0, c_z);
    RETURN (true);
%}
!

glxTranslateX:x y:y z:z in:aGLXWindowId
    "translate current matrix, given individual x, y and z values"

%{  /* NOCONTEXT */

    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    translate(c_x, c_y, c_z);
    RETURN (true);
%}
!

glxTranslate:arrayOf3Floats in:aGLXWindowId
    "translate current matrix, given a 3-element vector"

%{  /* NOCONTEXT */

    float vec[3], *v;

    if (! (v = getFloatsFromInto(arrayOf3Floats, vec, 3))) RETURN(false);

    SETWIN(aGLXWindowId)
    translate((Coord)(v[0]), (Coord)(v[1]), (Coord)(v[2]));
    RETURN (true);
%}
!

glxScaleX:x in:aGLXWindowId
    "scale in x direction"

%{  /* NOCONTEXT */

    float f_x;

    _FLOAT_ (x, f_x)
    SETWIN(aGLXWindowId)
    scale(f_x, (float)0, (float)0);
    RETURN (true);
%}
!

glxScaleY:y in:aGLXWindowId
    "scale in y direction"

%{  /* NOCONTEXT */

    float f_y;

    _FLOAT_ (y, f_y)
    SETWIN(aGLXWindowId)
    scale((float)0, f_y, (float)0);
    RETURN (true);
%}
!

glxScaleZ:z in:aGLXWindowId
    "scale in z direction"

%{  /* NOCONTEXT */

    float f_z;

    _FLOAT_ (z, f_z)
    SETWIN(aGLXWindowId)
    scale((float)0, (float)0, f_z);
    RETURN (true);
%}
!

glxScaleX:x y:y z:z in:aGLXWindowId
    "scale & mirror current matrix, given individual x, y and z values"

%{  /* NOCONTEXT */

    float f_x, f_y, f_z;

    _FLOAT_ (x, f_x)
    _FLOAT_ (y, f_y)
    _FLOAT_ (z, f_z)
    SETWIN(aGLXWindowId)
    scale(f_x, f_y, f_z);
    RETURN (true);
%}
!

glxScale:arrayOf3Floats in:aGLXWindowId
    "scale current matrix, given a 3-element vector"

%{  /* NOCONTEXT */

    float vec[3], *v;

    if (! (v = getFloatsFromInto(arrayOf3Floats, vec, 3))) RETURN(false);

    SETWIN(aGLXWindowId)
    scale(v[0], v[1], v[2]);
    RETURN (true);
%}
!

glxRotateX:angle in:aGLXWindowId
    "rotate the current matrix on x axis.
     The angle is in degrees."

%{  /* NOCONTEXT */

    SETWIN(aGLXWindowId)
    RETURN (doRotate(angle, 'x'));
%}
!

glxRotateY:angle in:aGLXWindowId
    "rotate the current matrix on y axis.
     The angle is in degrees."

%{  /* NOCONTEXT */

    SETWIN(aGLXWindowId)
    RETURN (doRotate(angle, 'y'));
%}
!

glxRotateZ:angle in:aGLXWindowId
    "rotate the current matrix on z axis.
     The angle is in degrees."

%{  /* NOCONTEXT */

    SETWIN(aGLXWindowId)
    RETURN (doRotate(angle, 'z'));
%}
!

glxRotate:angle axis:axis in:aGLXWindowId
    "rotate the current matrix around the axis given by the axis arg,
     which must be one of the symbols: #x, #y or #z.
     The angle is in degrees."

%{  /* NOCONTEXT */

    char c_axis;

    if (axis == @symbol(x))
	c_axis = 'x';
    else if (axis == @symbol(y))
	c_axis = 'y';
    else if (axis == @symbol(z))
	c_axis = 'z';
    else {
	RETURN (false);
    }

    SETWIN(aGLXWindowId)
    RETURN ( doRotate(angle, c_axis) );
%}
!

glxRotateX:xAngle y:yAngle z:zAngle in:aGLXWindowId
    "rotate the current matrix on all axes, given individual x, y and z values.
     The values are in degrees"

%{  /* NOCONTEXT */

    SETWIN(aGLXWindowId)
    if ( doRotate(xAngle, 'x') == true) {
	if ( doRotate(yAngle, 'y') == true) {
	    RETURN (doRotate(zAngle, 'z'));
	}
    }
%}
.
    ^ false
!

glxRotate:arrayOf3Floats in:aGLXWindowId
    "rotate current matrix, given a 3-element vector (or more).
     The elements of the array are degrees."

%{  /* NOCONTEXT */

    float vec[3], *v;

    if (! (v = getFloatsFromInto(arrayOf3Floats, vec, 3))) RETURN(false);

    SETWIN(aGLXWindowId)
    rot(v[0], 'x');
    rot(v[1], 'y');
    rot(v[2], 'z');
    RETURN (true);
%}
!

glxRotateIX:angle in:aGLXWindowId
    "rotate the current matrix on x axis.
     The angle is an integer specifying tenths of a degree."

%{  /* NOCONTEXT */

    if (__isSmallInteger(angle)) {
	SETWIN(aGLXWindowId)
	rotate(__intVal(angle), 'x');
	RETURN (true);
    }
%}
.
    ^ false
!

glxRotateIY:angle in:aGLXWindowId
    "rotate the current matrix on x axis.
     The angle is an integer specifying tenths of a degree."

%{  /* NOCONTEXT */

    if (__isSmallInteger(angle)) {
	SETWIN(aGLXWindowId)
	rotate(__intVal(angle), 'y');
	RETURN (true);
    }
%}
.
    ^ false
!

glxRotateIZ:angle in:aGLXWindowId
    "rotate the current matrix on x axis.
     The angle is an integer specifying tenths of a degree."

%{  /* NOCONTEXT */

    if (__isSmallInteger(angle)) {
	SETWIN(aGLXWindowId)
	rotate(__intVal(angle), 'z');
	RETURN (true);
    }
%}
.
    ^ false
!

glxRotateI:angle axis:axis in:aGLXWindowId
    "rotate the current matrix around the axis given by the axis arg,
     which must be one of the symbols: #x, #y or #z.
     The angle is an integer specifying tenths of a degree."

%{  /* NOCONTEXT */

    char c_axis;

    if (axis == @symbol(x))
	c_axis = 'x';
    else if (axis == @symbol(y))
	c_axis = 'y';
    else if (axis == @symbol(z))
	c_axis = 'z';
    else {
	RETURN (false);
    }

    if (__isSmallInteger(angle)) {
	SETWIN(aGLXWindowId)
	rotate(__intVal(angle), c_axis);
	RETURN (true);
    }
%}
.
    ^ false
!

glxRotateIX:xAngle y:yAngle z:zAngle in:aGLXWindowId
    "rotate the current matrix on all axes, given individual x, y and z values.
     The values are integers specifying tenths of a degree."

%{  /* NOCONTEXT */

    if (__bothSmallInteger(xAngle, yAngle)
     && __isSmallInteger(zAngle)) {
	SETWIN(aGLXWindowId)
	rotate(__intVal(xAngle), 'x');
	rotate(__intVal(yAngle), 'y');
	rotate(__intVal(zAngle), 'z');
	RETURN (true);
    }
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'materials & lights'!

glxLmdef:what index:index np:np props:props in:aGLXWindowId
    "define a material, light source or lighting model;
     what must be one of #material, #light or #lightModel.
     props must be a FloatArray or a subclass of FloatArray"

%{  /* NOCONTEXT */
#ifdef GLX
    short defType;
    short i_index, i_np;
    extern OBJ FloatArray;
    float *fp;
    OBJ cls;
    int ninstVars, nInstBytes;

    if (what == @symbol(material))
	defType = DEFMATERIAL;
    else if (what == @symbol(light))
	defType = DEFLIGHT;
    else if (what == @symbol(lightModel))
	defType = DEFLMODEL;
    else {
	RETURN (false);
    }

    _INT_ (index, i_index);
    _INT_ (np, i_np);

    if (! _isNonNilObject(props)) fp = NULL;
    else {
	cls = __qClass(props);
	if (cls == FloatArray)
	    fp = _FloatArrayInstPtr(props)->f_element;
	else {
	    if ((__intVal(_ClassInstPtr(cls)->c_flags) & ARRAYMASK) == FLOATARRAY) {
		ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
		fp = (float *) &(_InstPtr(props)->i_instvars[ninstVars]);
	    } else {
		RETURN (false);
	    }
	} 
    }
    SETWIN(aGLXWindowId)
    lmdef(defType, i_index, i_np, fp);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxLmbind:target index:index in:aGLXWindowId
    "select a material, light or lighting model.
     target must be a symbol from: #material, #backMaterial,
     #light0-light7 or #lightModel."

%{  /* NOCONTEXT */
#ifdef GLX
    short defType;
    short i_index;

    if (target == @symbol(material))
	defType = MATERIAL;
    else if (target == @symbol(backMaterial))
	defType = BACKMATERIAL;
    else if (target == @symbol(light0))
	defType = LIGHT0;
    else if (target == @symbol(light1))
	defType = LIGHT1;
    else if (target == @symbol(light2))
	defType = LIGHT2;
    else if (target == @symbol(light3))
	defType = LIGHT3;
    else if (target == @symbol(light4))
	defType = LIGHT4;
    else if (target == @symbol(light5))
	defType = LIGHT5;
    else if (target == @symbol(light6))
	defType = LIGHT6;
    else if (target == @symbol(light7))
	defType = LIGHT7;
    else if (target == @symbol(lightModel))
	defType = LMODEL;
    else { 
	RETURN (false); 
    }

    _INT_ (index, i_index);
    SETWIN(aGLXWindowId)
    lmbind(defType, i_index);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxTexDef2d:index nc:nc width:w height:h bits:image np:np props:props in:aGLXWindowId
    "define a 2D texture. index is the 'name' of the texture;
     nc is the number of components (1-4) per pixel;
     w/h define the size of the texture; bits is a byteArray containing the
     long-word aligned pixel data; np is the number of props found in
     the floatArray props. Props must be delimited by a 0.0 entry."

%{  /* NOCONTEXT */
#ifdef GLX
    unsigned char *cp;
    const float *fp;
    OBJ cls;
    float fbuff[30];

    if (__isByteArray(image)) {
	cp = _ByteArrayInstPtr(image)->ba_element;
	fp = getFloatsFromFloatArrayInto(props, fbuff);

	SETWIN(aGLXWindowId)
	texdef2d(__intVal(index), __intVal(nc), __intVal(w), __intVal(h),
		 (const unsigned long *)cp, __intVal(np), fp);
	RETURN (true);
    }
#endif
%}
.
    ^ false
! 

glxTexDef3d:index nc:nc width:w height:h depth:d bits:image np:np props:props in:aGLXWindowId
    "define a 3D texture. index is the 'name' of the texture;
     nc is the number of components (1-4) per pixel;
     w/h/d define the size of the texture; bits is a byteArray containing the
     long-word aligned pixel data; np is the number of props found in
     the floatArray props. Props must be delimited by a 0.0 entry."

%{  /* NOCONTEXT */
#ifdef GLX
    unsigned char *cp;
    const float *fp;
    OBJ cls;
    float fbuff[30];

    if (__isByteArray(image)) {
	cp = _ByteArrayInstPtr(image)->ba_element;
	fp = getFloatsFromFloatArrayInto(props, fbuff);

	SETWIN(aGLXWindowId)
	texdef3d(__intVal(index), __intVal(nc), __intVal(w), __intVal(h),
		 __intVal(d),
		 (const unsigned long *)cp, __intVal(np), fp);
	RETURN (true);
    }
#endif
%}
.
    ^ false
! 

glxTevdef:index np:np props:props in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    const float *fp;
    float fbuff[30];

    SETWIN(aGLXWindowId)
    fp = getFloatsFromFloatArrayInto(props, fbuff);
    tevdef(__intVal(index), __intVal(np), fp);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxTevbind:target index:index in:aGLXWindowId
    "bind a texture environment; target must be 0
     or the symbol #env0."

%{  /* NOCONTEXT */
#ifdef GLX
    long t;

    if (__isSmallInteger(target)) {
	t = __intVal(target);
    } else {
	if (target == @symbol(env0)) {
	    t = TV_ENV0;
	} else {
	    RETURN (false);
	}
    }
    SETWIN(aGLXWindowId)
    tevbind(t, __intVal(index));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxTexbind:target index:index in:aGLXWindowId
    "bind a texture; target must be an integer or one
     of the symbols #texture0, #textureDetail or #textureIdle."

%{  /* NOCONTEXT */
#ifdef GLX
    long t;

    if (__isSmallInteger(target)) {
	t = __intVal(target);
    } else {
	if (target == @symbol(texture0)) {
	    t = TX_TEXTURE_0;
	} else if (target == @symbol(textureDetail)) {
	    t = TX_TEXTURE_DETAIL;
	} else if (target == @symbol(textureIdle)) {
	    t = TX_TEXTURE_IDLE;
	} else {
	    RETURN (false);
	}
    }
    SETWIN(aGLXWindowId)
    texbind(t, __intVal(index));
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'color'!

glxColor:index in:aGLXWindowId
    "set color, for non gouraud shading, we dont care if the
     argument is integer or float; otherwise, better results are
     expected with float values."

%{  /* NOCONTEXT */

    SETWIN(aGLXWindowId)
    if (__isSmallInteger(index)) {
	color((Colorindex)(__intVal(index)));
	RETURN (true);
    }
    if (__isFloat(index)) {
	colorf((float)(_floatVal(index)));
	RETURN (true);
    }
%}
.
    ^ false
!

glxColorRed:r green:g blue:b in:aGLXWindowId
    "set color, args must be integer values in 0..255"

%{  /* NOCONTEXT */

#ifdef GLX
    short s_r, s_g, s_b;

    _INT_(r, s_r);
    _INT_(g, s_g);
    _INT_(b, s_b);
    SETWIN(aGLXWindowId)
    RGBcolor(s_r, s_g, s_b);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxColorRed:r green:g blue:b alpha:a in:aGLXWindowId
    "set color including alpha value, args must be integer values within 0..255"

%{  /* NOCONTEXT */

#ifdef GLX
    short s_r, s_g, s_b, s_a;

    _INT_(r, s_r);
    _INT_(g, s_g);
    _INT_(b, s_b);
    _INT_(a, s_a);
    SETWIN(aGLXWindowId)
    cpack((((((s_a<<8) | s_b) << 8) | s_g) << 8) | s_r);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxTextcolor: tcolor in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    textcolor(_colorindexVal(tcolor));
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'clearing'!

glxClearIn:aGLXWindowId
    "clear to current color"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    clear();
    RETURN (true);
%}
!

glxZClearIn:aGLXWindowId
    "clear z buffer"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    zclear();
    RETURN (true);
#endif
%}
.
    ^ false
!

glxCzclearCval:cval zval:zval in:aGLXWindowId
    "clear to a color (cval) and clear z buffer to zval simultaniously"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    czclear((ulong)__intVal(cval), __intVal(zval));
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'matrix stack'!

glxPushmatrixIn:aGLXWindowId
    "push down transformation stack"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    pushmatrix();
    RETURN (true);
%}
!

glxPopmatrixIn:aGLXWindowId
    "pop transformation stack"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    popmatrix();
    RETURN (true);
%}
!

glxGetMatrix:arrayOf16Floats in:aGLXWindowId
    "argument must be an array (a matrix) of 16 floats. The current matrix
     will be stored into that."

%{  /* NOCONTEXT */
    Matrix matrix;

    SETWIN(aGLXWindowId)
    getmatrix(matrix);
    if (! putFloatsFromInto(matrix, arrayOf16Floats, 16)) RETURN(false);
%}
.
    ^ true
!

glxLoadMatrix:arrayOf16Floats in:aGLXWindowId
    "argument must be an array(a matrix) of 16 floats. The current matrix
     will be loaded from that."

%{  /* NOCONTEXT */
    Matrix matrix;
    Matrix *m;

    if (! (m = getFloatsFromMatrixInto(arrayOf16Floats, &matrix))) RETURN (false);
    SETWIN(aGLXWindowId)
    loadmatrix(*m);
    RETURN (true);
%}
!

glxMultMatrix:arrayOf16Floats in:aGLXWindowId
    "argument must be an array(a matrix) of 16 floats containing a
     matrix to multiply into the current matrix."

%{  /* NOCONTEXT */
    Matrix matrix;
    Matrix *m;

    if (! (m = getFloatsFromMatrixInto(arrayOf16Floats, &matrix))) RETURN (false);
    SETWIN(aGLXWindowId)
    multmatrix(*m);
    RETURN (true);
%}
! !

!GLXWorkstation methodsFor:'video and planes'!

glxStereobufferIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    stereobuffer();
    RETURN (true);
#endif
%}
.
    ^ false
!

glxUnderlay: planes in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    underlay(_longVal(planes));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxOverlayPlanes: planes in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    overlay(_longVal(planes));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxVideocmd:cmd in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    videocmd(_longVal(cmd));
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'double buffering'!

glxDoubleBufferIn:aGLXWindowId
    "set double buffer mode"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    doublebuffer();
    RETURN (true);
%}
!

glxSingleBufferIn: aGLXWindowId
    "set single buffer mode"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    singlebuffer();
    RETURN (true);
%}
!

glxSwapBuffersIn:aGLXWindowId
    "swap double buffers"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    swapbuffers();
    RETURN (true);
%}
!

glxFrontBufferIn:aGLXWindowId
    "switch to front buffer - turning backbuffer off"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
#ifdef GLX
    backbuffer(FALSE);
#endif
    frontbuffer(TRUE);
    RETURN (true);
%}
!

glxBackBufferIn:aGLXWindowId
    "switch to back buffer - turning frontbuffer off"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
#ifdef GLX
    frontbuffer(FALSE);
#endif
    backbuffer(TRUE);
    RETURN (true);
%}
!

glxBackbuffer: b in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    backbuffer(_booleanVal(b));
    RETURN (true);
%}
! 

glxFrontbuffer: b in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    frontbuffer(_booleanVal(b));
    RETURN (true);
%}
! !

!GLXWorkstation methodsFor:'zbuffer'!

glxZbuffer:aBoolean in:aGLXWindowId
    "enable/disable z-buffer operation"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    zbuffer(aBoolean == false ? FALSE : TRUE);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxZbsize: planes in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    zbsize(_longVal(planes));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxZdraw: b in: aGLXWindowId
    "enable/disable drawing into the z-buffer"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    zdraw(_booleanVal(b));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxZfunction: func in: aGLXWindowId
    "set the z-buffer comparison function.
     func may be either the numeric value or a symbol (preferred)"

%{  /* NOCONTEXT */
#ifdef GLX
    long f;

    SETWIN(aGLXWindowId)
    if (func == @symbol(NEVER))
	f = ZF_NEVER;
    else if (func == @symbol(LESS))
	f = ZF_LESS;
    else if (func == @symbol(EQUAL))
	f = ZF_EQUAL;
    else if (func == @symbol(LEQUAL))
	f = ZF_LEQUAL;
    else if (func == @symbol(GREATER))
	f = ZF_GREATER;
    else if (func == @symbol(NOTEQUAL))
	f = ZF_NOTEQUAL;
    else if (func == @symbol(GEQUAL))
	f = ZF_GEQUAL;
    else if (func == @symbol(ALWAYS))
	f = ZF_ALWAYS;
    else
	f = _longVal(func);
    zfunction(f);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxZsource: src in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    zsource(_longVal(src));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxZwritemask: mask in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    zwritemask((ulong)__intVal(mask));
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'misc'!

glxRGBmodeIn:aGLXWindowId
    "set true color mode (no colormap)"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RGBmode();
    RETURN (true);
#endif
%}
.
    ^ false
!

glxGconfigIn:aGLXWindowId
    "must be sent after RGBmode, doubleBuffer etc. to have these
     changes really take effect. See GLX manual.
     (Actually, it seems to be not allowed - I dont really know)"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    gconfig();
    RETURN (true);
%}
!

glxNmode:aSymbol in:aGLXWindowId
    "set normalize mode: #auto, #normalize"

%{  /* NOCONTEXT */
#ifdef GLX
    if (aSymbol == @symbol(auto)) {
	nmode(NAUTO);
	RETURN (true);
    }
    if (aSymbol == @symbol(normalize)) {
	nmode(NNORMALIZE);
	RETURN (true);
    }
#endif
%}
.
    ^ false
!

glxMmode:aSymbol in:aGLXWindowId
    "set matrix mode: #single, #viewing, #projection or #texture"

%{  /* NOCONTEXT */
#ifdef GLX
    if (aSymbol == @symbol(single)) {
	mmode(MSINGLE);
	RETURN (true);
    }
    if (aSymbol == @symbol(viewing)) {
	mmode(MVIEWING);
	RETURN (true);
    }
    if (aSymbol == @symbol(projection)) {
	mmode(MPROJECTION);
	RETURN (true);
    }
    if (aSymbol == @symbol(texture)) {
	mmode(MTEXTURE);
	RETURN (true);
    }
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'flat drawing'!

glxBeginPointIn:aGLXWindowId
    "start a point-group"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    bgnpoint();
    RETURN (true);
%}
!

glxEndPointIn:aGLXWindowId
    "end a point group"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    endpoint();
    RETURN (true);
%}
!

glxBeginClosedLineIn:aGLXWindowId
    "start a closed line"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    bgnclosedline();
    RETURN (true);
%}
!

glxEndClosedLineIn:aGLXWindowId
    "end a closed line"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    endclosedline();
    RETURN (true);
%}
!

glxBeginLineIn:aGLXWindowId
    "start a line group"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    bgnline();
    RETURN (true);
%}
!

glxEndLineIn:aGLXWindowId
    "end a line group"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    endline();
    RETURN (true);
%}
!

glxBeginPolygonIn:aGLXWindowId
    "start a polygon"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    bgnpolygon();
    RETURN (true);
%}
!

glxEndPolygonIn:aGLXWindowId
    "end a polygon"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    endpolygon();
    RETURN (true);
%}
!

glxBeginTriangleMeshIn:aGLXWindowId
    "start a triangle mesh"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    bgntmesh();
    RETURN (true);
%}
!

glxEndTriangleMeshIn:aGLXWindowId
    "end a triangle mesh"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    endtmesh();
    RETURN (true);
%}
!

glxBeginQuadrilateralStripIn:aGLXWindowId
    "start a quadrilateral strip"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    bgnqstrip();
    RETURN (true);
%}
!

glxEndQuadrilateralStripIn:aGLXWindowId
    "end a quadrilateral strip"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    endqstrip();
    RETURN (true);
%}
! !

!GLXWorkstation methodsFor:'sphere drawing'!

glxSphDraw:arrayOf4Floats in:aGLXWindowId
    "argument must be an array(a matrix) of 4 floats containing the
     sphere - in real GL only"

%{  /* NOCONTEXT */
#ifdef GLX
    float vec[4], *v;

    if (! (v = getFloatsFromInto(arrayOf4Floats, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    sphdraw(v);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSphDrawX:x y:y z:z radius:r in:aGLXWindowId
    "arguments must be convertable to floats - in real GL only"

%{  /* NOCONTEXT */
#ifdef GLX
    float vec[4];

    _FLOAT_(x, vec[0])
    _FLOAT_(y, vec[1])
    _FLOAT_(z, vec[2])
    _FLOAT_(r, vec[3])
    SETWIN(aGLXWindowId)
    sphdraw(vec);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxSphfreeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sphfree();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSphgnpolysIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(sphgnpolys()));
#endif
%}
.
    ^ false
! 

glxSphmode: attribute value: value in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sphmode(__intVal(attribute), __intVal(value));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSphobj: objid in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sphobj(_objectVal(objid));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSphrotmatrix: mat in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Matrix matrix, *m;

    if (! (m = getFloatsFromMatrixInto(mat, &matrix))) RETURN (false);
    SETWIN(aGLXWindowId)
    sphrotmatrix(*m);
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'patches & surfaces'!

glxDefBasis:id mat:aMatrix in:aGLXWindowId
    "define the basis"

%{  /* NOCONTEXT */
    Matrix matrix;
    Matrix *m;

    if (! (m = getFloatsFromMatrixInto(aMatrix, &matrix))) RETURN (false);
    if (__isSmallInteger(id)) {
	SETWIN(aGLXWindowId)
	defbasis((short)(__intVal(id)), *m);
	RETURN (true);
    }
%}
.
    ^ false
!

glxPatchCurvesU:u v:v in:aGLXWindowId
    "set the number of curves in a patch"

%{  /* NOCONTEXT */
    if (__bothSmallInteger(u, v)) {
	SETWIN(aGLXWindowId)
	patchcurves((long)__intVal(u), (long)__intVal(v));
	RETURN (true);
    }
%}
.
    ^ false
!

glxPatchPrecisionU:u v:v in:aGLXWindowId
    "set the patch precision"

%{  /* NOCONTEXT */
    if (__bothSmallInteger(u, v)) {
	SETWIN(aGLXWindowId)
	patchprecision((long)__intVal(u), (long)__intVal(v));
	RETURN (true);
    }
%}
.
    ^ false
!

glxPatchBasisU:u v:v in:aGLXWindowId
    "set the current basis matrices"

%{  /* NOCONTEXT */
    if (__bothSmallInteger(u, v)) {
	SETWIN(aGLXWindowId)
	patchbasis((long)__intVal(u), (long)__intVal(v));
	RETURN (true);
    }
%}
.
    ^ false
!

glxPatchX:arrayOf16XFloats y:arrayOf16YFloats z:arrayOf16ZFloats in:aGLXWindowId
    "arguments must be arrays of 16 floats containing the patch"

%{  /* NOCONTEXT */
    Matrix matrixX, matrixY, matrixZ;
    Matrix *mX, *mY, *mZ;

    if (! (mX = getFloatsFromMatrixInto(arrayOf16XFloats, &matrixX))) RETURN (false);
    if (! (mY = getFloatsFromMatrixInto(arrayOf16YFloats, &matrixY))) RETURN (false);
    if (! (mZ = getFloatsFromMatrixInto(arrayOf16ZFloats, &matrixZ))) RETURN (false);
    SETWIN(aGLXWindowId)
    patch(*mX, *mY, *mZ);
    RETURN (true);
%}
!

glxBeginCurveIn:aGLXWindowId
    "start a NURBS curve def - in real GL only"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    bgncurve();
    RETURN (true);
#endif
%}
.
    ^ false
!

glxEndCurveIn:aGLXWindowId
    "end a NURBS curve def - in real GL only"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    endcurve();
    RETURN (true);
#endif
%}
.
    ^ false
!

glxBeginSurfaceIn:aGLXWindowId
    "start a NURBS surface def - in real GL only"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    bgnsurface();
    RETURN (true);
#endif
%}
.
    ^ false
!

glxEndSurfaceIn:aGLXWindowId
    "end a NURBS surface def - in real GL only"

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    endsurface();
    RETURN (true);
#endif
%}
.
    ^ false
!

glxNurbsSurfaceUKnotCount: uKnotCount uKnot: uKnot 
    vKnotCount: vKnotCount vKnot: vKnot
    uOffset: uOffset vOffset: vOffset 
    ctlArray: ctlArray 
    uOrder: uOrder vOrder: vOrder 
    type: type in: aGLXWindowId

    | ctlPoints i |
    ctlPoints := DoubleArray new: ctlArray size * (ctlArray first size).
    i := 1.
    ctlArray do: [:point |
	point do: [:coord | 
	    ctlPoints at: i put: coord.
	    i := i + 1]].

%{  /* NOCONTEXT */
#ifdef GLX
    char *uKnotElements, *vKnotElements, *ctlElements;
    OBJ cls;
    int ninstVars, nInstBytes;

    SETWIN(aGLXWindowId)
    cls = __qClass(ctlPoints);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);

    ctlElements = (char *)(_InstPtr(ctlPoints)) + nInstBytes;
    uKnotElements = (char *)(_InstPtr(uKnot)) + nInstBytes;
    vKnotElements = (char *)(_InstPtr(vKnot)) + nInstBytes;

    nurbssurface (
	__intVal(uKnotCount), (double *)uKnotElements,
	__intVal(vKnotCount), (double *)vKnotElements,
	__intVal(uOffset), __intVal(vOffset),
	(double *)ctlElements, 
	__intVal(uOrder), __intVal(vOrder), __intVal(type));
    RETURN(true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'arcs and circles'!

glxArcX: x y: y radius: radius startang: startang endang: endang in: aGLXWindowId
    "draw an arc"

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_radius;
    Angle a_startang, a_endang;

    _COORD_(x, c_x)
    _COORD_(y, c_y)
    _COORD_(radius, c_radius)
    _ANGLE_(startang, a_startang)
    _ANGLE_(endang, a_endang)
    SETWIN(aGLXWindowId)
    arc(c_x, c_y, c_radius, a_startang, a_endang);
    RETURN (true);
%}
! 

glxArciX: x y: y radius: radius startang: startang endang: endang in: aGLXWindowId
    "draw an arc"

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_radius;
    Angle a_startang, a_endang;

    _ICOORD_(x, c_x)
    _ICOORD_(y, c_y)
    _ICOORD_(radius, c_radius)
    _ANGLE_(startang, a_startang)
    _ANGLE_(endang, a_endang)
    SETWIN(aGLXWindowId)
    arci(c_x, c_y, c_radius, a_startang, a_endang);
    RETURN (true);
%}
! 

glxArcsX: x y: y radius: radius startang: startang endang: endang in: aGLXWindowId
    "draw an arc"

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_radius;
    Angle a_startang, a_endang;

    _SCOORD_(x, c_x)
    _SCOORD_(y, c_y)
    _SCOORD_(radius, c_radius)
    _ANGLE_(startang, a_startang)
    _ANGLE_(endang, a_endang)
    SETWIN(aGLXWindowId)
    arcs(c_x, c_y, c_radius, a_startang, a_endang);
    RETURN (true);
%}
! 

glxArcfX: x y: y radius: radius startang: startang endang: endang in: aGLXWindowId
    "draw a filled arc"

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_radius;
    Angle a_startang, a_endang;

    _COORD_(x, c_x)
    _COORD_(y, c_y)
    _COORD_(radius, c_radius)
    _ANGLE_(startang, a_startang)
    _ANGLE_(endang, a_endang)
    SETWIN(aGLXWindowId)
    arcf(c_x, c_y, c_radius, a_startang, a_endang);
    RETURN (true);
%}
! 

glxArcfiX: x y: y radius: radius startang: startang endang: endang in: aGLXWindowId
    "draw a filled arc"

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_radius;
    Angle a_startang, a_endang;

    _ICOORD_(x, c_x)
    _ICOORD_(y, c_y)
    _ICOORD_(radius, c_radius)
    _ANGLE_(startang, a_startang);
    _ANGLE_(endang, a_endang)
    SETWIN(aGLXWindowId)
    arcfi(c_x, c_y, c_radius, a_startang, a_endang);
    RETURN (true);
%}
! 

glxArcfsX: x y: y radius: radius startang: startang endang: endang in: aGLXWindowId
    "draw a filled arc"

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_radius;
    Angle a_startang, a_endang;

    _SCOORD_(x, c_x)
    _SCOORD_(y, c_y)
    _SCOORD_(radius, c_radius)
    _ANGLE_(startang, a_startang)
    _ANGLE_(endang, a_endang)
    SETWIN(aGLXWindowId)
    arcfs(c_x, c_y, c_radius, a_startang, a_endang);
    RETURN (true);
%}
!

glxCircX: x y: y radius: radius in: aGLXWindowId
    "draw a circle"

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_radius;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (radius, c_radius)
    SETWIN(aGLXWindowId)
    circ(c_x, c_y, c_radius);
    RETURN (true);
%}
! 

glxCirciX: x y: y radius: radius in: aGLXWindowId
    "draw a circle"

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_radius;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (radius, c_radius)
    SETWIN(aGLXWindowId)
    circi(c_x, c_y, c_radius);
    RETURN (true);
%}
! 

glxCircsX: x y: y radius: radius in: aGLXWindowId
    "draw a circle"

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_radius;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (radius, c_radius)
    SETWIN(aGLXWindowId)
    circs(c_x, c_y, c_radius);
    RETURN (true);
%}
! 

glxCircfX: x y: y radius: radius in: aGLXWindowId
    "draw a filled circle"

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_radius;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (radius, c_radius)
    SETWIN(aGLXWindowId)
    circf(c_x, c_y, c_radius);
    RETURN (true);
%}
! 

glxCircfiX: x y: y radius: radius in: aGLXWindowId
    "draw a filled circle"

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_radius;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (radius, c_radius)
    SETWIN(aGLXWindowId)
    circfi(c_x, c_y, c_radius);
    RETURN (true);
%}
! 

glxCircfsX: x y: y radius: radius in: aGLXWindowId
    "draw a filled circle"

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_radius;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (radius, c_radius)
    SETWIN(aGLXWindowId)
    circfs(c_x, c_y, c_radius);
    RETURN (true);
%}
! !

!GLXWorkstation methodsFor:'objects'!

glxCallObject:obj in:aGLXWindowId
    "perform the commands of an object (macro)."

%{  /* NOCONTEXT */
    if (__isSmallInteger(obj)) {
	SETWIN(aGLXWindowId)
	callobj(_objectVal(obj));
	RETURN (true);
    }
%}
.
    ^ false
!

glxCallobj: obj in: aGLXWindowId
    "OBSOLETE; use glxCallObject:in:
     This one will be removed soon."

%{  /* NOCONTEXT */
    if (__isSmallInteger(obj)) {
	SETWIN(aGLXWindowId)
	callobj(_objectVal(obj));
	RETURN (true);
    }
%}
.
    ^ false
!

glxCloseObjectIn:aGLXWindowId
    "end object defnition"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    closeobj();
    RETURN (true);
%}
!

glxCloseobjIn:aGLXWindowId
    "OBSOLETE: use glxCloseObjectIn:
     This one will be removed."

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    closeobj();
    RETURN (true);
%}
! 

glxDeleteObject:obj in:aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    delobj(_objectVal(obj));
    RETURN (true);
%}
!

glxDelobj:obj in:aGLXWindowId
    "OBSOLETE: use glxDeleteObject:in:
     This one will be removed."

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    delobj(_objectVal(obj));
    RETURN (true);
%}
!

glxGenObjectIn:aGLXWindowId
    "return a new (free & unused) object id for use
     with makeObj"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(genobj()));
%}
!

glxGenobjIn:aGLXWindowId
    "OBSOLETE: use glxGenObject:in:
     This one will be removed."

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(genobj()));
%}
!

glxMakeObject:id in:aGLXWindowId
    "start object definition -
     another name conflict"

%{  /* NOCONTEXT */
    if (__isSmallInteger(id)) {
	SETWIN(aGLXWindowId)
	makeobj(_objectVal(id));
	RETURN (true);
    }
%}
.
    ^ false
!

glxMakeobj:obj in:aGLXWindowId
    "OBSOLETE; use glxMakeObject:in:
     This one will be removed soon."

%{  /* NOCONTEXT */
    if (__isSmallInteger(obj)) {
	SETWIN(aGLXWindowId)
	makeobj(_objectVal(obj));
	RETURN (true);
    }
%}
.
    ^ false
!

glxIsobj:obj in:aGLXWindowId
    "return true, if obj is a valid object id"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(isobj(_objectVal(obj))));
%}
!

glxGetopenobjIn:aGLXWindowId
    "return the currently open objects id; -1 if none is open"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getopenobj()));
%}
! !

!GLXWorkstation methodsFor:'unspecified rest'!

glxAcbufOp:op value:value in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    acbuf(__intVal(op), _floatVal(value));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxAcsizePlanes: planes in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    acsize(__intVal(planes));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxAfunctionRef: ref func: func in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    afunction(__intVal(ref), __intVal(func));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBackface: b in: aGLXWindowId
    "enable/disable backface culling"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    backface(_booleanVal(b));
    RETURN (true);
%}
! 

glxBbox2Xmin: xmin ymin: ymin x1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Screencoord c_xmin, c_ymin;
    Coord c_x1, c_y1, c_x2, c_y2; 

    _SCREENCOORD_ (xmin, c_xmin)
    _SCREENCOORD_ (ymin, c_ymin)
    _COORD_ (x1, c_x1)
    _COORD_ (y1, c_y1)
    _COORD_ (x2, c_x2)
    _COORD_ (y2, c_y2)
    SETWIN(aGLXWindowId)
    bbox2(c_xmin, c_ymin, c_x1, c_y1, c_x2, c_y2);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBbox2iXmin: xmin ymin: ymin x1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Screencoord c_xmin, c_ymin;
    Icoord c_x1, c_y1, c_x2, c_y2; 

    _SCREENCOORD_ (xmin, c_xmin)
    _SCREENCOORD_ (ymin, c_ymin)
    _ICOORD_ (x1, c_x1)
    _ICOORD_ (y1, c_y1)
    _ICOORD_ (x2, c_x2)
    _ICOORD_ (y2, c_y2)
    SETWIN(aGLXWindowId)
    bbox2i(c_xmin, c_ymin, c_x1, c_y1, c_x2, c_y2);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBbox2sXmin: xmin ymin: ymin x1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Screencoord c_xmin, c_ymin;
    Scoord c_x1, c_y1, c_x2, c_y2; 

    _SCREENCOORD_ (xmin, c_xmin)
    _SCREENCOORD_ (ymin, c_ymin)
    _SCOORD_ (x1, c_x1)
    _SCOORD_ (y1, c_y1)
    _SCOORD_ (x2, c_x2)
    _SCOORD_ (y2, c_y2)
    SETWIN(aGLXWindowId)
    bbox2s(c_xmin, c_ymin, c_x1, c_y1, c_x2, c_y2);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBeginTrimIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    bgntrim();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxEndTrimIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    endtrim();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBlankscreen: b in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    blankscreen(_booleanVal(b));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBlanktime: count in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    blanktime(__intVal(count));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBlendcolorRed: red green: green blue: blue alpha: alpha in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    blendcolor(_floatVal(red), _floatVal(green), _floatVal(blue), _floatVal(alpha)); 
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBlendfunctionSfactr: sfactr dfactr: dfactr in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    blendfunction(__intVal(sfactr), __intVal(dfactr));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBlinkRate: rate i: i red: red green: green blue: blue in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    blink(_shortVal(rate), _colorindexVal(i), 
	  _shortVal(red), _shortVal(green), _shortVal(blue));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxBlkqreadData: data n: n in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(blkqread((short *)_indexedArea(data), __intVal(n))));
#endif
%}
.
    ^ false
! 

glxC3s: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    short vec[3], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    c3s(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxC3i: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    long vec[3], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    c3i(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxC3f: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    float vec[3], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    c3f(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxC4s: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    short vec[4], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    c4s(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxC4i: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    long vec[4], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    c4i(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxC4f: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    float vec[4], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    c4f(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxClearhitcodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    clearhitcode();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxClipplaneIndex: index mode: mode params: params in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    float vec[4], *v;

    if (! (v = getFloatsFromInto(params, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    clipplane(__intVal(index), __intVal(mode), v);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxCmodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    cmode();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxCmovX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    cmov(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxCmoviX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    cmovi(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxCmovsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    cmovs(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxCmov2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    cmov2(c_x, c_y);
    RETURN (true);
%}
! 

glxCmov2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    cmov2i(c_x, c_y);
    RETURN (true);
%}
! 

glxCmov2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    cmov2s(c_x, c_y);
    RETURN (true);
%}
! 

glxColorfIndex: index in: aGLXWindowId

    ^self glxColor: index in: aGLXWindowId
! 

glxConcave: b in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    concave(_booleanVal(b));
    RETURN (true);
%}
! 

glxCuroriginN: n xorigin: xorigin yorigin: yorigin in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    curorigin(_shortVal(n), _shortVal(xorigin), _shortVal(yorigin));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxCursoffIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    cursoff();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxCursonIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    curson();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxCurstype: type in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    curstype(__intVal(type));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxCurvebasis: basid in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    curvebasis(_shortVal(basid));
    RETURN (true);
%}
! 

glxCurveit: iterationcount in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    curveit(_shortVal(iterationcount));
    RETURN (true);
%}
! 

glxCurveprecision: nsegments in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    curveprecision(_shortVal(nsegments));
    RETURN (true);
%}
! 

glxCyclemapDuration: duration map: map nxtmap: nxtmap in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    cyclemap(_shortVal(duration), _shortVal(map), _shortVal(nxtmap));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxDeflinestyleN: n ls: ls in: aGLXWindowId
    "define a line style"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    deflinestyle(_shortVal(n), _linestyleVal(ls));
    RETURN (true);
%}
! 

glxDefpatternN: n size: size mask: mask in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    defpattern(_shortVal(n), _shortVal(size), (unsigned short *)_indexedArea(mask));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxDeltag: t in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    deltag(_tagVal(t));
    RETURN (true);
#endif
%}
.
    ^ false
!

glxDepthcueMode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    depthcue(_booleanVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxDitherMode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    dither(_longVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxDopup: pup in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    dopup(_longVal(pup));
    RETURN (true);
#endif
%}
.
    ^ false
!

glxDraw:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[3], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    draw((Coord)(c_v[0]), (Coord)(c_v[1]), (Coord)(c_v[2]));
    RETURN (true);
%}
! 

glxDrawX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    draw(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxDrawiX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    drawi(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxDrawsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    draws(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxDraw2:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[2], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    draw2((Coord)(c_v[0]), (Coord)(c_v[1]));
    RETURN (true);
%}
! 

glxDraw2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    draw2(c_x, c_y);
    RETURN (true);
%}
! 

glxDraw2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    draw2i(c_x, c_y);
    RETURN (true);
%}
! 

glxDraw2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    draw2s(c_x, c_y);
    RETURN (true);
%}
! 

glxDrawmode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    drawmode(_longVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxEditobj: obj in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    editobj(_objectVal(obj));
    RETURN (true);
#endif
%}
.
    ^ false
!

glxEndfullscrnIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    endfullscrn();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxFullscrnIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    fullscrn();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxEndpupmodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    endpupmode();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPupmodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pupmode();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxFinishIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    finish();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxFont: fntnum in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    font(_shortVal(fntnum));
    RETURN (true);
%}
! 

glxForegroundIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    foreground();
    RETURN (true);
%}
! 

glxFreepup: pup in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    freepup(_longVal(pup));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxFrontface: b in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    frontface(_booleanVal(b));
    RETURN (true);
%}
.
    ^ false
! 

glxFudgeXfudge: xfudge yfudge: yfudge in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    fudge(_longVal(xfudge), _longVal(yfudge));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxGbeginIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    gbegin();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxGetbackfaceIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getbackface()));
#endif
%}
.
    ^ false
! 

glxGentagIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(gentag()));
#endif
%}
.
    ^ false
! 

glxGetbufferIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getbuffer()));
#endif
%}
.
    ^ false
! 

glxGetbutton: num in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getbutton(_deviceVal(num))));
%}
! 

glxGetcmmodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(getcmmode()));
#endif
%}
.
    ^ false
! 

glxGetcolorIn: aGLXWindowId
    "return the current drawing color"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getcolor()));
%}
! 

glxGetcposIn: aGLXWindowId

    | x y |
%{ 
#ifdef GLX
    short s_x, s_y;
    SETWIN(aGLXWindowId)
    getcpos(&s_x, &s_y);
    x = _MKSMALLINT(s_x);
    y = _MKSMALLINT(s_y);
#endif
%}
.
    ^x @ y
! 

glxGetdcmIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(getdcm()));
#endif
%}
.
    ^ false
! 

glxGetdescenderIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getdescender()));
#endif
%}
.
    ^ false
! 

glxGetdisplaymodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getdisplaymode()));
#endif
%}
.
    ^ false
! 

glxGetdrawmodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getdrawmode()));
#endif
%}
.
    ^ false
! 

glxGetfontIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getfont()));
#endif
%}
.
    ^ false
! 

glxGetgconfigBuffer: buffer in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getgconfig(_longVal(buffer))));
#endif
%}
.
    ^ false
! 

glxGetgdescInquiry: inquiry in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getgdesc(_longVal(inquiry))));
%}
! 

glxGetheightIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getheight()));
%}
! 

glxGethitcodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(gethitcode()));
#endif
%}
.
    ^ false
! 

glxGetlsbackupIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(getlsbackup()));
#endif
%}
.
    ^ false
! 

glxGetlsrepeatIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getlsrepeat()));
#endif
%}
.
    ^ false
! 

glxGetlstyleIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getlstyle()));
#endif
%}
.
    ^ false
! 

glxGetlwidthIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getlwidth()));
#endif
%}
.
    ^ false
! 

glxGetmapIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getmap()));
#endif
%}
.
    ^ false
! 

glxGetmmodeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getmmode()));
#endif
%}
.
    ^ false
! 

glxGetmonitorIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getmonitor()));
#endif
%}
.
    ^ false
! 

glxGetmultisampleIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(getmultisample()));
#endif
%}
.
    ^ false
! 

glxGetothermonitorIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getothermonitor()));
#endif
%}
.
    ^ false
! 

glxGetpatternIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getpattern()));
#endif
%}
.
    ^ false
! 

glxGetplanesIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getplanes()));
#endif
%}
.
    ^ false
! 

glxGetresetlsIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(getresetls()));
#endif
%}
.
    ^ false
! 

glxGetshadeIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getshade()));
#endif
%}
.
    ^ false
! 

glxGetsmIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getsm()));
#endif
%}
.
    ^ false
! 

glxGetvaluator: dev in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getvaluator(_deviceVal(dev))));
%}
.
    ^ false
! 

glxGetvideo: reg in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getvideo(_longVal(reg))));
#endif
%}
.
    ^ false
! 

glxGetwritemaskIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getwritemask()));
#endif
%}
.
    ^ false
! 

glxGetwscrnIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(getwscrn()));
#endif
%}
.
    ^ false
! 

glxGetzbufferIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(getzbuffer()));
#endif
%}
.
    ^ false
! 

glxGexitIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    gexit();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxGflushIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    gflush();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxGinitIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    ginit();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxGlcompatMode: mode value: value in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    glcompat(_longVal(mode), _longVal(value));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxGresetIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    greset();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxGsyncIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    gsync();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxIconsizeX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    iconsize(_longVal(x), _longVal(y));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxImakebackgroundIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    imakebackground();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxInitnamesIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    initnames();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxIsqueued: dev in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(isqueued(_deviceVal(dev))));
#endif
%}
.
    ^ false
! 

glxIstag: t in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKBOOLEAN(istag(_tagVal(t))));
#endif
%}
.
    ^ false
! 

glxKeepaspectX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    keepaspect(_longVal(x), _longVal(y));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLeftbuffer: bool in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    leftbuffer(_booleanVal(bool));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxRightbuffer: bool in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    rightbuffer(_booleanVal(bool));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLinesmoothMode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    linesmooth((ulong)__intVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLinewidth: n in: aGLXWindowId
    "set the linewidth"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    linewidth(_shortVal(n));
    RETURN (true);
%}
! 

glxLinewidthf: n in: aGLXWindowId
    "set the linewidth"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    linewidthf(_floatVal(n));
    RETURN (true);
%}
! 

glxLmcolorMode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    lmcolor(_longVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLoadname: name in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    loadname(_shortVal(name));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLogicop: opcode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    logicop(_longVal(opcode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLrgbrangeRmin: rmin gmin: gmin bmin: bmin rmax: rmax gmax: gmax bmax: bmax
    znear: znear zfar: zfar in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    lRGBrange(_shortVal(rmin), _shortVal(gmin), _shortVal(bmin), 
	_shortVal(rmax), _shortVal(gmax), _shortVal(bmax), 
	_longVal(znear), _longVal(zfar));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLsbackup: b in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    lsbackup(_booleanVal(b));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLsetdepthNear: near far: far in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    lsetdepth(_longVal(near), _longVal(far));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLshaderangeLowin: lowin hiwin: hiwin znear: znear zfar: zfar in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    lshaderange(_colorindexVal(lowin), _colorindexVal(hiwin), 
	_longVal(znear), _longVal(zfar));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxLsrepeatFactor: factor in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    lsrepeat(_longVal(factor));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMaketag: t in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    maketag(_tagVal(t));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMapcolorI: i red: red green: green blue: blue in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    mapcolor(_colorindexVal(i), _shortVal(red), _shortVal(green), _shortVal(blue));
    RETURN (true);
%}
! 

glxMaxsizeX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    maxsize(_longVal(x), _longVal(y));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMinsizeX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    minsize(_longVal(x), _longVal(y));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMonobufferIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    monobuffer();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMove:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[3], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    move((Coord)(c_v[0]), (Coord)(c_v[1]), (Coord)(c_v[2]));
    RETURN (true);
%}
! 

glxMoveX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    move(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxMoveiX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    movei(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxMovesX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    moves(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxMove2:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[2], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    move2((Coord)(c_v[0]), (Coord)(c_v[1]));
    RETURN (true);
%}
! 

glxMove2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    move2(c_x, c_y);
    RETURN (true);
%}
! 

glxMove2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    move2i(c_x, c_y);
    RETURN (true);
%}
! 

glxMove2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    move2s(c_x, c_y);
    RETURN (true);
%}
! 

glxMsalphaMode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    msalpha(_longVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMsmask: mask inverse: inverse in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    msmask(_floatVal(mask), _booleanVal(inverse));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMspattern: pattern in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    mspattern(_longVal(pattern));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMssizeSamples: samples zsize: zsize ssize: ssize in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    mssize(_longVal(samples), _longVal(zsize), _longVal(ssize));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMswapbuffers: fbuf in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    mswapbuffers(_longVal(fbuf));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMultimapIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    multimap();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxMultisample: bool in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    multisample(_booleanVal(bool));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxNewpupIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(newpup()));
#endif
%}
.
    ^ false
! 

glxNewtag: newtg oldtg: oldtg offst: offst in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    newtag(_tagVal(newtg), _tagVal(oldtg), _offsetVal(offst));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxNoborderIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    noborder();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxNoise: v delta: delta in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    noise(_deviceVal(v), _shortVal(delta));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxNoportIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    noport();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxNurbscurveKnotCount: knotCount knotList: knotList
    offset: offset ctlArray: ctlArray 
    order: order type: type in: aGLXWindowId

    | ctlPoints i |
    ctlPoints := DoubleArray new: ctlArray size * (ctlArray first size).
    i := 1.
    ctlArray do: [:point |
	point do: [:coord | 
	    ctlPoints at: i put: coord.
	    i := i + 1]].

%{  /* NOCONTEXT */
#ifdef GLX
    char *knotElements, *ctlElements;
    OBJ cls;
    int ninstVars, nInstBytes;

    SETWIN(aGLXWindowId)
    cls = __qClass(ctlPoints);
    ninstVars = __intVal(_ClassInstPtr(cls)->c_ninstvars);
    nInstBytes = OHDR_SIZE + ninstVars * sizeof(OBJ);

    ctlElements = (char *)(_InstPtr(ctlPoints)) + nInstBytes;
    knotElements = (char *)(_InstPtr(knotList)) + nInstBytes;

    nurbscurve (
	_longVal(knotCount), (double *)knotElements,
	_longVal(offset), (double *)ctlElements, 
	_longVal(order), _longVal(type));
    RETURN(true);
#endif
%}
.
    ^ false
! 

glxObjdeleteTag1: tag1 tag2: tag2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    objdelete(_tagVal(tag1), _tagVal(tag2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxObjinsert: t in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    objinsert(_tagVal(t));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxObjreplace: t in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    objreplace(_tagVal(t));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxOnemapIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    onemap();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPagecolor: pcolor in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pagecolor(_colorindexVal(pcolor));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPassthroughToken: token in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    passthrough(_shortVal(token));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPclosIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pclos();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPdrX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pdr(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPdriX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pdri(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPdrsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pdrs(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPdr2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pdr2(c_x, c_y);
    RETURN (true);
%}
! 

glxPdr2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pdr2i(c_x, c_y);
    RETURN (true);
%}
! 

glxPdr2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pdr2s(c_x, c_y);
    RETURN (true);
%}
! 

glxPicksizeX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    picksize(_shortVal(x), _shortVal(y));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPixmode: mode value: value in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pixmode(_longVal(mode), _longVal(value));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPmvX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pmv(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPmviX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pmvi(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPmvsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pmvs(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPmv2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pmv2(c_x, c_y);
    RETURN (true);
%}
! 

glxPmv2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pmv2i(c_x, c_y);
    RETURN (true);
%}
! 

glxPmv2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pmv2s(c_x, c_y);
    RETURN (true);
%}
! 

glxPntX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pnt(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPntiX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pnti(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPntsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    pnts(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxPnt2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pnt2(c_x, c_y);
    RETURN (true);
%}
! 

glxPnt2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pnt2i(c_x, c_y);
    RETURN (true);
%}
! 

glxPnt2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    pnt2s(c_x, c_y);
    RETURN (true);
%}
! 

glxPntsize: n in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pntsize(_shortVal(n));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPntsizef: n in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pntsizef(_floatVal(n));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPntsmoothMode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pntsmooth((ulong)__intVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPolymode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    polymode(_longVal(mode));
    RETURN (true);
%}
! 

glxPolysmoothMode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    polysmooth(_longVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPopattributesIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    popattributes();
    RETURN (true);
%}
! 

glxPopnameIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    popname();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPopviewportIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    popviewport();
    RETURN (true);
%}
! 

glxPrefpositionX1: x1 x2: x2 y1: y1 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    prefposition(_longVal(x1), _longVal(x2), _longVal(y1), _longVal(y2));
    RETURN (true);
%}
! 

glxPrefsizeX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    prefsize(_longVal(x), _longVal(y));
    RETURN (true);
%}
! 

glxPushattributesIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    pushattributes();
    RETURN (true);
%}
! 

glxPushname: name In: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    pushname(_shortVal(name));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxPushviewportIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    pushviewport();
    RETURN (true);
%}
! 

glxQdevice: dev in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    qdevice(_deviceVal(dev));
    RETURN (true);
%}
! 

glxQenterDev: dev val: val in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    qenter(_deviceVal(dev), _shortVal(val));
    RETURN (true);
%}
! 

glxQgetfdIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(qgetfd()));
#endif
%}
.
    ^ false
! 

glxQreadIn: aGLXWindowId

    | dev data |
%{ 
    short c_data;

    SETWIN(aGLXWindowId)
    dev = _MKSMALLINT(qread(&c_data));
    data = _MKSMALLINT(c_data);
%}
.
    ^ Array with: dev with: data
! 

glxQresetIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    qreset();
    RETURN (true);
%}
! 

glxQtestIn: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    RETURN (_MKSMALLINT(qtest()));
%}
! 

glxRdr:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[3], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    rdr((Coord)(c_v[0]), (Coord)(c_v[1]), (Coord)(c_v[2]));
    RETURN (true);
%}
! 

glxRdrX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rdr(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRdriX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rdri(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRdrsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rdrs(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRdr2:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[2], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    rdr2((Coord)(c_v[0]), (Coord)(c_v[1]));
    RETURN (true);
%}
! 

glxRdr2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rdr2(c_x, c_y);
    RETURN (true);
%}
! 

glxRdr2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rdr2i(c_x, c_y);
    RETURN (true);
%}
! 

glxRdr2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rdr2s(c_x, c_y);
    RETURN (true);
%}
! 

glxReadsource: src in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    readsource(_longVal(src));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxRectX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    rect(_coordVal(x1), _coordVal(y1), _coordVal(x2), _coordVal(y2));
    RETURN (true);
%}
! 

glxRectiX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    recti(_icoordVal(x1), _icoordVal(y1), _icoordVal(x2), _icoordVal(y2));
    RETURN (true);
%}
! 

glxRectsX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    rects(_scoordVal(x1), _scoordVal(y1), _scoordVal(x2), _scoordVal(y2));
    RETURN (true);
%}
! 

glxRectfX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    rectf(_coordVal(x1), _coordVal(y1), _coordVal(x2), _coordVal(y2));
    RETURN (true);
%}
! 

glxRectfiX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    rectfi(_icoordVal(x1), _icoordVal(y1), _icoordVal(x2), _icoordVal(y2));
    RETURN (true);
%}
! 

glxRectfsX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    rectfs(_scoordVal(x1), _scoordVal(y1), _scoordVal(x2), _scoordVal(y2));
    RETURN (true);
%}
! 

glxRectcopyX1: x1 y1: y1 x2: x2 y2: y2 newx: newx newy: newy in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    rectcopy(_screencoordVal(x1), _screencoordVal(y1), 
	_screencoordVal(x2), _screencoordVal(y2), 
	_screencoordVal(newx), _screencoordVal(newy));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxRectzoomX: xfactor y: yfactor in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    rectzoom(_floatVal(xfactor), _floatVal(yfactor));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxResetls: b in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    resetls(_booleanVal(b));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxRGBcursorIndex: index red: red green: green blue: blue 
    redm: redm greenm: greenm bluem: bluem in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RGBcursor(_shortVal(index), 
	_shortVal(red), _shortVal(green), _shortVal(blue), 
	_shortVal(redm), _shortVal(greenm), _shortVal(bluem));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxRGBwritemaskRed: red green: green blue: blue in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    RGBwritemask(_shortVal(red), _shortVal(green), _shortVal(blue));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxRingbellIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    ringbell();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxRmv:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[3], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    rmv((Coord)(c_v[0]), (Coord)(c_v[1]), (Coord)(c_v[2]));
    RETURN (true);
%}
! 

glxRmvX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rmv(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRmviX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rmvi(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRmvsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rmvs(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRmv2:v in: aGLXWindowId

%{  /* NOCONTEXT */
    float vec[2], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    rmv2((Coord)(c_v[0]), (Coord)(c_v[1]));
    RETURN (true);
%}
! 

glxRmv2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rmv2(c_x, c_y);
    RETURN (true);
%}
! 

glxRmv2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rmv2i(c_x, c_y);
    RETURN (true);
%}
! 

glxRmv2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rmv2s(c_x, c_y);
    RETURN (true);
%}
! 

glxRpdrX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rpdr(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRpdriX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rpdri(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRpdrsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rpdrs(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRpdr2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rpdr2(c_x, c_y);
    RETURN (true);
%}
! 

glxRpdr2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rpdr2i(c_x, c_y);
    RETURN (true);
%}
! 

glxRpdr2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rpdr2s(c_x, c_y);
    RETURN (true);
%}
! 

glxRpmvX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rpmv(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRpmviX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rpmvi(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRpmvsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    rpmvs(c_x, c_y, c_z);
    RETURN (true);
%}
! 

glxRpmv2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rpmv2(c_x, c_y);
    RETURN (true);
%}
! 

glxRpmv2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rpmv2i(c_x, c_y);
    RETURN (true);
%}
! 

glxRpmv2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    rpmv2s(c_x, c_y);
    RETURN (true);
%}
! 

glxSboxX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sbox(_coordVal(x1), _coordVal(y1), _coordVal(x2), _coordVal(y2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSboxiX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sboxi(_icoordVal(x1), _icoordVal(y1), _icoordVal(x2), _icoordVal(y2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSboxsX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sboxs(_scoordVal(x1), _scoordVal(y1), _scoordVal(x2), _scoordVal(y2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSboxfX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sboxf(_coordVal(x1), _coordVal(y1), _coordVal(x2), _coordVal(y2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSboxfiX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sboxfi(_icoordVal(x1), _icoordVal(y1), _icoordVal(x2), _icoordVal(y2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSboxfsX1: x1 y1: y1 x2: x2 y2: y2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sboxfs(_scoordVal(x1), _scoordVal(y1), _scoordVal(x2), _scoordVal(y2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSclearSval: sval in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    sclear((ulong)__intVal(sval));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxScrbox: arg in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    scrbox(_longVal(arg));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxScreenspaceIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    screenspace();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxScrmaskLeft: left right: right bottom: bottom top: top in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    scrmask(_screencoordVal(left), _screencoordVal(right), 
	_screencoordVal(bottom), _screencoordVal(top));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxScrnattach: gsnr in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    scrnattach(_longVal(gsnr));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxScrnselect: gsnr in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    scrnselect(_longVal(gsnr));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetcursorIndex: index color: color wtn: wtn in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setcursor(_shortVal(index), _colorindexVal(color), _colorindexVal(wtn));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetdblightsMask: mask in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setdblights((ulong)__intVal(mask));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetdepthNear: near far: far in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setdepth(_screencoordVal(near), _screencoordVal(far));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetlinestyle: index in: aGLXWindowId
    "set the linestyle"

%{  /* NOCONTEXT */
    SETWIN(aGLXWindowId)
    setlinestyle(_shortVal(index));
    RETURN (true);
%}
.
    ^ false
! 

glxSetmap: mapnum in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setmap(_shortVal(mapnum));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetmonitor: mtype in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setmonitor(_shortVal(mtype));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetnurbsproperty: property value: value in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setnurbsproperty(_longVal(property), _floatVal(value));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetpattern: index in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setpattern(_shortVal(index));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetpup: pup entry: entry mode: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setpup(_longVal(pup), _longVal(entry), (ulong)__intVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetvaluator: v init: init vmin: vmin vmax: vmax in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setvaluator(_deviceVal(v), _shortVal(init), _shortVal(vmin), _shortVal(vmax));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSetvideo: reg value: value in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    setvideo(_longVal(reg), _longVal(value));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxShademodel: model in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    shademodel(_longVal(model));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxShaderangeLowin: lowin hiwin: hiwin z1: z1 z2: z2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    shaderange(_colorindexVal(lowin), _colorindexVal(hiwin), 
	_screencoordVal(z1), _screencoordVal(z2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSmoothline: mode in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    smoothline(_longVal(mode));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxStencilEnable: enable ref: ref func: func mask: mask fail: fail 
    pass: pass zpass: zpass in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    stencil(_longVal(enable), (ulong)__intVal(ref), _longVal(func), 
	(ulong)__intVal(mask), _longVal(fail), _longVal(pass), _longVal(zpass));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxStensize: planes in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    stensize(_longVal(planes));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxStepunitX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    stepunit(_longVal(x), _longVal(y));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSubpixel: b in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    subpixel(_booleanVal(b));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSwapinterval: i in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    swapinterval(_shortVal(i));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSwaptmeshIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    swaptmesh();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSwinopen: parent in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    swinopen(_longVal(parent));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxSwritemask: mask in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    swritemask((ulong)__intVal(mask));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxT2s: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    short vec[2], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    t2s(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT2i: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    long vec[2], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    t2i(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT2f: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    float vec[2], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    t2f(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT2d: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    double vec[2], *c_v;

    if (! (c_v = getDoublesFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    t2d(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT3s:v in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    short vec[3], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    t3s(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT3i:v in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    long vec[3], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    t3i(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT3f:v in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    float vec[3], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    t3f(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT3d:v in:aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    double vec[3], *c_v;

    if (! (c_v = getDoublesFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    t3d(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT4s: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    short vec[4], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    t4s(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT4i: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    long vec[4], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    t4i(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT4f: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    float vec[4], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    t4f(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxT4d: v in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    double vec[4], *c_v;

    if (! (c_v = getDoublesFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    t4d(c_v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxTextinitIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    textinit();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxTextportLeft: left right: right bottom: bottom top: top in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    textport(_screencoordVal(left), _screencoordVal(right), 
	_screencoordVal(bottom), _screencoordVal(top));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxTieB: b v1: v1 v2: v2 in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    tie(_deviceVal(b), _deviceVal(v1), _deviceVal(v2));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxTlutbind: target index: index in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef FULL_GLX
    SETWIN(aGLXWindowId)
    tlutbind(_longVal(target), _longVal(index));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxTpoffIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    tpoff();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxTponIn: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    tpon();
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxUnqdevice: dev in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    unqdevice(_deviceVal(dev));
    RETURN (true);
#endif
%}
.
    ^ false
!

glxWmpack: pack in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    wmpack((ulong)__intVal(pack));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxWritemask: wtm in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    SETWIN(aGLXWindowId)
    writemask(_colorindexVal(wtm));
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfptX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Coord c_x, c_y, c_z;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    xfpt(c_x, c_y, c_z);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfptiX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Icoord c_x, c_y, c_z;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    xfpti(c_x, c_y, c_z);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfptsX: x y: y z: z in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Scoord c_x, c_y, c_z;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    SETWIN(aGLXWindowId)
    xfpts(c_x, c_y, c_z);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfpt2X: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Coord c_x, c_y;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    xfpt2(c_x, c_y);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfpt2iX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Icoord c_x, c_y;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    xfpt2i(c_x, c_y);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfpt2sX: x y: y in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Scoord c_x, c_y;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    SETWIN(aGLXWindowId)
    xfpt2s(c_x, c_y);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfpt4X: x y: y z: z w: w in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Coord c_x, c_y, c_z, c_w;

    _COORD_ (x, c_x)
    _COORD_ (y, c_y)
    _COORD_ (z, c_z)
    _COORD_ (w, c_w)
    SETWIN(aGLXWindowId)
    xfpt4(c_x, c_y, c_z, c_w);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfpt4iX: x y: y z: z w: w in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Icoord c_x, c_y, c_z, c_w;

    _ICOORD_ (x, c_x)
    _ICOORD_ (y, c_y)
    _ICOORD_ (z, c_z)
    _ICOORD_ (w, c_w)
    SETWIN(aGLXWindowId)
    xfpt4i(c_x, c_y, c_z, c_w);
    RETURN (true);
#endif
%}
.
    ^ false
! 

glxXfpt4sX: x y: y z: z w: w in: aGLXWindowId

%{  /* NOCONTEXT */
#ifdef GLX
    Scoord c_x, c_y, c_z, c_w;

    _SCOORD_ (x, c_x)
    _SCOORD_ (y, c_y)
    _SCOORD_ (z, c_z)
    _SCOORD_ (w, c_w)
    SETWIN(aGLXWindowId)
    xfpt4s(c_x, c_y, c_z, c_w);
    RETURN (true);
#endif
%}
.
    ^ false
! !

!GLXWorkstation methodsFor:'vertex data transfer'!

glxV2s:v in:aGLXWindowId
    "pass a vertex; v must be a vector with 2 shorts; z is taken as 0"

%{  /* NOCONTEXT */
    short vec[2], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    v2s(c_v);
    RETURN (true);
%}
!

glxV2i:v in:aGLXWindowId
    "pass a vertex; v must be a vector with 2 longs; z is taken as 0"

%{  /* NOCONTEXT */
    long vec[2], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    v2i(c_v);
    RETURN (true);
%}
!

glxV2f:v in:aGLXWindowId
    "pass a vertex; v must be a vector with 2 floats; z is taken as 0"

%{  /* NOCONTEXT */
    float vec[2], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    v2f(c_v);
    RETURN (true);
%}
!

glxV2d:v in:aGLXWindowId
    "pass a vertex; v must be a vector with 2 doubles; z is taken as 0"

%{  /* NOCONTEXT */
    double vec[2], *c_v;

    if (! (c_v = getDoublesFromInto(v, vec, 2))) RETURN(false);
    SETWIN(aGLXWindowId)
    v2d(c_v);
    RETURN (true);
%}
!

glxV2fX:x y:y in:aGLXWindowId
    "pass a vertex from individual x and y values; z is taken as 0.0"

%{  /* NOCONTEXT */
    float vec[2];

    _FLOAT_(x, vec[0])
    _FLOAT_(y, vec[1])
    SETWIN(aGLXWindowId)
    v2f(vec);
    RETURN (true);
%}
!

glxV3s:v in:aGLXWindowId
    "pass a vertex; v must be a vector with 3 shorts"

%{  /* NOCONTEXT */
    short vec[3], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    v3s(c_v);
    RETURN (true);
%}
!

glxV3i:v in:aGLXWindowId
    "pass a vertex; v must be a vector with 3 longs"

%{  /* NOCONTEXT */
    long vec[3], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    v3i(c_v);
    RETURN (true);
%}
!

glxV3f:v in:aGLXWindowId
    "pass a vertex; v must be a 3-element float-vector"

%{  /* NOCONTEXT */
    float vec[3], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    v3f(c_v);
    RETURN (true);
%}
!

glxV3fX:x y:y z:z in: aGLXWindowId
    "pass a vector from individual x, y and z (float) values"

%{  /* NOCONTEXT */
    float vec[3];

    _FLOAT_(x, vec[0])
    _FLOAT_(y, vec[1])
    _FLOAT_(z, vec[2])
    SETWIN(aGLXWindowId)
    v3f(vec);
    RETURN (true);
%}
!

glxVOriginIn:aGLXWindowId
    "pass a 0.0/0.0/0.0 vector.
     This is the same as v3f:#(0.0 0.0 0.0), but, since its so
     common, this somewhat faster method has been provided"

%{  /* NOCONTEXT */
    static float vec[3] = {0.0, 0.0, 0.0};

    SETWIN(aGLXWindowId)
    v3f(vec);
    RETURN (true);
%}
!

glxVUnitXIn:aGLXWindowId
    "pass a 1.0/0.0/0.0 vector.
     This is the same as v3f:#(1.0 0.0 0.0), but, since its so
     common, this somewhat faster method has been provided"

%{  /* NOCONTEXT */
    static float vec[3] = {1.0, 0.0, 0.0};

    SETWIN(aGLXWindowId)
    v3f(vec);
    RETURN (true);
%}
!

glxVUnitYIn:aGLXWindowId
    "pass a 0.0/1.0/0.0 vector.
     This is the same as v3f:#(0.0 1.0 0.0), but, since its so
     common, this somewhat faster method has been provided"

%{  /* NOCONTEXT */
    static float vec[3] = {0.0, 1.0, 0.0};

    SETWIN(aGLXWindowId)
    v3f(vec);
    RETURN (true);
%}
!

glxVUnitZIn:aGLXWindowId
    "pass a 0.0/0.0/1.0 vector.
     This is the same as v3f:#(0.0 0.0 1.0), but, since its so
     common, this somewhat faster method has been provided"

%{  /* NOCONTEXT */
    static float vec[3] = {0.0, 0.0, 1.0};

    SETWIN(aGLXWindowId)
    v3f(vec);
    RETURN (true);
%}
!

glxV3d:v in:aGLXWindowId
    "pass a vertex; v must be a 3-element double-vector"

%{  /* NOCONTEXT */
    double vec[3], *c_v;

    if (! (c_v = getDoublesFromInto(v, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    v3d(c_v);
    RETURN (true);
%}
.
    ^ false
!

glxN3f:arrayOf3Floats in:aGLXWindowId
    "argument must be an array of 3 floats containing the
     current vertex normal - in real GL only"

%{  /* NOCONTEXT */
#ifdef GLX
    float vec[3], *v;

    if (! (v = getFloatsFromInto(arrayOf3Floats, vec, 3))) RETURN(false);
    SETWIN(aGLXWindowId)
    n3f(v);
    RETURN (true);
#endif
%}
.
    ^ false
!

glxV4s:v in:aGLXWindowId
    "pass a vertex; v must be a 4-element short-vector,
     containing x, y, z and w"

%{  /* NOCONTEXT */
    short vec[4], *c_v;

    if (! (c_v = getShortsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    v4s(c_v);
    RETURN (true);
%}
!

glxV4i:v in:aGLXWindowId
    "pass a vertex; v must be a 4-element int-vector,
     containing x, y, z and w"

%{  /* NOCONTEXT */
    long vec[4], *c_v;

    if (! (c_v = getLongsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    v4i(c_v);
    RETURN (true);
%}
!

glxV4f:v in:aGLXWindowId
    "pass a vertex; v must be a 4-element float-vector,
     containing x, y, z and w"

%{  /* NOCONTEXT */
    float vec[4], *c_v;

    if (! (c_v = getFloatsFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    v4f(c_v);
    RETURN (true);
%}
!

glxV4d:v in:aGLXWindowId
    "pass a vertex; v must be a 4-element double-vector,
     containing x, y, z and w"

%{  /* NOCONTEXT */
    double vec[4], *c_v;

    if (! (c_v = getDoublesFromInto(v, vec, 4))) RETURN(false);
    SETWIN(aGLXWindowId)
    v4d(c_v);
    RETURN (true);
%}
! !

!GLXWorkstation methodsFor:'stereo extension'!

stereoExtensionVersion
    "return the stereo extensions version as an array consisting of
     major and minor numbers."

%{  /* NOCONTEXT */
#if defined(XSGIStereo) && defined(GLX)
    Status status;
    Display *dpy = myDpy;
    int major, minor;
    extern OBJ __ARRAY_WITH2();

    if (ISCONNECTED) {
	status = XSGIStereoQueryVersion(myDpy, &major, &minor);
	if (status == True) {
	    RETURN ( __ARRAY_WITH2(__MKSMALLINT(major), __MKSMALLINT(minor)));
	}
    }
#endif
%}.
    self primitiveFailed

    "
     Display stereoExtensionVersion
    "
!

stereoExtensionModeIn:aWindowId
    "return the current stereo mode for some window"

%{  /* NOCONTEXT */
#if defined(XSGIStereo) && defined(GLX)
    int mode;
    Window win;

    if (ISCONNECTED && __isExternalAddress(aWindowId)) {
	win = _WindowVal(aWindowId);
	mode = XSGIQueryStereoMode(myDpy, win);
	switch (mode) {
	    case STEREO_OFF:
		RETURN ( @symbol(off) );
	    case STEREO_BOTTOM:
		RETURN ( @symbol(bottom) );
	    case STEREO_TOP:
		RETURN ( @symbol(top) );
	}
	RETURN ( @symbol(unsupported) );
    }
#endif
%}.
    self primitiveFailed

    "
     |v|

     v := StandardSystemView new.
     v extent:300@300.
     v openAndWait.
     v device stereoExtensionModeIn:(v id)

     Display stereoExtensionModeIn:Display rootWindowId 
    "
!

stereoExtensionMode:aModeSymbol height:h offset:o for:aWindowId
    "set the current stereo mode; the argument may be one of:
	nil/false #off -> turn it off
	#bottom        -> STEREO_BOTTOM
	#top           -> STEREO_TOP
    "

%{  /* NOCONTEXT */
#if defined(XSGIStereo) && defined(GLX)
    Status status;
    int mode;
    unsigned short us_h, us_o;
    Window win;

    if (ISCONNECTED 
     && __bothSmallInteger(h, o)
     && __isExternalAddress(aWindowId)) {
	win = _WindowVal(aWindowId);
	if ((aModeSymbol == nil)
	 || (aModeSymbol == false)
	 || (aModeSymbol == @symbol(off))) {
	    mode = STEREO_OFF;
	} else {
	    if (aModeSymbol == @symbol(bottom)) {
		mode = STEREO_BOTTOM;
	    } else {
		if (aModeSymbol == @symbol(top)) {
		    mode = STEREO_TOP;
		} else {
		    goto bad;
		}
	    }
	}
	us_h = __intVal(h);
	us_o = __intVal(o);
	status = XSGISetStereoMode(myDpy, win, us_h, us_o, mode);
	RETURN ( status ? true : false);
    }
  bad: ;
#endif
%}.
    self primitiveFailed

    "
     Display stereoExtensionMode:#top height:492 offset:532 for:(Display rootWindowId).  
     (Delay forSeconds:10) wait.
     Display stereoExtensionMode:#off height:0 offset:0 for:(Display rootWindowId).  
    "
!

stereoExtensionBuffer:aBufferSymbol for:aWindowId
    "set the current stereo buffer; the argument may be one of:
	#left        -> STEREO_BUFFER_LEFT
	#right       -> STEREO_BUFFER_RIGHT
    "

%{  /* NOCONTEXT */
#if defined(XSGIStereo) && defined(GLX)
    Status status;
    int buffer;
    Window win;

    if (ISCONNECTED 
     && __isExternalAddress(aWindowId)) {
	win = _WindowVal(aWindowId);
	if (aBufferSymbol == @symbol(left)) {
	    buffer = STEREO_BUFFER_LEFT;
	} else {
	    if (aBufferSymbol == @symbol(right)) {
		buffer = STEREO_BUFFER_RIGHT;
	    } else {
		goto bad;
	    }
	}
	status = XSGISetStereoBuffer(myDpy, win, buffer);
	RETURN ( status ? true : false);
    }
  bad: ;
#endif
%}.
    self primitiveFailed

    "
     |t v|

     t := StandardSystemView new.
     t extent:300@300.
     v := GLXView origin:0.0@0.0 corner:1.0@1.0 in:t.
     t openAndWait.

     v device stereoExtensionBuffer:#left for:(v id).  
     (Delay forSeconds:10) wait.
     v device stereoExtensionBuffer:#right for:(v id).  
    "
! !