;; this file: ;; https://dataswamp.org/~incal/cl/general-base/gb.lisp (require :cl-opengl) (require :sdl2) (load "controller.lisp") (load "gl-incal.lisp") (load "polygon.lisp") (load "sdl2-incal.lisp") (load "triangle.lisp") (defun gb-init () (sdl2:with-init (:everything) (sdl2:with-window (win :title "A Camp Software" :flags '(:shown :opengl)) (sdl2:with-gl-context (gl-context win) (init-gl gl-context win) (let*((controllers-all (controllers-init)) (controllers (car controllers-all)) (haptic (cadr controllers-all)) (draw t) (halt 0) ) (sdl2:with-event-loop (:method :poll) (:keydown (:keysym ks) (let ((scv (sdl2:scancode-value ks)) (symv (sdl2:sym-value ks)) (modv (sdl2:mod-value ks)) ) (cond ((sdl2:scancode= scv :scancode-i) (setf halt (max 0 (decf halt)))) ((sdl2:scancode= scv :scancode-d) (incf halt)) ((sdl2:scancode= scv :scancode-p) (setf draw (not draw))) ((sdl2:scancode= scv :scancode-s) (sdl2:show-cursor)) ((sdl2:scancode= scv :scancode-h) (sdl2:hide-cursor)) ((sdl2:scancode= scv :scancode-q) (sdl2:push-event :quit)) ) (format t "key code sym mode: ~a ~a ~a~%" scv symv modv) )) (:keyup (:keysym keysym) (let ((ks (sdl2:scancode-value keysym))) (when (sdl2:scancode= ks :scancode-escape) (sdl2:push-event :quit) ))) (:mousemotion (:x x :y y :xrel xr :yrel yr :state s) (format t "mouse pos/rel [state]: ~a/~a ~a/~a [~a]~%" x xr y yr s) ) (:controllerbuttondown (:which id) (let ((h (cdr (assoc id haptic)))) (when h (sdl2:rumble-play h 1.0 100) ))) (:idle () (when draw (gl:clear :color-buffer) (draw-triangle-test) (draw-polygon-test) (gl:flush) (sdl2:gl-swap-window win) (sdl2:delay halt) )) (:quit () t) ) (controllers-deinit controllers haptic) )))))