aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interactive
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-12-10 07:11:02 -0800
committercolin <colin@cicadas.surf>2024-12-14 08:35:58 -0800
commit8a51ba81c7df6b0b6dab7cf4b35b5ca084b653ba (patch)
tree23f5f0a5449a06473aba2ec7914a3c2193823a10 /src/interactive
parent2cbb8e4114c860e1774efd40d18661aee8ab2a72 (diff)
Replaced defclass-std with defrefactor-with-def
Diffstat (limited to 'src/interactive')
-rw-r--r--src/interactive/canvas.lisp19
-rw-r--r--src/interactive/frameset.lisp20
-rw-r--r--src/interactive/image.lisp7
-rw-r--r--src/interactive/interactive.lisp11
-rw-r--r--src/interactive/sprite.lisp8
-rw-r--r--src/interactive/text.lisp41
6 files changed, 63 insertions, 43 deletions
diff --git a/src/interactive/canvas.lisp b/src/interactive/canvas.lisp
index af54634..f4b2b74 100644
--- a/src/interactive/canvas.lisp
+++ b/src/interactive/canvas.lisp
@@ -2,9 +2,11 @@
(in-package #:wheelwork)
-(defclass/std pixels ()
- ((pixel-width pixel-height :std (error "pixel-width and pixel-height are required"))
- (data :a :with :doc "Array of RGBA data representing an image of pixel-width X pixel-height")))
+(def:class pixels ()
+ (pixel-width pixel-height :required :type fixnum)
+ (data :prefix
+ :type (vector (unsigned-byte 8))
+ :documentation "Array of RGBA data"))
(defmethod initialize-instance :after ((pixels pixels) &key)
(with-slots (pixel-width pixel-height data) pixels
@@ -145,14 +147,15 @@ e.g., drawing a line in a particular color."
(gl:delete-vertex-arrays (list *canvas-render-vao*)))
(when *canvas-shader-program*
(gl:delete-program *canvas-shader-program*))
- (setf-many *canvas-fbo-vao*
- *canvas-render-vao*
+ (setf-many *canvas-render-vao*
*canvas-shader-program*
nil)))))
-(defclass/std canvas (unit interactive pixels)
- ((fbo :with :r :doc "framebuffer object for use in off-screen-rendering of this canvas to a texture")
- (texture :with :a :doc "texture instance")))
+(def:class canvas (unit interactive pixels)
+ ((fbo "framebuffer object for use in off-screen rendering of this canvas to a texture")
+ :prefix :ro)
+ ((texture "the texture where the pixles are rendered")
+ :prefix))
(defmethod cleanup ((canvas canvas))
(cleanup (canvas-texture canvas))
diff --git a/src/interactive/frameset.lisp b/src/interactive/frameset.lisp
index c866d04..65762c7 100644
--- a/src/interactive/frameset.lisp
+++ b/src/interactive/frameset.lisp
@@ -2,12 +2,20 @@
(in-package #:wheelwork)
-(defclass/std frameset (unit interactive)
- ((frames :with :doc "an array of renderable frames")
- (sequence :with :doc "an array of indices into frames")
- (runningp :std t)
- (wait-time :std (/ 1000.0 2) :with :doc "milliseconds between frames")
- (count index next-time :with :std 0 :a)))
+;; TODO: be more specific about vector types
+(def:class frameset (unit interactive)
+ ((frames "Vector of renderable frames.")
+ :prefix :type vector)
+ ((sequence "Vector of indicies into the frame controlling order of display")
+ :prefix :type vector)
+ ((runningp "Whether this set is animating by cycling through frames")
+ :type boolean :initform t)
+ ((wait-time "Milliseconds between frames")
+ :prefix :initform (/ 1000.0 2))
+ ((count "")
+ (index "")
+ (next-time "")
+ :prefix :initform 0))
(defmethod (setf fps) (newval (fs frameset))
(setf (frameset-wait-time fs) (/ 1000.0 newval)))
diff --git a/src/interactive/image.lisp b/src/interactive/image.lisp
index 644c06e..a0fce09 100644
--- a/src/interactive/image.lisp
+++ b/src/interactive/image.lisp
@@ -4,11 +4,12 @@
(defvar *image-shader-program* nil
"Cached for later cleanup.")
+
(defvar *image-vao* nil)
-(defclass/std image (unit interactive)
- ((texture :ri :std (error "A image requires a texture."))
- (alpha :std 1.0)))
+(def:class image (unit interactive)
+ (texture :required :ro :type texture)
+ (alpha :type float :initform 1.0))
(defun make-shared-image-gpu-objects ()
(unless *image-shader-program*
diff --git a/src/interactive/interactive.lisp b/src/interactive/interactive.lisp
index 11bc5ca..74a22d1 100644
--- a/src/interactive/interactive.lisp
+++ b/src/interactive/interactive.lisp
@@ -2,10 +2,13 @@
(in-package #:wheelwork)
-(defclass/std interactive ()
- ((listener :type (or null listener) :std nil :a)
- (focusablep :std t :doc "Whether or not this object can receive application focus."))
- (:documentation "Supplies an object with a listener slot."))
+(def:class interactive ()
+ (listener :type (or null listener) :initform nil)
+
+ ((focusablep "Whether or not this object can receive application focus")
+ :type boolean :initform nil)
+
+ :documentation "Supplies an object with an event listener")
(defun remove-all-handlers (interactive)
(loop
diff --git a/src/interactive/sprite.lisp b/src/interactive/sprite.lisp
index 68f8a8d..dd9b2a1 100644
--- a/src/interactive/sprite.lisp
+++ b/src/interactive/sprite.lisp
@@ -2,9 +2,11 @@
(in-package #:wheelwork)
-(defclass/std sprite (unit interactive)
- ((framesets :with :doc "A PLIST whose values are framesets.")
- (frameset-key :with :doc "The current name of the frameset being displayed.")))
+(def:class sprite (unit interactive)
+ ((framesets "A PLIST whose values are framesets")
+ :required :prefix)
+ ((frameset-key "The name of the current frameset being displayed")
+ :required :prefix))
(defun current-frameset (sprite)
"Returns the current FRAMESET instance being displayed on SRPITE."
diff --git a/src/interactive/text.lisp b/src/interactive/text.lisp
index d79f7bf..73e25e4 100644
--- a/src/interactive/text.lisp
+++ b/src/interactive/text.lisp
@@ -2,13 +2,13 @@
(in-package #:wheelwork)
-(defclass/std text (unit interactive)
- ((font :with :ri :std (error "A font is required") :type font)
- (content :with :ri :std "")
- (color :with :std #(1.0 1.0 1.0 1.0))
- (vao elem-count newlines :r)
- (shader :with :static :r)))
-
+(def:class text (unit interactive)
+ (font :prefix :ro :required :type font)
+ (content :prefix :ro :type string :initform "")
+ ((color "RGBA values")
+ :prefix :type (vector float 4) :initform (vector 1.0 1.0 1.0 1.0))
+ (vao elem-count newlines :ro :type (unsigned-byte 32))
+ (shader :prefix :ro :allocation :class))
(defmethod model-matrix ((text text))
(let ((m (mat:meye 4)))
@@ -19,20 +19,23 @@
(* newlines text-height))
(rotation-baseline-offset
(* 2 newlines text-height )))
- (mat:nmtranslate m (vec:vec x
- (+ y
- (*
- scale-y
- baseline-offset))
- 0.0))
+ (mat:nmtranslate
+ m (vec:vec x
+ (+ y
+ (*
+ scale-y
+ baseline-offset))
+ 0.0))
- (mat:nmtranslate m (vec:v* 0.5 (vec:vec (* scale-x base-width)
- (* scale-y (- base-height rotation-baseline-offset) )
- 0.0)))
+ (mat:nmtranslate
+ m (vec:v* 0.5 (vec:vec (* scale-x base-width)
+ (* scale-y (- base-height rotation-baseline-offset) )
+ 0.0)))
(mat:nmrotate m vec:+vz+ rotation)
- (mat:nmtranslate m (vec:v* -0.5 (vec:vec (* scale-x base-width )
- (* scale-y (- base-height rotation-baseline-offset))
- 0.0))))
+ (mat:nmtranslate
+ m (vec:v* -0.5 (vec:vec (* scale-x base-width )
+ (* scale-y (- base-height rotation-baseline-offset))
+ 0.0))))
(mat:nmscale m (vec:vec scale-x scale-y 1.0))
m)))