Permalink
Browse files

Export platform specific accessors for window handle.

This may be usefull if you need to implement some sort of external
event loop.
Also fixed custom-event-loop example.
  • Loading branch information...
1 parent 323531b commit 26e4b01cf4735b72f2fc222246d19f55061471e3 @patzy patzy committed Oct 22, 2011
Showing with 27 additions and 23 deletions.
  1. +6 −1 src/package.lisp
  2. +21 −22 test/test.lisp
View
@@ -35,6 +35,11 @@
;; helper macros
#:with-window #:with-idle-forms
;; multiple windows
- #:set-gl-window))
+ #:set-gl-window
+ ;; platform-specific export for external event loop
+ #+(and unix (not darwin))#:x11-window-id
+ #+(and unix (not darwin))#:x11-window-display
+ #+(or win32 windows)#:win32-window-id
+ ))
View
@@ -123,28 +123,27 @@
(let ((win (glop:create-window "Glop test window" 800 600)))
(format t "Created window: ~S~%" win)
(gl:clear-color 0.3 0.3 1.0 0)
- (cffi:with-foreign-object (x-evt 'glop-xlib::x-event)
- (loop with running = t
- with dpy = (glop::x11-window-display win)
- for x-evt = nil
- while running
- do (when (glop-xlib::x-pending-p dpy)
- (setf x-evt (cffi:foreign-alloc 'glop-xlib::x-event))
- (glop-xlib::%x-next-event dpy x-evt))
- if x-evt
- do (let ((evt (glop-xlib::process-event win dpy x-evt)))
- (typecase evt
- (glop:key-press-event
- (when (eq (glop:keysym evt) :escape)
- (setf running nil)))
- (glop:close-event
- (setf running nil))
- (t (format t "Unhandled event: ~A~%" evt)))
- (cffi:foreign-free x-evt))
- else do (gl:clear :color-buffer)
- (gl:flush)
- (glop:swap-buffers win)))
- (glop:destroy-window win)))
+ (loop with running = t
+ with dpy = (glop::x11-window-display win)
+ for x-evt = nil
+ while running
+ do (when (glop-xlib::x-pending-p dpy)
+ (setf x-evt (cffi:foreign-alloc 'glop-xlib::x-event))
+ (glop-xlib::%x-next-event dpy x-evt))
+ if x-evt
+ do (let ((evt (glop-xlib::process-event win dpy x-evt)))
+ (typecase evt
+ (glop:key-press-event
+ (when (eq (glop:keysym evt) :escape)
+ (setf running nil)))
+ (glop:close-event
+ (setf running nil))
+ (t (format t "Unhandled event: ~A~%" evt)))
+ (cffi:foreign-free x-evt))
+ else do (gl:clear :color-buffer)
+ (gl:flush)
+ (glop:swap-buffers win))
+ (glop:destroy-window win)))
(defun test-gl-hello ()
(glop:with-window (win "Glop test window" 800 600)

0 comments on commit 26e4b01

Please sign in to comment.