Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added code for 2d-window generation #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#:define-start-function

;; window
#:window #:gl-window #:initialize-window
#:window #:gl-window #:2d-window #:initialize-window

#:sdl-window #:sdl-window-id #:gl-context #:window-from-id
#:sdl-window #:sdl-window-id #:gl-context #:renderer #:window-from-id
#:render-enabled

#:all-windows #:focused-window #:last-window
Expand Down
24 changes: 24 additions & 0 deletions src/window.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,30 @@ a cons, e.g. `(10 . 10)`."
#+nil
(format *error-output* "Unhandled event: ~S~%" (sdl2:get-event-type event)))

;;;;;; 2D-WINDOW

(defclass 2d-window (window)
((renderer :initform nil :reader renderer)))

(defmethod initialize-window progn ((window 2d-window) &key &allow-other-keys)
(with-slots (renderer sdl-window) window
(setf renderer (sdl2:create-renderer sdl-window))))

(defmethod render :before ((window 2d-window))
(with-slots (renderer) window
(sdl2-ffi.functions:sdl-render-clear renderer)))

(defmethod render :after ((window 2d-window))
(with-slots (renderer) window
(sdl2:render-present renderer)))

(defmethod close-window ((window 2d-window))
(with-slots (renderer) window
(when (and (slot-boundp window 'renderer) renderer)
(sdl2:destroy-renderer renderer)))
(call-next-method))


;;;; GL-WINDOW

(defmethod initialize-window progn
Expand Down