Animation with Timers
Hello,
I’ve searched through the examples for an animation example and found balloons.lisp. I’ve come up with the following code:
(defpackage :typing
(:use :cl :capi))
(in-package :typing)
(defparameter *typing-timer* nil)
(defun typing-display-callback (pane &optional x y w h)
(unless *typing-timer*
(setf *typing-timer* (mp:make-timer #'typing-display-callback pane)))
(with-atomic-redisplay (pane)
(gp:clear-graphics-port pane)
(gp:draw-string pane "testing" (random 800) (random 450)))
(mp:schedule-timer-relative *typing-timer* (/ 1 30)))
(defun typing ()
(let ((pane (make-instance 'output-pane
:display-callback 'typing-display-callback
:background :white
:initial-constraints
'(:visible-min-width 800 :visible-min-height 450)
:title "Typing - the game")))
(contain pane)))
I am expecting from this code the work “testing” jumping around the screen, but what I get is (usually) just a single frame and no further graphics updates, like something needs to be synched or flipped. I know the timer is running, because if I put in a (format t “.”) I see a stream of dots in the output buffer. I have searched for ways to swap or flush the buffer to screen (redisplay-all-screens) on Cocoa, as the documentation states that it is a buffered display to no avail.
Sometimes I do see what I expect, but only if I put another window obscuring part of the main window.
Any tips on how I can get animation output using CAPI?
Burton Samograd