An OpenGL backend for SDL using OpenRM in just a few lines of Common Lisp
code. Updates to the SDL surface are being rendered by the OpenRM sprite
primitive in realtime. Basically the pixel data are shared between the SDL
surface and the OpenRM sprite so no actual copying takes place. Because of
differences in the SDL and OpenGL coordinate system the result is that the
surface is rendered mirrored & upside down. I should be able to fix this
by using a texture map instead of a sprite.

SDL-WINDOW creates a new surface of :width & :height and assigns it to
sdl:*default-display* so all the existing drawing functions in
lispbuilder-sdl just work.

(defun sdl-circles ()
    (make-instance 'rm::sdl-window
                   :width 320 :height 240
                   :title-caption "Using OpenRM as a backend for SDL."
                   :icon-caption "Using OpenRM as a backend for SDL.")
    (make-instance 'rm:scene
                   :window (rm::default-window)
                   :camera (make-instance 'rm::camera-2d)
                   :viewport #(0.0 0.0 1.0 1.0)
                   :compute-view-from-geometry nil)

    (let* ((image (rm::load-image sdl:*default-display*))
           (sprite (rm::new-sprite :xy/z (calculate-image-center
(rm::default-window) image)
                                   :images image)))

      (rm::add-node sprite (rm::default-scene))

      (setf (sdl:frame-rate) nil)

      (sdl:with-events ()
        (:key-down-event ()
         (sdl:push-quit-event))
        (:quit-event () t)
        (:idle ()
         (sdl:draw-filled-circle-* (random 320) (random 240) (random 50)
                                   :color (sdl:color :r (random 255)
                                                     :g (random 255)
                                                     :b (random 255)))
         (rm::render))))
    (rm::clean-up))
_______________________________________________
application-builder mailing list
application-builder@lispniks.com
http://www.lispniks.com/mailman/listinfo/application-builder

Reply via email to