Excluding only the mouse events from triggering a refresh would probably
be the most elegant solution.
My canvas should only ever listen to a timer, though, so they might as
well share some insider information:
#lang racket/gui
(require sgl)
(define c%
(class canvas%
(inherit with-gl-context swap-gl-buffers refresh)
(define asked-nicely? #f)
(define (please) (set! asked-nicely? #t))
(define (thank-you) (set! asked-nicely? #f))
(define/public (please-refresh)
(please)
(refresh))
(define/override (on-paint)
(when asked-nicely?
(with-gl-context
(lambda ()
(gl-clear-color (random) (random) (random) 1)
(gl-clear 'color-buffer-bit)
(swap-gl-buffers)
(gl-flush)))
(thank-you)))
(super-new (style '(gl)))))
(define t%
(class timer%
(define/override (notify)
(send c please-refresh))
(super-new)))
(define f (new frame% [label ""] [width 100] [height 100]))
(define c (new c% [parent f]))
(define t (new t% [interval 1000]))
(send f show #t)
On 12.02.13 20:04, Robby Findler wrote:
Could you work around this by tracking mouse movements and, when you
see a refresh call that comes with a mouse movement doing something
different than drawing? (I guess you'd need to set a timer that
expired in a short time and refresh then, just in case it was a "real"
refresh, but at least you could work around the performance issue.)
Robby
On Tue, Feb 12, 2013 at 1:02 PM, Robby Findler
<ro...@eecs.northwestern.edu <mailto:ro...@eecs.northwestern.edu>> wrote:
I was using os x 10.7.5 (and saw the same flashing).
On Tue, Feb 12, 2013 at 12:59 PM, Philipp Dikmann
<phil...@dikmann.de <mailto:phil...@dikmann.de>> wrote:
The OS here is Mac OS 10.6.8, running Racket 5.3.1 -
so I guess its an issue with the OpenGL implementation.
Thanks for taking a look, though :)
On 12.02.13 19:37, Michael Wilber wrote:
Your OpenGL example still doesn't flash for me when I move
the mouse
over it, on 64-bit linux.
It does, however, flash when I change window focus... for
some reason?
What OS are you using?
Philipp Dikmann <phil...@dikmann.de
<mailto:phil...@dikmann.de>> writes:
I'm sorry, I should have been more specific – it
happens when using a
gl-enabled canvas (example below).
I hope that does not turn it into a dragons' den? ;)
Philipp
#lang racket/gui
(require sgl)
(define c%
(class canvas%
(inherit with-gl-context swap-gl-buffers)
(define/override (on-paint)
(with-gl-context
(lambda ()
(gl-clear-color (random) (random) (random) 1)
(gl-clear 'color-buffer-bit)
(swap-gl-buffers)
(gl-flush))))
(super-new (style '(gl no-autoclear)))))
(define f (new frame% [label ""] [width 100] [height
100]))
(define c (new c% [parent f]))
(send f show #t)
On 11.02.13 22:39, Robby Findler wrote:
I don't think it does that. The program below, at
least for me,
doesn't do crazy colors when I move the mouse
around (it does when
resizing, tho).
Robby
#lang racket/gui
(define c%
(class canvas%
(inherit get-client-size get-dc)
(define/override (on-paint)
(define-values (w h) (get-client-size))
(define dc (get-dc))
(define c (make-object color% (random 255)
(random 255) (random
255)))
(send dc set-brush c 'solid)
(send dc set-pen "black" 1 'transparent)
(send dc draw-ellipse 0 0 w h))
(super-new)))
(define f (new frame% [label ""] [width 100]
[height 100]))
(define c (new c% [parent f]))
(send f show #t)
On Mon, Feb 11, 2013 at 9:41 AM, Philipp Dikmann
<phil...@dikmann.de <mailto:phil...@dikmann.de>
<mailto:phil...@dikmann.de
<mailto:phil...@dikmann.de>>> wrote:
It appears that the GUI canvas% refreshes
itself whenever it
receives a mouse-event%.
I intend to refresh the canvas at a steady
pace (using a timer%)
and independently of any mouse-events instead.
Is there a reasonable way to suppress the
default behavior?
Thanks for your time,
Philipp
____________________
Racket Users list:
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users