X-Git-Url: http://uxul.de/gitweb/?p=uxul-world.git;a=blobdiff_plain;f=opengl.lisp;fp=opengl.lisp;h=907aa6d60cc019743324bc8553387959b7b3d8b0;hp=0000000000000000000000000000000000000000;hb=32d336f81c7ba63968f935b66d6b601ecf9d400b;hpb=074a5863f985bd9a078f41af96310fd55828df3f diff --git a/opengl.lisp b/opengl.lisp new file mode 100644 index 0000000..907aa6d --- /dev/null +++ b/opengl.lisp @@ -0,0 +1,27 @@ +;; Copyright 2010-2011 Christoph Senjak + +(in-package :uxul-world) + +(defun load-bmp-blob-into-texture (blob) + (let* + ((id (car (gl:gen-textures 1))) + (pix (bmp-pixel-data blob)) + (w (bmp-width blob)) + (h (bmp-height blob))) + (gl:bind-texture :texture-2d id) + (gl:tex-image-2d :texture-2d 0 :rgba8 w h 0 :bgra :unsigned-byte pix) + (gl:tex-parameter :texture-2d :texture-min-filter :linear) + (gl:tex-parameter :texture-2d :texture-mag-filter :linear) + (gl:flush) + id)) + +(defun make-quad (id x y w h) + (setf x (- (+ x x) +screen-width+ )) + (setf y (- (+ y y) +screen-height+)) + (gl:bind-texture :texture-2d id) + (gl:with-primitive :quads + (gl:tex-coord 0 0) (gl:vertex x (+ y h)) + (gl:tex-coord 1 0) (gl:vertex (+ x w) (+ y h)) + (gl:tex-coord 1 1) (gl:vertex (+ x w) y) + (gl:tex-coord 0 1) (gl:vertex x y))) +