chiark / gitweb /
merge into history old stuff found on chiark
[moebius.git] / dualx11.cc
index 4bfc39cba3edb3b7c39012a7eafd0bc9d6a6d670..6a2edd5a796aeaac6e8e6fe288b62ea39cd0a9dd 100644 (file)
@@ -5,6 +5,9 @@
 #include "dualx11.hh"
 #include "parameter.hh"
 
+static Parameter<int> dualx11size("dualx11size", "Dual X11 window size",
+                                 500, 100, 10, 10000);
+
 DualX11Output::DualX11Output() {
   display= XOpenDisplay(0);
   Colormap cmap= DefaultColormap(display,DefaultScreen(display));
@@ -26,9 +29,10 @@ DualX11Output::DualX11Output() {
   
   window= XCreateSimpleWindow(display,
                               DefaultRootWindow(display),
-                              0,0, 500,500, 0,0, pixelbase);
+                              0,0, dualx11size,dualx11size, 0,0, pixelbase);
 
   XGCValues gcvalues;
+  int i;
   for (i=0; i<2; i++) {
     gcvalues.plane_mask= planemasks[i];
     // First, the fabric
@@ -59,21 +63,36 @@ DualX11Output::~DualX11Output() {
   XCloseDisplay(display);
 }
 
-void DualX11Output::drawcell(const Point* list, int n) {
-  static Parameter<double> eyeseparation("eyesep",
-                                         "Distance from projection eye to origin", 
-                                         0.3, .1, 0., 100.);
+void DualX11Output::drawcell(const Point* list, int n, Colour colour) {
+  static Parameter<double>
+    eyeseparation("eyesep", "Distance from projection eye to origin", 
+                 0.3, .1, 0., 100.);
+
   for (int i=0; i<2; i++) {
+    GC fill;
+    bool draw;
+    
     Point::seteyex(eyeseparation*(i-0.5));
+
+    switch (colour) {
+    case grid:       fill= fabric[i]; draw= true;  break;
+    case solidblack: fill= fabric[i]; draw= false; break;
+    case solidwhite: fill= mesh[i];   draw= false; break;
+    default: abort();
+    }
+
     XPoint xp[n+1];
     for (int j=0; j<n; j++) {
       Onscreen here= Onscreen(list[j]);
-      xp[j].x= (int)((here.x+1.0)*250.0);
-      xp[j].y= (int)((-here.y+1.0)*250.0);
+      xp[j].x= (int)((here.x+1.0)*(dualx11size*0.5));
+      xp[j].y= (int)((-here.y+1.0)*(dualx11size*0.5));
+    }
+
+    XFillPolygon(display,window,fill,xp,n,Nonconvex,CoordModeOrigin);
+    if (draw) {
+      xp[n]= xp[0];
+      XDrawLines(display,window,mesh[i],xp,n+1,CoordModeOrigin);
     }
-    XFillPolygon(display,window,fabric[i],xp,n,Nonconvex,CoordModeOrigin);
-    xp[n]= xp[0];
-    XDrawLines(display,window,mesh[i],xp,n+1,CoordModeOrigin);
   }
   Point::seteyex(0);
 }