Any way to detect VSYNC ?

I’ve got an image scrolling application, and the timing says it has plenty of processor horsepower to do a splendid job – and it more or less does. But I can see what I think is some vague visual stutter that affects perceived smoothness.

I’m wondering if there is any way to get an interrupt from the monitor when it begins it’s raster scan from the top; commonly called VSYNC.

How is it scrolling using a canvas?
Redraws using invalidate?
On which platform do you see the stutter?

I’ve got it implemented a variety of ways. Canvas scrolling with refresh rather than invalidate (canvas is size of the entire window). I’ve also got it implemented in OpenGL which performs much better on slower machines. I see it on a fast mac, a reasonably fast windows machine, in a windows vm on the mac. All of them are pretty similar and I’d call them semi-smooth; but there is just a slight amount of visible stutter – maybe; sometimes; I think. I can’t tell if it’s a vision artifact or a real inability to refresh the screen fast enough or be in sync with the monitor raster. That’s what made me think of VSYNC as being a possible solution. Actually, now that I think about it; LED monitors don’t have VSYNC any more, do they? :slight_smile:

VSYNC isn’t going to be a solution as it isn’t available… and if I recall is based on the refresh rate of the monitor so could be any where between 60 and 240 times per second… much faster that polling software could accurately catch even if it were available

dont use refresh
invalidate will give generally better results as refresh forces the window manager to flush right then and that by itself can induce flicker & stuttering effects

Hi Ed,

The previous suggestions are all good for lowering drawing studdering on Windows and are good practices that should be tried first.

Drawing in Linux has most of the problems solved with drawing and Xojo Windows suffers from latency with drawing. Over the last couple of years there has been many great improvements that were implementations by Julian and others.

One issue that still bites me today with OpenGL and the Canvas on Windows is studdering from the mouse action. Each movement is the mouse seems to fire code in Xojo which slows down the drawing speed, and this doesn’t seem to be noticeable on Linux. If I bypass drawing code on Xojo windows (forms) then the speed is nice and fast, whereas just moving the mouse seems to cause drawing performance issues, which are differences in drawing rates which speed up and slow down and magnifies studdering. This issue has been placed in the background over the years as I have had a bunch of other work that needed to be done.

Depending on how you are drawing in Xojo Windows, there might be some studdering which will keep happening until the mouse-drawing issue is fixed with Xojo.

I remember writing directly to B000:0000 to get faster video performance on an AT.
However if you didn’t wait for horizontal retrace to be true you would get tearing on the screen and an ugly display.
I don’t remember the i/o port that had to be read but i’m sure the i/o address and chip can found.

http://www.tascl.org/uploads/4/9/3/3/49339445/2_.pdf

Motorola 6845 CRT Controller
This device provides the necessary interface to drive a raster scan
CRT.
Mode Set And Status Registers
This is a general purpose programmable I/O register. It has I/O points
which may be individually programmed. Its function in this attachment
is to provide mode selection (page 2-49 and 2-50) and color selection in
the medium resolution color graphics mode (page 2-51.)
Display Buffer
The Display Buffer resides in the CPU address space starting at
address X’B8000’. It provides 16K bytes of dynamic read/write
memory. A dual-ported implementation allows the CPU and the
graphics control unit to access this buffer. The CPU and the CRT
control unit have equal access to this buffer during all modes of
operation except in high resolution alphanumeric mode. In this mode
the CPU should access this buffer during the horizontal retrace
intervals. The CPU may however, write to the required buffer at any
time, but a small amount of display fetches will result if not during
retrace intervals.

don’t forget to double buffer and flush!!! :slight_smile: lol