implement GL screen sync for Cocoa canvases

This commit is contained in:
Matthew Flatt 2015-10-18 17:49:32 -06:00
parent 8bfd1bb25e
commit 4daafb2357
3 changed files with 8 additions and 7 deletions

View File

@ -6,7 +6,7 @@
"data-lib"
["base" #:version "6.2.900.17"]
"syntax-color-lib"
["draw-lib" #:version "1.9"]
["draw-lib" #:version "1.10"]
"snip-lib"
"wxme-lib"
"pict-lib"

View File

@ -383,7 +383,9 @@
(define/override (get-cocoa-content) content-cocoa)
(define is-gl? (and (not is-combo?) (memq 'gl style)))
(define want-sync-gl? (and is-gl? gl-config (send gl-config get-sync-swap)))
(define/public (can-gl?) is-gl?)
(define/public (sync-gl?) want-sync-gl?)
(define dc #f)
(define blits null)

View File

@ -51,14 +51,13 @@
(define/override (do-swap-buffers)
(tellv gl-ctx flushBuffer))
(super-new)))])
;; Disable screen sync for GL flushBuffer; otherwise,
;; By default, disable screen sync for GL flushBuffer; otherwise,
;; flushBuffer can take around 10 msec depending on the timing
;; of event polling, and that can be bad for examples like gears.
;; Maybe whether to sync with the screen should be a configuration
;; option, but I can't tell the difference on my screen.
(tellv gl-ctx setValues:
#:type (_ptr i _long) 0
forParameter: #:type _int NSOpenGLCPSwapInterval)
(unless (send canvas sync-gl?)
(tellv gl-ctx setValues:
#:type (_ptr i _long) 0
forParameter: #:type _int NSOpenGLCPSwapInterval))
(set! gl g)
g)))))