From: Dave Touretzky
Subject: help with Allegro/CLX graphics
Date: 
Message-ID: <bhsc6a$di1$1@wolfberry.srv.cs.cmu.edu>
Years ago I wrote a little tool called SDRAW that draws cons cell
structures, and even handles circular structures.  It's useful for
teaching beginning Lispers how to relate list notation, dot notation,
and graphical cons cell representations.  I gave this tool away for
free.  It's on my web site, here:

  http://www.cs.cmu.edu/~dst/Lisp/sdraw/sdraw.allegro

Unfortunately, software rot has set in, and the Allegro/CLX version of
the tool no longer works.  (There is also a generic version that uses
ASCII graphics and works fine.)  Running Allegro 6.1 under RedHat 7.1,
the CLX version gets runtime errors from inside Xlib, such as the
following:

  cl-user(2): (sdraw '(foo bar baz))
  Error: Asynchronous match-error in request 23 (last request was 26)  Code 70.0 [PolyFillRectangle]

If I move around on the stack and do :continue 0, sometimes the
function completes successfully and draws what it's supposed to.
Sometimes it doesn't.

I imagine that someone familiar with the current state of Allegro/CLX
could fix this in a couple of minutes.  I don't have the time to trace
it down myself.

So if anyone wants to take a crack at this, I'd be grateful for the
assistance.

-- Dave Touretzky

From: Dave Touretzky
Subject: Re: help with Allegro/CLX graphics
Date: 
Message-ID: <bhss0n$jh1$1@wolfberry.srv.cs.cmu.edu>
Andy Hefner sent me a fix for my CLX problem, so the graphical version
of sdraw is working again.  You can download it from:

  http://www.cs.cmu.edu/~dst/Lisp/sdraw/sdraw.allegro

Thanks, Andy.

-- Dave Touretzky
From: Peter Seibel
Subject: Re: help with Allegro/CLX graphics
Date: 
Message-ID: <m365ktpfss.fsf@javamonkey.com>
···@cs.cmu.edu (Dave Touretzky) writes:

> Andy Hefner sent me a fix for my CLX problem, so the graphical version
> of sdraw is working again.  You can download it from:
> 
>   http://www.cs.cmu.edu/~dst/Lisp/sdraw/sdraw.allegro
> 

I gave this a whirl and got the following error while loading:

  Error: Connection failure to X11.0 server  display 0: No protocol specified

    [condition type: CONNECTION-FAILURE]

Turns out this is due to the call to xlib:open-display. I suspect it's
something goofy in either my X or ACL setup. Anyone know what this is
about? I'm running ACL 6.2 on a RedHat GNU/Linux box.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Kevin Layer
Subject: Re: help with Allegro/CLX graphics
Date: 
Message-ID: <mkekzhxlf3.fsf@*n*o*s*p*a*m*franz.com>
Peter Seibel <·····@javamonkey.com> writes:

> ···@cs.cmu.edu (Dave Touretzky) writes:
> 
> > Andy Hefner sent me a fix for my CLX problem, so the graphical version
> > of sdraw is working again.  You can download it from:
> > 
> >   http://www.cs.cmu.edu/~dst/Lisp/sdraw/sdraw.allegro
> > 
> 
> I gave this a whirl and got the following error while loading:
> 
>   Error: Connection failure to X11.0 server  display 0: No protocol specified
> 
>     [condition type: CONNECTION-FAILURE]
> 
> Turns out this is due to the call to xlib:open-display. I suspect it's
> something goofy in either my X or ACL setup. Anyone know what this is
> about? I'm running ACL 6.2 on a RedHat GNU/Linux box.

I had to do this (changed from the original):

(defvar *display*
    (let* ((disp (system:getenv "DISPLAY"))
	   (colon-pos (position #\: disp :test #'char=))
	   (host (subseq disp 0 colon-pos))
	   (dispn (read-from-string (subseq disp (1+ colon-pos)))))
      (xlib:open-display host :display dispn)))

Instead of this:

(defvar *display* (xlib:open-display "")) ;cannot network window (see above)

Then, it worked (in Allegro CL 6.2 (patched)).  Btw, I also cleaned up
the defpackage like this:

(defpackage :sdraw
  (:use #:common-lisp)
  (:export #:sdraw #:sdraw-loop #:scrawl #:*sdraw-print-circle*
	   #:*sdraw-leading-arrow* #:sdraw #:sdraw-loop #:scrawl
	   #:*sdraw-print-circle* #:*sdraw-leading-arrow*))

and deleted the shadowing-import form.

Kevin
From: Daniel Barlow
Subject: Re: help with Allegro/CLX graphics
Date: 
Message-ID: <87ekzh8d0s.fsf@noetbook.telent.net>
Peter Seibel <·····@javamonkey.com> writes:

> I gave this a whirl and got the following error while loading:
>
>   Error: Connection failure to X11.0 server  display 0: No protocol specified

"No protocol specified" is usually the error message you get for
having incorrect xauthority data.  Sadly the message comes direct from
the server, not from the X library, so it's difficult for any CLX
maintainer to provide a more helpful diagnostic message.

It's possible that ACL's CLX port doesn't understand xauth.  Try doing
something horribly insecure with xhost (such as "xhost +") and see if
that helps.


-dan

-- 

   http://www.cliki.net/ - Link farm for free CL-on-Unix resources 
From: Peter Seibel
Subject: Re: help with Allegro/CLX graphics
Date: 
Message-ID: <m3ptj0me9q.fsf@javamonkey.com>
Daniel Barlow <···@telent.net> writes:

> Peter Seibel <·····@javamonkey.com> writes:
> 
> > I gave this a whirl and got the following error while loading:
> >
> >   Error: Connection failure to X11.0 server  display 0: No protocol specified
> 
> "No protocol specified" is usually the error message you get for
> having incorrect xauthority data.  Sadly the message comes direct from
> the server, not from the X library, so it's difficult for any CLX
> maintainer to provide a more helpful diagnostic message.
> 
> It's possible that ACL's CLX port doesn't understand xauth.  Try doing
> something horribly insecure with xhost (such as "xhost +") and see if
> that helps.

That was it. Thanks. (That also explains why I wasn't able to find
that string anywhere in the CLX sources). So does the fact that xhost
+ fixes the problem suggest that ACL doesn't understand xauth. Or is
it something else?

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Daniel Barlow
Subject: Re: help with Allegro/CLX graphics
Date: 
Message-ID: <87he4c6u7d.fsf@noetbook.telent.net>
Peter Seibel <·····@javamonkey.com> writes:

> That was it. Thanks. (That also explains why I wasn't able to find
> that string anywhere in the CLX sources). So does the fact that xhost
> + fixes the problem suggest that ACL doesn't understand xauth. Or is
> it something else?

Going by the version of CLX found at ftp://ftp.franz.com/pub/clx/clx/
(which according to CLiki is the one in Allegro 6.2), there are
optional arguments to open-display to provide authorization data, but
nothing that reads the .Xauthority file, so you'd have to figure out
appropriate authorization data yourself.  

To emulate Xlib completely means some slightly evil special-casing:
http://clozure.com/pipermail/portable-clx-devel/2003-February/000028.html
has the full sorry story.  Anyway, Eric Marsden wrote code in the
CMUCL port of CLX (which I have since also stolen for SBCL) to do this
parsing.  You could probably also borrow this and add it to the
Allegro version - or indeed, you could bug your vendor to do it for
you ;-)


-dan

-- 

   http://www.cliki.net/ - Link farm for free CL-on-Unix resources 
From: Christophe Rhodes
Subject: Re: help with Allegro/CLX graphics
Date: 
Message-ID: <sqk79aq9kb.fsf@lambda.jcn.srcf.net>
···@cs.cmu.edu (Dave Touretzky) writes:

> Years ago I wrote a little tool called SDRAW that draws cons cell
> structures, and even handles circular structures.  It's useful for
> teaching beginning Lispers how to relate list notation, dot notation,
> and graphical cons cell representations.  I gave this tool away for
> free.  It's on my web site, here:
>
>   http://www.cs.cmu.edu/~dst/Lisp/sdraw/sdraw.allegro
> [...]
> I imagine that someone familiar with the current state of Allegro/CLX
> could fix this in a couple of minutes.  I don't have the time to trace
> it down myself.

I'm not familiar with the current state of Allegro/CLX, but (apart
from removing the messing with the non-existent "USER" package) your
code runs fine with SBCL/CLX if the following change is made:

@@ -593,7 +596,8 @@
 (defconstant *diameter* 7)
 (defun create-circle ()
   (let ((pix (xlib:create-pixmap :width *diameter* :height *diameter*
-                                :depth 1 :drawable *window*))
+                                :depth (xlib:drawable-depth *window*)
+                                :drawable *window*))
        (data '((2 4)(1 5)(0 6)(0 6)(0 6)(1 5)(2 4))))
     (xlib:with-gcontext (*gc* :foreground *white*)
       (xlib:draw-rectangle pix *gc* 0 0 *diameter* *diameter* t))

(thanks to Andy Hefner for spotting the error, which was essentially
assuming a 1-bit display).

Christophe
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)