Hi
Two problems with a program as trivial as actively rendering a “hello” string on the canvas. First, BufferStrategy.contentsLost() always returns true
try {
//boolean contentsLost = bufferStrategy.contentsLost();
boolean contentsLost = bufferStrategy.contentsLost()
&& !bufferStrategy.contentsRestored();
contentsLost = false;
if (contentsLost && !renderer.onContentsLost()) {
return;
}
while (!renderer.update())
;
if (contentsLost) {
return;
}
Graphics g = bufferStrategy.getDrawGraphics();
//Graphics g = getGraphics();
if (null != g) {
renderer.render(g);
g.dispose();
}
} finally {
bufferStrategy.show();
}
Second, when the rendering canvas was added to the containing frame, layout management seems take no effect, and the canvas shrinks into itself at the top left corner of the frame. Did I missed anything?
Thanks in advance!