Shouldn't triple buffering and Canvas be an optimal solution for passive rendering? I've just wrote this java code that displays a circle. If I leave bufferstrategy to 3, it flickers so much. If I turn it down to 2 or 1 it's ok. Maybe I'm doing something wrong?
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();
}
and this is the JFrame class where I put the 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();
}
}