Created
December 31, 2009 18:38
-
-
Save joelreymont/266840 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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