[cello-devel] Cello "Just Shoot Me!" shots on c-l.net [was Re: Cello update: Web info, and a feature]

Kenny Tilton ktilton at nyc.rr.com
Thu Mar 18 21:15:33 UTC 2004


Brought to you by the miracle of Cello's new Just Shoot Me!(tm) embedded 
frame capture capability:

    ftp://common-lisp.net/pub/project/cello

Look for cello-shots.zip or the signed cello-shots.asc (if I did that 
right, which I doubt).

Not worth the trouble if you have been to my web site, unless you want 
to enter the Find-the-Celebrities contest (find two to win the right to 
port Cello to OS X).

As advertised, not many diff widgets yet. Just buttons, check boxes, and 
sliders (but checkout the 2-D slider). Unless you count static widgets: 
one-line text and images. The focus to date instead has been:

   - portability: all code and libs are portable. In principle, and in 
fact to ACL/win32, LW/win32, and ACL/Linux.

   - fonts: done. bitmapped, pixmapped, texture, polygon, polygon 
extruded and outlie. One shot shows a polygon extruded string in 
wireframe mode. Neato. It was a real pain calculating and typing in the 
coordinates of all those vertices, tho.

   - pretty pictures: check. very pretty in the shot which happens also 
to show a few of the fonts on my system (in texture mode, btw, the 
fastest, prettiest, and most flexible in re rotations, rescaling, etc etc.

   - stupid OpenGL tricks (so youse guys won't have to figure them out, 
and because they look so cool). Well, to a degree this is also about 
performance, because figuring out textures (to the poor degree I have) 
means much better performance. And this is why Cello methinks belongs in 
the "scene graph Lite" category, because one design imperative is that a 
user should not have to understand OpenGL to build a normal GUI with Cello.

[aside: speaking of tricks, check out orange-tea.jpg where I turned down 
all the lights (the 3d buttons pretty much disappear, but you still see 
the labels because I elected to turn lighting off for text display) and 
played with the OpenGL parameters on the remaining light to create a 
spotlight effect. The funny thing is that I have to move my little 
flashlight back over the light control panel to wind the sliders to turn 
the lights back up. (Is it OK that this is so much fun?) If I get the 
movie-making thing going satisfactorily I will post a demo of me looking 
aound the gui with the flashlight--it will be a little jumpy because I 
am always laughing so hard when I do that.

btw, thanks-nehe.jpg is lovely (thanks to his own cool logo) and is 
actually a tutorial-by-example of basic Cello widget geometry. It is 
dedicated to him because without his web site Cello might not exist. The 
uneven row of widgets at the top all have the same vertical position, 
with local bounds tweaked to make them appear as if they do not. The 
origin is the little dot near the topleft corner, invisible in the 
middle widget because it is on the TL corner. You cannot see it, but the 
bottom widget circles its origin, which is stationary. Check out the 
last box:

(thekids
  (mkPart :box(tu-box)
    :px 50 :py -100
    :color +red+
    :lL -25 :lT (ups 25))
  (mkPart :box(tu-box)
    :px 300 :py -100
    :color +green+
    :lL 0 :lT 0)
  (mkPart :box(tu-box)
    :px 500 :py -100
    :color +yellow+
    :lL 25 :lT (ups -25))
  (mkPart :box(tu-box)
    :px 300 :py -500
    :color +yellow+
    :md-value (c? (degree-radians (mod (frame-ct .w.) 360)))
    :lL (c? (+ -62.5 (* 62.5 (cos (^md-value)))))
    :lT (c? (+ 62.5 (* -62.5 (sin (^md-value)))))))

Classic cells. rendering code for the window ends with:

      (incf (frame-ct self))

That causes the lower tu-box instance to compute a new md-value ("model 
value" as in "model-view", md-value being a useful bucket every instance 
has which can be used for whatever) causing the ll and lt (local-left 
and local top) to be recalculated. The echo function on these slots 
trigger a re-render by calling glut-post-redisplay. Second verse, same 
as the first.

Not shown is that this in turn causes the lr and lb to recalculate. 
Well, here ya go:

(defmodel tu-box (image)
   ((color :initarg :color :accessor color :initform nil))
   (:default-initargs
       :lR (C? (^lr-width 125))
     :lb (C? (^lb-height (downs 125)))
     :layers (c? (list :off (gloff GL_TEXTURE_2D)
                   (xlout 200) (color self)
                   '(:line-width 3) :line-lr))))

The ^lr-width maco expands to: (+ (lL self) <value>)

downs ("down screen") expands to (- 0 <values>*) because it was a pain 
switching over from the usual gui model in which positive is down.

The layers slot is funny, a slot which invented itself. I gave it an 
inch and it will probably end up being the only way to render. The 
really cool thing is that OpenGL itself will compile any sequence of 
OpenGL drawing commands and transformations into what it calls display 
lists, so I am not too embarrassed to be rendering complex things by a 
list of commands. In fact (and leading to another point about Cells) 
here is the dedicated rendering method:

(defmethod ix-render ((self tu-box))
   (trc nil "drawing tu-box" (gbox self))
   (gl-polygon-mode GL_FRONT_AND_BACK GL_FILL)
   (gl-line-width 4)
   (gl-rectf -2 2 2 -2))

Hell, if I just extend my layers language with :poly-mode and :rect 
operators I can lose the special method, and if I sneak the color into 
the skin slot on the image class (not completely unreasonable) I do not 
even need the class, and here is how I make the kids (including the 
close button this time):

(flet ((tu-box (name &rest deets)
          (apply 'make-instance 'image
            :md-name name
            :lR (C? (^lr-width 125))
            :lb (C? (^lb-height (downs 125)))
            :layers (c? (list
                         (gloff gl_texture_2d)
                         :off
                         '(:line-width 3)
                         (skin self)
                         :line-lr
                         `(:poly-mode ,gl_front_and_back ,gl_fill)
                         '(:rect -2 2 2 -2)))
            deets)))
   (thekids
    (tu-box :ftgrow
      :px 50 :py -100
      :skin +red+
      :lL -25 :lT (ups 25))
    (tu-box :ftgrow
      :px 300 :py -100
      :skin +green+
      :lL 0 :lT 0)
    (tu-box :ftgrow
      :px 500 :py -100
      :skin +yellow+
      :lL 25 :lT (ups -25))
    (tu-box :ftgrow
      :px 300 :py -500
      :skin +yellow+
      :md-value (c? (degree-radians (mod (frame-ct .w.) 360)))
      :lL (c? (+ -62.5 (* 62.5 (cos (^md-value)))))
      :lT (c? (+ 62.5 (* -62.5 (sin (^md-value))))))
    (mkPart :bye (CTButton)
      :px (c? (/ (lwidth .w.) 2))
      :py (c? (downs (/ (lheight .w.) 2)))
      :text$ "Close"
      :controlAction (lambda (self event &aux (gw (glutw .w.)))
                       (declare (ignorable event))
                       (glut-Destroy-Window gw)))))

The point about Cells is that it delivers on object reuse, as defined in 
a recent painful thread: the generic image widget serves nicely inan 
unanticipated role because so much code has been moved out to rules 
which can be specified differently for different slots of instances of 
the same (more) generic class.


Ng Pheng Siong wrote:
> According to Kenny Tilton  <ktilton at nyc.rr.com>:
> 
>>Well, someone broke in yesterday and stole a draft of the info I was 
>>going to put up and, well, put it up:
>>
>>   http://www.common-lisp.net/project/cello/
> 
> 
> It seems the Cincom Smalltalk people are building a new GUI framework
> called Pollock:
> 
>   http://www.cincomsmalltalk.com/userblogs/pollock/blogView 
> 
> In my mind, when people are ready to graduate from tcl, Python, Perl, etc.
> the next level up is Common Lisp or Smalltalk. Kenny's competition may not
> come from the Lisp space at all. ;-)

Once they chose Lisp over Smalltalk, Cello should have no problem 
whipping Pollock's butt. :) Cello just keeps people from passing up Lisp 
because it has (had) no GUI. They won't know how much fun is Cello until 
they have seen enough Lisp that they will already be converted.

But I think I know the masses, and I wager the first thing they will 
want to play with after they finish Practical Lisp is a GUI, so 
newby-level Cello doc will be essential (hence Peter's follow-up 
bestseller, Practical Cello <g> [please note everyone that the entire 
second half of this sentence is a joke]). I will approach the Black Book 
people about doing The Cello Black Book. (I like that approach to doc.)


kt

-- 
http://tilton-technology.com

Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

Your Project Here! http://alu.cliki.net/Industry%20Application





More information about the cello-devel mailing list