Page Flipping and Tearing

HI,

I’m using Java 6 to do some simple physics simulation. The application is running inside as frame (not fullscreen exclusive) and I’m getting what appears to be tearing. However, the graphics configuration tells me that the offscreen buffer to which I’m drawing is using page flipping (specifically the buffer strategy is java.awt.Component$FlipSubRegionBufferStrategy…). In theory, the page flipping should be synced to vertical retrace, and I shouldn’t get any tearing, but that doesn’t seem to be the case. Any thoughts on the matter would be appreciated.

Pageflipping is not linked in any way to vsync.

You can flip a pointer to the framebuffer at any interval.

I don’t know how to get vsync in Java2D, but I suppose others do.

Page flipping in full screen is vsynched if your cards DirectDraw driver supports it and you’ve got enough graphics card memory to hold the pages.

It is impossible to vsynch “page flipping” of windows in the Win32 architecture (unlike the Amiga where you could program things to happen on a given scan-line.)

IIRC you may get vsync and page flipping if you use BufferStrategy in fullscreen exclusive mode, but even then you can’t force it. If you’re running windowed you’re out of luck.

OpenGL stuff can vsync in windowed though, so perhaps try enabling the OpenGL pipeline and see if you get lucky.

I seem to remember someone had a bit of (native) code that would give you the capability to listen for the vsync signal, even in windowed mode…

Can’t remember where I saw it now… somewhere on this forum.

Hi,

There’s some info about this here: http://www.java-gaming.org/forums/index.php?topic=14696.0

Kevin Glass has some native code to do page flipping which he gives in that link.

OrangyTang is right about page flipping, and also you must have 2 buffers or more with your BufferStrategy.

By the way, the BufferCapabilities are broken and still haven’t been fixed as far as I know so don’t rely on them to find out if you’re image is accelerated. Dmitri Trembovetski of the Java2D team pointed this out in the Java2D forum here at JGO a little while ago :). I could dig up the link if you want.

Keith

well, don’t quote me, and Dmitri definitely knows more about this then I do BUT

In a number of cases like this ist not really the Java code thats broken-- its the crappy video card maker supplied DirectDraw drivers. They lie to the Java API and the API has no way of knowing its a lie.