GLXWorkstation.st
changeset 157 891eff44c2e7
parent 151 8123ec03c52f
child 158 34bade266dec
--- a/GLXWorkstation.st	Mon Jul 03 02:35:52 1995 +0200
+++ b/GLXWorkstation.st	Sun Jul 23 04:29:59 1995 +0200
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/GLXWorkstation.st,v 1.21 1995-06-06 04:07:06 claus Exp $
+$Header: /cvs/stx/stx/libview/GLXWorkstation.st,v 1.22 1995-07-23 02:26:55 claus Exp $
 '!
 
 !GLXWorkstation class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview/GLXWorkstation.st,v 1.21 1995-06-06 04:07:06 claus Exp $
+$Header: /cvs/stx/stx/libview/GLXWorkstation.st,v 1.22 1995-07-23 02:26:55 claus Exp $
 "
 !
 
@@ -93,6 +93,8 @@
     *** 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)
 "
 ! !
 
@@ -126,6 +128,7 @@
 #else
 # undef memset
 # include <vogl.h>
+# undef move
 # include <X11/Xlib.h>
 #endif
 
@@ -171,6 +174,9 @@
 
 #define myDpy MKDPY(_INST(displayId))
 
+/*
+ * set the GLXWindow for followup drawing
+ */
 #define SETWIN(aGLXWindowId)                             \
     if (_INST(activeWindow) != aGLXWindowId) {           \
 	if (! __isSmallInteger(aGLXWindowId)) {          \
@@ -182,12 +188,29 @@
 	_INST(activeWindow) = aGLXWindowId;              \
     }
 
+#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
+ * ST-object must be true or false. Return wth false if invalid.
  */
-#define _MKBOOLEAN(b)   ((b==FALSE) ? false : true)
-#define _booleanVal(b)  ((b==false) ? (Boolean)FALSE : (Boolean)TRUE)
 #define _BOOLEAN_(arg, dst)             \
     if (arg==true)                      \
 	dst = (Boolean)TRUE;            \
@@ -197,12 +220,9 @@
 
 /*
  * check for and fetch a coord from ST-arg into C-dst
- * ST-object must be Float, SmallInteger or Fraction
+ * ST-object must be Float, SmallInteger or Fraction.
+ * Return wth false if invalid.
  */
-#define _coordVal(c)                            \
-    ((__isFloat(c)) ? (Coord)(_floatVal(c))      \
-		   : (Coord)(_intVal(c)))
-
 #define _COORD_(arg, dst)               \
     if (__isFloat(arg))                 \
 	dst = (Coord)(_floatVal(arg));  \
@@ -220,46 +240,32 @@
 
 /*
  * check for and fetch an icoord from ST-arg into C-dst
- * ST-object must be SmallInteger 
+ * ST-object must be SmallInteger. Return wth false if invalid. 
  */
-#define _icoordVal(c) ((Icoord)(_intVal(c)))
 #define _ICOORD_(arg, dst)              \
     if (__isSmallInteger(arg))          \
       dst = (Icoord)(_intVal(arg));     \
     else { RETURN(false); }
 
 /*
- * check for and fetch an icoord from ST-arg into C-dst
- * ST-object must be SmallInteger 
+ * check for and fetch an scoord from ST-arg into C-dst
+ * ST-object must be SmallInteger. Return wth false if invalid. 
  */
-#define _scoordVal(c) ((Scoord)(_intVal(c)))
 #define _SCOORD_(arg, dst)              \
     if (__isSmallInteger(arg))          \
       dst = (Scoord)(_intVal(arg));     \
     else { RETURN(false); }
 
-#define _screencoordVal(c) ((Screencoord)(_intVal(c)))
 #define _SCREENCOORD_(arg, dst)          \
     if (__isSmallInteger(arg))           \
       dst = (Screencoord)(_intVal(arg)); \
     else { RETURN(false); }
 
-#define _colorindexVal(c) ((Colorindex)(_intVal(c)))
 #define _COLORINDEX_(arg, dst)           \
     if (__isSmallInteger(arg))           \
       dst = (Colorindex)(_intVal(arg));  \
     else { RETURN(false); }
 
-#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)))
 #define _ANGLE_(arg, dst)               \
     if (__isSmallInteger(arg))          \
 	dst = (Angle)(_intVal(arg));    \
@@ -962,10 +968,22 @@
 
 !GLXWorkstation methodsFor:'queries'!
 
+supportsGLDrawing
+    "return true, if this device supports 3D GL drawing."
+
+    ^ true
+
+    "
+     Display supportsGLDrawing 
+    "
+!
+
 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 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
@@ -980,8 +998,10 @@
 !
 
 supportsLight
-    "return true, if this gl workstation supports light 
-     (i.e. if its a real GL)"
+    "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
@@ -997,7 +1017,9 @@
 
 supportsTextures
     "return true, if this gl workstation supports texture mapping
-     (i.e. if its a real GL)"
+     (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
@@ -1014,7 +1036,10 @@
 !
 
 supportsDoubleBuffer
-    "return true, if this gl workstation supports double buffering"
+    "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
@@ -1031,7 +1056,10 @@
 !
 
 supportsZBuffer
-    "return true, if this gl workstation has z buffer support"
+    "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
@@ -1068,11 +1096,7 @@
 !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|
+    |ext wsuperView wsuperViewId windowId|
 
     wsuperView := aView superView.
     wsuperView notNil ifTrue:[
@@ -3242,6 +3266,7 @@
 ! 
 
 glxBackface: b in: aGLXWindowId
+    "enable/disable backface culling"
 
 %{  /* NOCONTEXT */
     SETWIN(aGLXWindowId)
@@ -3820,6 +3845,18 @@
     ^ 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 */
@@ -3862,6 +3899,18 @@
 %}
 ! 
 
+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 */
@@ -4849,6 +4898,18 @@
     ^ 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 */
@@ -4891,6 +4952,18 @@
 %}
 ! 
 
+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 */
@@ -5684,6 +5757,18 @@
 %}
 ! 
 
+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 */
@@ -5726,6 +5811,18 @@
 %}
 ! 
 
+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 */
@@ -5915,6 +6012,18 @@
     ^ 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 */
@@ -5957,6 +6066,18 @@
 %}
 ! 
 
+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 */