[Openmcl-devel] Small bug in iSight camera window code

Ron Garret ron at awun.net
Tue Jul 15 16:15:59 PDT 2008


Below is some code that displays video from an iSight camera.  It  
works, but for some reason it doesn't actually start displaying until  
you move the window.  I would have thought that the call to  
setNeedsDisplay would take care of this but it doesn't.  Any Cocoa  
experts out there tell me what I'm doing wrong?

Thanks,
rg

---

(objc:load-framework "QTKit" :qtkit)
(#/inputDevices ns:q-t-capture-device)
(setf devs (#/inputDevicesWithMediaType: ns:q-t-capture-device  
#&QTMediaTypeVideo))
(setf cam (#/objectAtIndex: devs 0))
(%stack-block ((err 8)) (#/open: cam err))
(setf caminput (make-instance ns:q-t-capture-device-input))
(#/initWithDevice: caminput cam)
(setf session (make-instance ns:q-t-capture-session))
(#/init session)
(%stack-block ((err 8)) (#/addInput:error: session caminput err))

(defparameter +standard-window-style-mask+
   (logior #$NSTitledWindowMask
           #$NSClosableWindowMask
           #$NSMiniaturizableWindowMask
           #$NSResizableWindowMask))

(defun make-ns-window (x y &optional (title "Untitled"))
   (bb nsw (make-instance 'ns:ns-window
             :with-content-rect (ns:make-ns-rect 0 0 x y)
             :style-mask +standard-window-style-mask+
             :backing #$NSBackingStoreBuffered
             :defer t)
       (#/setTitle: nsw title) ; (nsstr title))
       (#/setReleasedWhenClosed: nsw nil)
       (#/center nsw)
       (#/orderFront: nsw nil)
       nsw))

(setf w (make-ns-window 320 240))
(setf v (make-instance ns:q-t-capture-view))
(#/setContentView: w v)
(#/setCaptureSession: v session)
(#/startRunning session)
(#/setNeedsDisplay: v t)




More information about the Openmcl-devel mailing list