Skip to content

Instantly share code, notes, and snippets.

@joelreymont
Created December 31, 2009 18:38
Show Gist options
  • Save joelreymont/266840 to your computer and use it in GitHub Desktop.
Save joelreymont/266840 to your computer and use it in GitHub Desktop.
(defun cocoa-build-sprite (sprite image mask size)
(declare #.*optimize*
(type fixnum size))
(loop for i fixnum from 0 below size
for ii fixnum from 0 by 3
for si fixnum from 0 by 4
for alpha fixnum = ii
for sr fixnum = si
for sg fixnum = (1+ sr)
for sb fixnum = (1+ sg)
for sa fixnum = (1+ sb)
for ir fixnum = ii
for ig fixnum = (1+ ir)
for ib fixnum = (1+ ig) do
;; copy color channels
(setf (opengl:gl-vector-aref sprite sr)
(the fixnum (opengl:gl-vector-aref image ir)))
(setf (opengl:gl-vector-aref sprite sg)
(the fixnum (opengl:gl-vector-aref image ig)))
(setf (opengl:gl-vector-aref sprite sb)
(the fixnum (opengl:gl-vector-aref image ib)))
;; set alpha from mask
(setf (opengl:gl-vector-aref sprite sa)
(the fixnum (opengl:gl-vector-aref mask alpha)))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment