GLXWorkstation.st
author claus
Sun, 19 Dec 1993 01:46:41 +0100
changeset 19 74683e998f36
parent 12 9f0995fac1fa
child 20 ab35d92b9a4b
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'
       classVariableNames:   ''
       poolDictionaries:''
       category:'Interface-Graphics'
!

GLXWorkstation comment:'

COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved

this class just to give a hint of what could be ...

$Header: /cvs/stx/stx/libview/GLXWorkstation.st,v 1.4 1993-12-19 00:46:02 claus Exp $
written june 93 by claus
'!

%{
#ifdef GLX

/*
 * this is stupid, GLX defines String, which is also defined here ...
 */
# define String GLX_String
# include <gl/glws.h>
# include <gl/sphere.h>

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

extern Window GLXCreateWindow(Display*,Window,int,int,int,int,int,GLXWindowType);
#undef String

#endif

/*
 * some defines - tired of typing ...
 */
#define MKDPY(o)       (Display *)(_intVal(o))
#define MKWIN(o)       (Window)(_intVal(o))
#define MKGC(o)        (GC)(_intVal(o))
#define MKCURS(o)      (Cursor)(_intVal(o))
#define MKFONT(o)      (XFontStruct *)(_intVal(o))
#define MKDPSContext(o)      (DPSContext)(_intVal(o))

#define myDpy MKDPY(_INST(displayId))

#define SETWIN(aGLXWindowId)                             \
    if (_INST(activeWindow) != aGLXWindowId) {           \
        if (GLXwinset(myDpy, MKWIN(aGLXWindowId)) < 0) { \
            RETURN (false);                              \
        }                                                \
        _INST(activeWindow) = aGLXWindowId;              \
    }

#define _COORD_(arg, dst)               \
    if (_isFloat(arg))                  \
        dst = (Coord)(_floatVal(arg));  \
    else if (_isSmallInteger(arg))      \
        dst = (Coord)(_intVal(arg));    \
    else break;

#define _FLOAT_(arg, dst)               \
    if (_isFloat(arg))                  \
        dst = (float)(_floatVal(arg));  \
    else if (_isSmallInteger(arg))      \
        dst = (float)(_intVal(arg));    \
    else break;

#define _ANGLE_(arg, dst)               \
    if (_isSmallInteger(arg))           \
        dst = (Angle)(_intVal(arg));    \
    else break;

#define _INT_(arg, dst)                 \
    if (_isSmallInteger(arg))           \
        dst = (int)(_intVal(arg));      \
    else break;

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:
        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:
        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 return 0;
            pElem += sizeof(OBJ);
        }
        return vec;
    }
    return (float *)0;
}

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;

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

    cls = _qClass(obj);
    nByte = _qSize(obj) - OHDR_SIZE;

    if (cls == FloatArray) {
        int x = 0;
        int i,j;

        if (nByte < (16 * sizeof(float))) return (Matrix *)0;
        return (Matrix *) _FloatArrayInstPtr(obj)->f_element;
    }
    
    if (cls == DoubleArray) {
        int x = 0;
        int i,j;

        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;
    }
    
    if (cls == Array) {
        int x = 0;
        int i,j;

        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)) return (Matrix *)0;
                (*mp)[i][j] = _floatVal(o);
                x++;
            }
        }
        return mp;
    }
    return (Matrix *)0;
}

%}

!GLXWorkstation methodsFor:'window creation'!

createGLXWindowFor:aView left:xpos top:ypos width:wwidth height:wheight type:glxType
    |ext minWidth minHeight maxWidth maxHeight 
     bWidth bColor viewBg viewBgId wsuperView wsuperViewId wcreateOnTop 
     winputOnly wlabel wcursor wcursorId wicon wiconId windowId
     weventMask wiconView wiconViewId bitGravity viewGravity vBgColor
     vBgForm deepForm|

    "{ Symbol: colorIndexSingleBuffer }"
    "{ Symbol: colorIndexDoubleBuffer }"
    "{ Symbol: rgbSingleBuffer }"
    "{ Symbol: rgbDoubleBuffer }"

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

%{
#ifdef GLX
    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 (_isSmallInteger(wsuperViewId)) {
            parentWindow = MKWIN(wsuperViewId);
        } else {
            parentWindow = RootWindow(dpy, screen);
        }

        if (glxType == _colorIndexSingleBuffer)
            t = GLXcolorIndexSingleBuffer;
        else if (glxType == _colorIndexDoubleBuffer)
            t = GLXcolorIndexDoubleBuffer;
        else if (glxType == _rgbSingleBuffer)
            t = GLXrgbSingleBuffer;
        else if (glxType == _rgbDoubleBuffer)
            t = GLXrgbDoubleBuffer;
        else {
            RETURN ( nil );
        }

        newWindow = GLXCreateWindow(dpy, parentWindow,
                                    _intVal(xpos), _intVal(ypos),
                                    _intVal(wwidth), _intVal(wheight),
                                    0, t);

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

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

!GLXWorkstation methodsFor:'queries'!

supportsRGB
    ^ true
! !

!GLXWorkstation methodsFor:'glx access'!

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

%{  /* NOCONTEXT */

#ifdef GLX
    Angle a_fovy;
    Coord c_near, c_far;
    float f_aspect;

    do {
        _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);
    } while(0);
#endif
%}
.
    ^ false
