Welcome to the CHICKEN Scheme pasting service

How's this possible? added by Jubjub on Sat Apr 5 13:08:02 2014

(define (atlas-fit! image #!optional (position (v2 0 0)))
  (unless *current-atlas* (reset-atlas))
  (let* ((atlas (car *current-atlas*))
        (textures (cadr *current-atlas*))
        (overlaps (find (lambda (t)
                          (contains? position (texture-offset t) (texture-size t))) textures)))
    (cond ((overlaps
             (print overlaps) ; prints #f
             (atlas-fit! image (v2-add position (texture-size overlaps)))))
          ((not (contains? (v2-add position (image-size image)) (v2 0 0) *atlas-page-size*))
           (reset-atlas)
           (atlas-fit! image))
          (else
            (set-texture atlas)
            (gl:TexSubImage2D gl:TEXTURE_2D 0 (v2-x position) (v2-y position)
                              (image-width image) (image-height image) gl:RGBA
                              gl:UNSIGNED_BYTE (make-locative (u8vector->blob/shared
                                                           (image-pixels image))))
            (make-texture (texture-id atlas) (image-size image) position)))))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the procedure that returns the cdr of a car?
Visually impaired? Let me spell it for you (wav file) download WAV