Add graphics-context class for managing SDL2 resources
This commit is contained in:
parent
24df86fa44
commit
5ce814867d
22
drawing.lisp
22
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)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user