!

glxTranslateX:x y:y z:z in:aGLXWindowId
    "translate current matrix"

%{  /* NOCONTEXT */

#ifdef GLX
    Coord c_x, c_y, c_z;

    do {
        _COORD_ (x, c_x);
        _COORD_ (y, c_y);
        _COORD_ (z, c_z);
        SETWIN(aGLXWindowId)
        translate(c_x, c_y, c_z);
        RETURN (true);
    } while(0);
#endif
%}
.
    ^ false
!

glxScaleX:x y:y z:z in:aGLXWindowId
    "scale & mirror current matrix"

%{  /* NOCONTEXT */

#ifdef GLX
    float f_x, f_y, f_z;

    do {
        _FLOAT_ (x, f_x);
        _FLOAT_ (y, f_y);
        _FLOAT_ (z, f_z);
        SETWIN(aGLXWindowId)
        scale(f_x, f_y, f_z);
        RETURN (true);
    } while(0);
#endif
%}
.
    ^ false
!

glxRotate:angle axis:axis in:aGLXWindowId
    "rotate the current matrix"

    "{ Symbol: x }"
    "{ Symbol: y }"
    "{ Symbol: z }"

%{  /* NOCONTEXT */

#ifdef GLX
    Angle a_angle;
    float f_angle;
    char c_axis;

    do {
        if (axis == _x)
            c_axis = 'x';
        else if (axis == _y)
            c_axis = 'y';
        else if (axis == _z)
            c_axis = 'z';
        else break;

        SETWIN(aGLXWindowId)
        if (_isFloat(angle)) {
            f_angle = (float)(_floatVal(angle));
            rot(f_angle, c_axis);
            RETURN (true);
        } else {
            if (_isSmallInteger(angle)) {
                a_angle = (Angle)(_intVal(angle));
                rotate(a_angle, c_axis);
                RETURN (true);
            }
        }
    } while(0);
#endif
%}
.
    ^ false
!

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

%{  /* NOCONTEXT */

#ifdef GLX
    Coord f_vx, f_vy, f_vz, f_px, f_py, f_pz;
    Angle a_twist;

    do {
        _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);
    } while(0);
#endif
%}
.
    ^ false
!

glxLmdef:what index:index np:np props:props in:aGLXWindowId
    "define a material, light source or lighting model;
     props must be a FloatArray"

    "{ Symbol: material }"
    "{ Symbol: light }"
    "{ Symbol: lightModel }"

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

    do {
        if (what == _material)
            defType = DEFMATERIAL;
        else if (what == _light)
            defType = DEFLIGHT;
        else if (what == _lightModel)
            defType = DEFLMODEL;
        else break;

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

        if (props == nil) fp = NULL;
        else if (_Class(props) == FloatArray)
            fp = _FloatArrayInstPtr(props)->f_element;
        else break;

        SETWIN(aGLXWindowId)
        lmdef(defType, i_index, i_np, fp);
        RETURN (true);
    } while(0);
#endif
%}
.
    ^ false
!

glxLmbind:target index:index in:aGLXWindowId
    "select a material, lighyt or lighting model"

    "{ Symbol: material }"
    "{ Symbol: backMaterial }"
    "{ Symbol: light0 }"
    "{ Symbol: light1 }"
    "{ Symbol: light2 }"
    "{ Symbol: light3 }"
    "{ Symbol: light4 }"
    "{ Symbol: light5 }"
    "{ Symbol: light6 }"
    "{ Symbol: light7 }"
    "{ Symbol: lightModel }"

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

    do {
        if (target == _material)
            defType = MATERIAL;
        else if (target == _backMaterial)
            defType = BACKMATERIAL;
        else if (target == _light0)
            defType = LIGHT0;
        else if (target == _light1)
            defType = LIGHT1;
        else if (target == _light2)
            defType = LIGHT2;
        else if (target == _light3)
            defType = LIGHT3;
        else if (target == _light4)
            defType = LIGHT4;
        else if (target == _light5)
            defType = LIGHT5;
        else if (target == _light6)
            defType = LIGHT6;
        else if (target == _light7)
            defType = LIGHT7;
        else if (target == _lightModel)
            defType = LMODEL;
        else break;

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

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 */

#ifdef GLX
    SETWIN(aGLXWindowId)
    if (_isSmallInteger(index)) {
        color((Colorindex)(_intVal(index)));
        RETURN (true);
    }
    if (_isFloat(index)) {
        colorf((float)(_floatVal(index)));
        RETURN (true);
    }
#endif
%}
.
    ^ false
!

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

