1 ;; Copyright 2010-2011 Christoph Senjak
\r
3 (in-package :uxul-world)
\r
5 (defun load-bmp-blob-into-texture (blob)
\r
7 ((id (car (gl:gen-textures 1)))
\r
8 (pix (bmp-pixel-data blob))
\r
10 (h (bmp-height blob)))
\r
11 (gl:bind-texture :texture-2d id)
\r
12 (gl:tex-image-2d :texture-2d 0 :rgba8 w h 0 :bgra :unsigned-byte pix)
\r
13 (gl:tex-parameter :texture-2d :texture-min-filter :linear)
\r
14 (gl:tex-parameter :texture-2d :texture-mag-filter :linear)
\r
18 (defun load-spritesheet ()
\r
20 ((id (car (gl:gen-textures 1)))
\r
21 (wh (cadr *spritesheet*))
\r
22 (pix (car *spritesheet*)))
\r
23 (gl:bind-texture :texture-2d id)
\r
24 (gl:tex-image-2d :texture-2d 0 :rgba8 wh wh 0 :bgra :unsigned-byte pix)
\r
25 (gl:tex-parameter :texture-2d :texture-min-filter :linear)
\r
26 (gl:tex-parameter :texture-2d :texture-mag-filter :linear)
\r
30 (defun make-quad (imgs x y w h)
\r
31 (destructuring-bind (x1 y1 x2 y2) imgs
\r
32 (setf x (- x +screen-width+))
\r
33 (setf y (- y +screen-height+))
\r
34 (gl:bind-texture :texture-2d *spritesheet-id*)
\r
35 (gl:with-primitive :quads
\r
36 (gl:tex-coord x1 y1) (gl:vertex x (+ y h))
\r
37 (gl:tex-coord x2 y1) (gl:vertex (+ x w) (+ y h))
\r
38 (gl:tex-coord x2 y2) (gl:vertex (+ x w) y)
\r
39 (gl:tex-coord x1 y2) (gl:vertex x y))))
\r