diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-30 07:57:54 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-30 07:57:54 -0500 |
commit | 642c0c594a8abe05be1cb887110ed3e602cd0e48 (patch) | |
tree | 2f4aced5b03abb0b8e4532f2676a18f8387895f7 /src/interactive-units/bitmap.lisp | |
parent | 099c3f927c11fe7ae4d12933d6f72abc0b53e973 (diff) |
[structure] renamed some asd modules
Diffstat (limited to 'src/interactive-units/bitmap.lisp')
-rw-r--r-- | src/interactive-units/bitmap.lisp | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/interactive-units/bitmap.lisp b/src/interactive-units/bitmap.lisp deleted file mode 100644 index cc4b4f7..0000000 --- a/src/interactive-units/bitmap.lisp +++ /dev/null @@ -1,72 +0,0 @@ -;;;; bitmap.lisp - -(in-package #:wheelwork) - -(defclass/std bitmap (affine interactive) - ((texture :ri :std (error "A bitmap requires a texture.")) - (vao shader :with :r :static))) - -(defmethod initialize-instance :after ((bitmap bitmap) &key) - (with-slots (vao shader base-width base-height texture) bitmap - (setf base-height (texture-height texture) - base-width (texture-width texture)) - (unless shader - (setf shader - (create-shader - '(:vertex - ((vert :vec2)) - ((transform :mat4)) - ((values - (* transform (vari:vec4 vert 0.0 1.0)) - vert))) ;color - '(:fragment - ((tc :vec2)) - ((tex :sampler-2d)) - ((let ((frag (vari:texture tex tc))) - (if (< (aref frag 3) 0.01) - (vari:discard) - frag)))))) - (gl:program-uniformi - shader - (gl:get-uniform-location shader "TEX") - 0)) - (unless vao - (setf vao (gl:gen-vertex-array)) - (gl:bind-vertex-array vao) - (let ((vbo (gl:gen-buffer))) - (with-gl-array (verts :float - 0.0 1.0 - 1.0 0.0 - 0.0 0.0 - - 0.0 1.0 - 1.0 1.0 - 1.0 0.0 ) - (gl:bind-buffer :array-buffer vbo) - (gl:buffer-data :array-buffer :static-draw verts))) - (gl:enable-vertex-attrib-array 0) - (gl:vertex-attrib-pointer 0 2 :float 0 (* +float-size+ 2) 0) - (gl:bind-buffer :array-buffer 0) - (gl:bind-vertex-array 0)))) - -(defmethod cleanup ((bitmap bitmap)) - (with-slots (vao shader) bitmap - (when vao - (gl:delete-vertex-arrays (list vao))) - (when shader - (gl:delete-program shader)) - (setf vao nil - shader nil))) - -(defmethod render ((bitmap bitmap)) - (with-slots (texture vao shader) bitmap - (gl:active-texture 0) - (gl:bind-texture :texture-2d (texture-id texture)) - (gl:use-program shader) - (gl:program-uniform-matrix-4fv - shader - (gl:get-uniform-location shader "TRANSFORM") - (projected-matrix bitmap)) - (gl:bind-vertex-array vao) - (gl:draw-arrays :triangles 0 6) - (gl:bind-vertex-array 0))) |