Documentation - Introduction to Rendering #2629
Replies: 21 comments
|
It's about the same. You can look at, for example the LIFE package. You just loop, drawing what you want to draw, it's polite to put a |
|
|
|
Thank you for your response, it will give me a starting point. |
|
@RyanBurnside I wonder if the Medley Primer https://interlisp.org/documentation/Medley-Primer.pdf was close as a better starting point? |
|
@nbriggs |
|
We've reorganized the web site and cataloged some of the available documentation; have you looked in https://interlisp.org/software/using-medley/ A lot of things need updating to 2024. In your screenshot try (FILESLOAD LIFE) (it's an Interilsp NLAMBDA function(from CL point of view, a macro). The (create PILOTBBT) is an indication (a) you're running Life interpreted, which is a lot slower than running compiled, and (b) you need to |
|
perhaps this could be a later chapter for the primer. |
|
Pardon the long delayed response! It turns out that I'm needing to revisit this concept a bit. I have a bit more experience now and managed to implement a self running demo. (This is going to be for a Boids simulation so pardon the name). You can imagine that for the classic "Boids" they just flock around and so the program doesn't rely on any hooks or input to keep updating. I'm working through this thread, and wanted to first start with the simple solution first offered by @nbriggs Hmm that LET should probably be moved outside and just SETQ in the FOR to reuse symbols... (LAMBDA (WINDOW NUM-BOIDS)
(PROG* ((WIN (OR WINDOW (CREATEW)))
(W (WINDOWPROP WINDOW 'WIDTH))
(H (WINDOWPROP WINDOW 'HEIGHT))
(BITMAP (BITMAPCREATE W H))
(DSP (DSPCREATE BITMAP)))
(for do (BLOCK)
(DSPRESET DSP)
(FRPTQ 10 (LET ((X (RAND 0 W))
(Y (RAND 0 H))
(RAD (RAND 16 32)))
(DRAWCIRCLE X Y RAD NIL NIL DSP)))
(BITBLT BITMAP 0 0 WIN)
until
(SHIFTDOWNP 'SHIFT)
finally
(CLOSEW WIN)))) |
|
In your |
|
I'd make that a |
|
it isnt clear what effect you're looking for in using a display stream on the BITMAP. If you want double buffering that's usually for some kind of continuity effect, but you're just drawing 10 random circles. you make a variable WIN to handle the default WINDOW when NIL but then don't use it consistently. the FOR is redundant but it would be more natural to write (while (SHIFTDOWNP 'SHIFT) do (BLOCK)) |
|
Overlapping @masinter's suggestion -- I had rewritten it as |
|
Edited: @pamoroso thanks! @masinter Ah, sorry for the confusion. This was not a finished demo, I wanted to make sure I had something that was properly updating on it's own without callbacks to start with. The circles were just a placeholder so I could see the updates for now. Yes, for the rest though I will want some kind of buffered display (I recall @hjellinek mentioning that rendering to an off screen bitmap then blitting that back reduces tearing and lag). Thanks for the catch on the inconsistent window usage. There was a bug. @nbriggs Thanks for the fix. I need to un CL:LOOP my brain a bit. I've been using FOR a bit too much. CL's LOOP always starts with the same identifier (LOOP) and then the clauses come, so I thought (wrongly) that FOR was the mandatory identifier for Interlisp's "Iterative Statement" but I see the first clause is more flexible than a keyword that starts every loop. Implementing it in such a freeform way without a common identifier must have been some interesting Macro-ology. |
|
I settled for some "snow" effects being far less intricate to make a demo for a newcomer. I thought simple arrays might be OK, but the SETA/ELT combo proved for more verbosity. The code below is too hackish. (It should run fine, but Github it butchering indentation...) (LAMBDA (NUM-FLAKES)
(* ;; "Provides a nice self updating snow simulator %"flakes%" are [x y radius]")
(PROG* ((WIN (CREATEW))
(NUM-FLAKES (OR NUM-FLAKES 100))
(W (WINDOWPROP WIN 'WIDTH))
(H (WINDOWPROP WIN 'HEIGHT))
(BITMAP (BITMAPCREATE W H))
(DSP (DSPCREATE BITMAP))
(FLAKES (for to NUM-FLAKES collect (LET ((TEMP (ARRAY 3 'FLOATP 0 0)))
(SETA TEMP 0 (RAND 0 W))
(SETA TEMP 1 (RAND 0 H))
(SETA TEMP 2 (RAND 1 3))
TEMP))))
(* ;; "Run demo until user presses shift ")
(until (SHIFTDOWNP 'SHIFT)
do
(BLOCK 10)
(DSPRESET DSP)
(* ;; "Update flakes keeping them onscreen")
(for F in FLAKES do (SETA F 0 (+ (ELT F 0)
(- (RAND 0 2)
1)))
(SETA F 1 (- (ELT F 1)
(RAND 1 3)))
(* ;; "Wrap around width")
(if (< (ELT F 0)
0)
then
(SETA F 0 W)
elseif
(> (ELT F 0)
W)
then
(SETA F 0 0))
(* ;; " Wrap around height")
(if (< (ELT F 1)
0)
then
(SETA F 1 H))
(* ;; "Render to buffer")
(DRAWCIRCLE (ELT F 0)
(ELT F 1)
(ELT F 2)
NIL NIL DSP))
(* ;; "Blit buffer to screen")
(BITBLT BITMAP 0 0 WIN)
finally
(CLOSEW WIN)))) |
|
When I read this discussion I was trying to figure out what "Boids" was. |
I've enjoyed her content for a long time. I think it's really cool that the original source is in Lisp. (What other language would you want to be doing exploratory thinking in!) |
|
Nothing wrong with the implementation. You could use You could give it a little east-wind bias with |
|
Thanks @nbriggs . I think the code is now sufficiently (looks through New Hacker's Dictionary) bummed and tense for the newcomer. So it's now hosted here. I had a few cool ideas like your wind option but wanted to keep it short (I got comment heavy). |
|
you can compile as-you-go by
If you want to assert "bummed" then compiling is the very first thing to do. |
|
As discussed in the May 27, 2026 external meeting I'll convert this issue to a discussion. |


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
One of the things that would be of interest to people (especially in a GUI system) is a small demo of rendering a real time system.
My past approach to such things in other systems is keeping a rendering "loop" going while polling the keyboard.
I realize this is probably different in the Medley environment.
I think there is a lot of power in just putting rendering knowledge in peoples' hands.
For example, I'd very much like to make a little 4th of July fireworks simulation.
I would be happy to write a tutorial for review with the Medley pros once I understand how to keep the window updating without user input and also where to store the program so it's cleared when the window is closed. I had a hack in my last game where I stored the game instance in the window user data but that's probably not correct.
Thanks for all the work on Medley, I will be using it in the future!
All reactions