Skip to content

Commit

Permalink
Don't require the 4.3 context for the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Apr 6, 2024
1 parent 8ca9245 commit 784d750
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/gpu-particle.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(define-example gpu-particle
:title "GPU Particle Simulation"
:superclasses (particle-scene)
:test (gl-extension-p :gl-arb-compute-shader)
(gl:clear-color 0 0 0 0)
(enter (make-instance 'display-controller) scene)
(enter (make-instance 'gpu-particle-emitter
Expand Down
13 changes: 9 additions & 4 deletions examples/trial-examples.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(defclass example (org.shirakumo.fraf.trial.harmony:settings-main)
((paused-p :initform NIL :accessor paused-p))
(:default-initargs :clear-color (vec 0.13 0.15 0.1)
:context '(:vsync T :version (4 3))))
:context '(:vsync T :version (3 3))))

(defmethod initialize-instance ((main example) &key example)
(when example
Expand Down Expand Up @@ -98,7 +98,7 @@
(setup-ui scene panel))

(defmacro define-example (name &body body)
(form-fiddle:with-body-options (body options title (scene-class (trial::mksym #.*package* name '-scene)) slots superclasses) body
(form-fiddle:with-body-options (body options title (scene-class (trial::mksym #.*package* name '-scene)) slots superclasses (test T)) body
(assert (null options))
`(progn
(pushnew ',name *examples*)
Expand All @@ -116,6 +116,9 @@
,@body
scene)

(defmethod available-p ((example (eql ',name)))
,test)

(defmethod change-scene ((main example) (scene (eql ',name)) &key (old (scene main)))
(change-scene main (make-instance ',scene-class) :old old))

Expand All @@ -131,8 +134,10 @@
(let ((layout (make-instance 'alloy:vertical-linear-layout))
(focus (make-instance 'alloy:vertical-focus-list)))
(dolist (example (sort (list-examples) #'string< :key #'title))
(make-instance 'alloy:button* :value (title example) :layout-parent layout :focus-parent focus
:on-activate (lambda () (change-scene +main+ example))))
(if (available-p example)
(make-instance 'alloy:button* :value (title example) :layout-parent layout :focus-parent focus
:on-activate (lambda () (change-scene +main+ example)))
(v:info :trial.examples "The example ~a is not available on your system." example)))
(alloy:finish-structure list layout focus)))

(defmethod setup-scene ((main example) (scene scene))
Expand Down
4 changes: 3 additions & 1 deletion package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,9 @@
#:infer-swizzle-channels
#:infer-pixel-type
#:pixel-type->cl-type
#:when-gl-extension)
#:gl-extension-p
#:when-gl-extension
#:gl-extension-case)
;; transforms.lisp
(:export
#:*view-matrix*
Expand Down

0 comments on commit 784d750

Please sign in to comment.