potrójne migotanie dużego bufora
Czy potrójne buforowanie i Płótno nie powinny być optymalnym rozwiązaniem dla pasywnego renderowania? Właśnie napisałem ten kod java, który wyświetla okrąg. Jeśli zostawię bufferstrategy na 3, miga tak bardzo. Jeśli ustawię go na 2 lub 1, jest OK. Może robię coś źle?
public void run(){
while (running){
update();
draw();
}
}
public void update(){
}
public void draw(){
BufferStrategy bs = getBufferStrategy();
if (bs==null){
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.setColor(Color.BLACK);
g.fillOval(30, 30, 20, 20);
g.dispose();
bs.show();
}
i to jest klasa JFrame, w której umieściłem Canvas
public class Game {
public static void main (String [] args){
Pan game = new Pan();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(true);
frame.add(game);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
game.start();
}
}