Made lesson2.factor slightly more efficient, still too slow though

cvs
Alex Chapman 2005-11-07 23:51:48 +00:00
parent 6e4c994a4e
commit 5dddb20f78
1 changed files with 11 additions and 14 deletions

View File

@ -54,9 +54,8 @@ SYMBOL: height
] keep ] keep
ExposureMask KeyPressMask bitor ButtonPressMask bitor StructureNotifyMask bitor ExposureMask KeyPressMask bitor ButtonPressMask bitor StructureNotifyMask bitor
over set-XSetWindowAttributes-event_mask over set-XSetWindowAttributes-event_mask
! dup 1 <int> swap set-XSetWindowAttributes-border_pixel dup 1 swap set-XSetWindowAttributes-border_pixel
CWColormap CWEventMask bitor swap ; CWBorderPixel CWColormap bitor CWEventMask bitor swap ;
! CWBorderPixel CWColormap bitor CWEventMask bitor swap ;
: make-display ( display-num -- display ) : make-display ( display-num -- display )
XOpenDisplay dup dpy set ; XOpenDisplay dup dpy set ;
@ -139,7 +138,6 @@ M: x-button-press-event (handle-event)
2drop f ; 2drop f ;
PREDICATE: x-key-press-event quit-key-event PREDICATE: x-key-press-event quit-key-event
! 0 XLookupKeysym XK_Escape = ;
0 XLookupKeysym dup CHAR: q = swap XK_Escape = or ; 0 XLookupKeysym dup CHAR: q = swap XK_Escape = or ;
M: quit-key-event (handle-event) M: quit-key-event (handle-event)
@ -153,18 +151,17 @@ M: object (handle-event)
#! unknown event, ignore and continue #! unknown event, ignore and continue
2drop t ; 2drop t ;
: handle-event ( glwin -- continue? ) : handle-event ( glwin xevent -- continue? )
! TODO: don't create a new XEvent object each time (but don't use a global) over gl-window-dpy over XNextEvent drop (handle-event) ;
dup gl-window-dpy <XEvent> tuck XNextEvent drop (handle-event) ;
: (loop) ( glwin -- continue? ) : (loop) ( glwin xevent -- continue? )
dup gl-window-dpy XPending 0 > [ over gl-window-dpy XPending 0 > [
dup handle-event [ (loop) ] [ drop f ] if 2dup handle-event [ (loop) ] [ 2drop f ] if
] [ drop t ] if ; ] [ 2drop t ] if ;
: loop ( glwin -- ) : loop ( glwin xevent -- )
dup (loop) [ draw-gl-scene loop ] [ drop ] if ; 2dup (loop) [ draw-gl-scene loop ] [ 2drop ] if ;
: main ( -- ) : main ( -- )
":0.0" 10 10 640 480 16 "NeHe Lesson 2" make-gl-window ":0.0" 10 10 640 480 16 "NeHe Lesson 2" make-gl-window
dup loop kill-gl-window ; dup <XEvent> loop kill-gl-window ;