< Back to IRCAM Forum

OpenMusic Class protocol tuto

Hello,

I am having trouble implementing the example shown in the dev ressources about OM Class-protocol.
(source here : https://openmusic-project.github.io/openmusic/dev/classprotocol
The example code aiming at showing a simple colored rectangle in miniview evaluates correctly in the lisp buffer but when I press “m” to show the miniview, openmusic crashes and I get this report. Did I miss something? Any help is much appreciated. Thank you

J

Dear J,

Thank you for pointing this out. In fact, this tutorial is dated (from the beginning of OM, circa 20 y and more).
The api changed many times.
If you need to run this use this code instead:

(in-package :om)

  (defclass! rgb-color ()
    ((red-comp :initform 1 :initarg :red-comp :accessor red-comp)
     (green-comp :initform 1 :initarg :green-comp :accessor green-comp)
     (blue-comp :initform 1 :initarg :blue-comp :accessor blue-comp))
    (:documentation "color with components red, blue and green.")
    (:icon 179))

 (defmethod draw-obj-in-rect ((self rgb-color) x x1 y y1 edparams view) 
   (om-with-fg-color view (om-make-color (red-comp self) (green-comp self) (blue-comp self))
     (om-fill-rect x y x1 y1)))

The only difference is that the om-with-fg-color macro now applies to the view and not to the class itself. (i have changed the default color values to white :slight_smile: )

Best
K

1 Like

Thank you so much dear Karim !!

All the best,
J

1 Like