Skip to content

Instantly share code, notes, and snippets.

@tonyarkles
Created December 18, 2018 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyarkles/f27e69f20b2f3fb444f60c7e03398bfe to your computer and use it in GitHub Desktop.
Save tonyarkles/f27e69f20b2f3fb444f60c7e03398bfe to your computer and use it in GitHub Desktop.
(ql:quickload :sdl2)
(require :sdl2)
(require :cl-opengl)
(defun render ()
"drawing whatever happens in a frame"
(gl:clear :color-buffer)
(gl:begin :triangles)
(gl:color 0.0 1.0 0.0)
(gl:vertex 0.0 1.0)
(gl:vertex -1.0 -1.0)
(gl:vertex 1.0 -1.0)
(gl:end)
(gl:flush)
)
(defun my-test ()
"just rendering basic stuff"
(sdl2:with-init (:everything)
(sdl2:with-window (win :flags '(:shown :opengl))
(sdl2:with-gl-context (gl-context win)
(let ()
(sdl2:gl-make-current win gl-context)
(gl:viewport 0 0 800 600)
(gl:matrix-mode :projection)
(gl:ortho -2 2 -2 2 -2 2)
(gl:matrix-mode :modelview)
(gl:load-identity)
(gl:clear-color 0.0 0.0 1.0 1.0)
(gl:clear :color-buffer)
;; main loop
(format t "Beginning main loop.~%")
(finish-output)
(sdl2:with-event-loop (:method :poll)
(:keyup (:keysym keysym)
(when (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape)
(sdl2:push-event :quit)))
(:idle ()
(render)
(sdl2:gl-swap-window win))
(:quit () t))
)))))
(defun start()
(bt:make-thread (lambda () (my-test))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment