我正在尝试开发一个全屏应用程序,但我遇到了双缓冲区问题。
public void create ()
{
window = new JWindow ();
window.setIgnoreRepaint (true);
GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ().setFullScreenWindow (window);
window.setVisible (true);
window.createBufferStrategy (2);
}
public void renderCycle ()
{
BufferStrategy strategy = window.getBufferStrategy ();
while (true)
{
render ((Graphics2D) strategy.getDrawGraphics ());
strategy.show ();
}
}
public void render (Graphics2D g)
{
g.setColor (Color.WHITE);
g.drawString ("Veikia", 100, 100);
}
我看到了严重的闪烁 - 似乎文本仅在每个其他缓冲区上绘制,其余缓冲区包含白色背景。可能是什么问题呢?