As I see it there are 2 independant issues here :-
-
Is it technically possible to have an un-vsynced page flip?
-
Does bufferStrategy.show() have to block when using a 2 page vsynced flipping strategy?
I don’t know the answer to either of those questions,
but if 1) isn’t possible, and 2) has to block, then there is nothing wrong with the current api. (apart from the lack of windowed mode (blit strategy) vsync)
If 1) is possible, then we need capability to specify whether we want vsync’ed strategy or not.
and if 2) doesn’t have to block, then we need a way of specifying whether we want it to block or not.
(perhaps bs.show(boolean block))
[going off on a tangent]
hmm, thinking further, I can see why bs.show() blocks.
If it didn’t, when you came to render the next frame, you would potencially be rendering onto the front buffer (if the previous refresh hadn’t completed yet)
However, this could be avoided, by making getDrawGraphics() the blocking call (if the buffer page you want a context onto is currently the front page, block)
This would be advantageous in most game loops, as you would be able to do the physics for the next frame and then block when you come to render it, rather than blocking at the end of the previous frames render.
while(true)
{
doPhysics();
render(bufferStrategy.getDrawGraphics());
bufferStrategy.show();
}
at the moment the above code when using a vsynced 2 page flipping strategy would behave like this :-
loop
{
doPhys
render
block until next vblank.
change video pointer
}
If you made getDrawGraphics() the blocking call, the behaviour would be :-
loop
{
doPhys
block if vblank hasn’t occured yet
render
change video pointer
}
Because you would potencially spend less time blocking, you would increase the maximum throughput in situations of high load(basically iron out any fps stutters). In the best case scenario, you would get the entire doPhys code executed for free!
I don’t know if this technique is possible though…
as I don’t know exactly what bs.show() has to do to cause a page flip.
(does it change the video pointer, then block until the gfx card says ‘vblank’,
or does it wait for the gfx card to say ‘vblank’ and then change the video pointer.
If its the later, then you can scrub this [going off on a tangent] bit, as it simply can’t work ^_^)
[/going off on a tangent]