%{  /* NOCONTEXT */

#ifdef GLX
    short s_r, s_g, s_b;

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

glxClearIn:aGLXWindowId
    "clear to current color"

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

glxZClearIn:aGLXWindowId
    "clear z buffer"

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

glxPushmatrixIn:aGLXWindowId
    "push down transformation stack"

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

glxPopmatrixIn:aGLXWindowId
    "pop transformation stack"

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

glxSwapBuffersIn:aGLXWindowId
    "swap double buffers"

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

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

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

glxDoubleBufferIn:aGLXWindowId
    "set double buffer mode"

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

glxGconfigIn:aGLXWindowId
    "must be sent after RGBmode, doubleBuffer etc. to have these
     changes really take effect. See GLX manual"

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

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

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

glxBackface:aBoolean in:aGLXWindowId
    "enable/disable backface"

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

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

    "{ Symbol: auto }"
    "{ Symbol: normalize }"

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

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

    "{ Symbol: single }"
    "{ Symbol: viewing }"
    "{ Symbol: projection }"
    "{ Symbol: texture }"

%{  /* NOCONTEXT */
#ifdef GLX
    if (aSymbol == _single) {
        mmode(MSINGLE);
        RETURN (true);
    }
    if (aSymbol == _viewing) {
        mmode(MVIEWING);
        RETURN (true);
    }
    if (aSymbol == _projection) {
        mmode(MPROJECTION);
        RETURN (true);
    }
    if (aSymbol == _texture) {
        mmode(MTEXTURE);
        RETURN (true);
    }
#endif
%}
.
    ^ false
!

glxBeginPolygonIn:aGLXWindowId
    "start a polygon"

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

glxEndPolygonIn:aGLXWindowId
    "end a polygon"

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

glxBeginPointIn:aGLXWindowId
    "start a point-group"

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

glxEndPointIn:aGLXWindowId
    "end a point group"

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

glxBeginCloseLineIn:aGLXWindowId
    "start a closed line"

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

glxEndClosedLineIn:aGLXWindowId
    "end a closed line"

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

glxBeginLineIn:aGLXWindowId
    "start a line group"

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

glxEndLineIn:aGLXWindowId
    "end a line group"

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

glxBeginTriangleMeshIn:aGLXWindowId
    "start a triangle mesh"

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

glxEndTriangleMeshIn:aGLXWindowId
    "end a triangle mesh"

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

glxBeginSurfaceIn:aGLXWindowId
    "start a NURBS surface def"

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

glxEndSurfaceIn:aGLXWindowId
    "end a NURBS surface def"

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

glxBeginQuadrilateralStripIn:aGLXWindowId
    "start a quadrilateral strip"

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

glxEndQuadrilateralStripIn:aGLXWindowId
    "end a quadrilateral strip"

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

glxBeginCurveIn:aGLXWindowId
    "start a NURBS curve def"

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

glxEndCurveIn:aGLXWindowId
    "end a NURBS curve def"

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

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

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

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

glxDefBasis:id mat:aMatrix in:aGLXWindowId
    "define the basis"
%{  /* NOCONTEXT */
#ifdef GLX
    Matrix matrix;
    Matrix *m;

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

glxPatchCurvesU:u v:v in:aGLXWindowId
    "set the number of curves in a patch"
%{  /* NOCONTEXT */
#ifdef GLX
    if (_isSmallInteger(u) && _isSmallInteger(v)) {
        SETWIN(aGLXWindowId)
        patchcurves((long)_intVal(u), (long)_intVal(v));
        RETURN (true);
    }
#endif
%}
.
    ^ false
!

glxPatchPrecisionU:u v:v in:aGLXWindowId
    "set the patch precision"
%{  /* NOCONTEXT */
#ifdef GLX
    if (_isSmallInteger(u) && _isSmallInteger(v)) {
        SETWIN(aGLXWindowId)
        patchprecision((long)_intVal(u), (long)_intVal(v));
        RETURN (true);
    }
#endif
%}
.
    ^ false
!

glxPatchBasisU:u v:v in:aGLXWindowId
    "set the current basis matrices"
%{  /* NOCONTEXT */
#ifdef GLX
    if (_isSmallInteger(u) && _isSmallInteger(v)) {
        SETWIN(aGLXWindowId)
        patchbasis((long)_intVal(u), (long)_intVal(v));
        RETURN (true);
    }
#endif
%}
.
    ^ false
!

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

%{  /* NOCONTEXT */
#ifdef GLX
    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);
#endif
%}
.
    ^ false
!

glxGetMatrix:arrayOf16Floats in:aGLXWindowId
    "argument must be an array(a matrix) of 16 floats containing the
     matrix"

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

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

glxLoadMatrix:arrayOf16Floats in:aGLXWindowId
    "argument must be an array(a matrix) of 16 floats containing the
     transformation matrix"

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

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

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

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

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

glxN3f:arrayOf3Floats in:aGLXWindowId
    "argument must be an array of 3 floats containing the
     current vertex normal"

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

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

glxC3f:arrayOf3Floats in:aGLXWindowId
    "argument must be an array of 3 floats containing the color"

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

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

glxV3f:arrayOf3Floats in:aGLXWindowId
    "argument must be an array of 3 floats containing the vertex"

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

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