diff --git a/drawing.lisp b/drawing.lisp index a1515e8..1b71a5d 100644 --- a/drawing.lisp +++ b/drawing.lisp @@ -63,3 +63,25 @@ (defun overlay (&rest drawings) (apply #'append drawings)) + +(defclass graphics-context () + (window + renderer + (width :initarg :width :initform 800) + (height :initarg :height :initform 600))) + +(defmethod initialize-instance :after ((ctx graphics-context) &key) + (with-slots (window renderer width height) ctx + (sdl2:init) + (setf window + (sdl2:create-window :title "Simulation" + :w width :h height + :flags '(:shown))) + (setf renderer + (sdl2:create-renderer window -1 '(:accelerated :presentvsync))))) + +(defmethod cleanup ((ctx graphics-context)) + (with-slots (window renderer) ctx + (sdl2:destroy-renderer renderer) + (sdl2:destroy-window window) + (sdl2:quit)))