I’ve recently come across an interesting phenomenon on Windows while creating a display class for 2D rendering.
If you use the following code to set a JFrame as the fullscreen window natively:
GraphicsDevice d = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (d.isFullScreenSupported()) {
d.setFullScreenWindow(frame);
at least on my system, it causes the graphics driver to engage VSync on Java’s rendering. I know this because when I removed the FPS cap to check overall performance, it never went over 60 until I disabled the above code and tried a screen sized JFrame instead.
It looks damn good too. Not a single jitter or break in the animations. 100% smooth rendering.
A few things to consider:
I am using the Direct3D Java properties:
sun.java2d.d3d=true
sun.java2d.noddraw=false
sun.java2d.accthreshold=0
and the infinite sleeping thread (hi-res timer) hack.
My graphics driver is in fact set to always enforce VSync (that’s how I’ve gotten the best performance in games) on 3D applications, so I wouldn’t necessarily expect this to work on PCs that don’t have that setting.
Some system specs:
OS: Windows 7
CPU: i7-3770
GPU: NVidia GeForce GTX-560 GC (factory overclocked) 2GB VRAM
RAM: 16GB
Forgive me if this is some kind of old-as-the-hills common knowledge. I thought it was pretty interesting. Has anyone else ever noticed this and/or can you confirm it on your system?