本文整理了Java中java.awt.Canvas.getBufferStrategy()
方法的一些代码示例,展示了Canvas.getBufferStrategy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Canvas.getBufferStrategy()
方法的具体详情如下:
包路径:java.awt.Canvas
类名称:Canvas
方法名:getBufferStrategy
暂无
代码示例来源:origin: stackoverflow.com
canvas.createBufferStrategy(2);
do {
strategy = canvas.getBufferStrategy();
} while (strategy == null);
start();
代码示例来源:origin: org.processing/core
synchronized protected void render() {
if (canvas.isDisplayable() &&
graphics.image != null) {
if (canvas.getBufferStrategy() == null) {
canvas.createBufferStrategy(2);
}
BufferStrategy strategy = canvas.getBufferStrategy();
if (strategy != null) {
// Render single frame
// try {
do {
// The following loop ensures that the contents of the drawing buffer
// are consistent in case the underlying surface was recreated
do {
Graphics2D draw = (Graphics2D) strategy.getDrawGraphics();
// draw to width/height, since this may be a 2x image
draw.drawImage(graphics.image, 0, 0, sketchWidth, sketchHeight, null);
draw.dispose();
} while (strategy.contentsRestored());
// Display the buffer
strategy.show();
// Repeat the rendering if the drawing buffer was lost
} while (strategy.contentsLost());
}
}
}
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = this.getBufferStrategy();
if(bs == null){
this.createBufferStrategy(3);
代码示例来源:origin: stackoverflow.com
bufferStrategy = canvas.getBufferStrategy();
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = this.getBufferStrategy();
if (bs == null) {
this.createBufferStrategy(3);
代码示例来源:origin: stackoverflow.com
bufferStrategy = gameField.getBufferStrategy();
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = this.getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = c.getBufferStrategy();
Graphics g = bs.getDrawGraphics();
g.drawImage(img, 100, 100, null);
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = getBufferStrategy();
代码示例来源:origin: stackoverflow.com
BufferStrategy bufferStrategy = getBufferStrategy();
if (bufferStrategy == null) {
this.createBufferStrategy(3);
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
代码示例来源:origin: com.b3dgs.lionengine/lionengine-core-awt
/**
* Prepare windowed mode.
*
* @param output The output resolution
* @throws LionEngineException If unable to initialize windowed mode.
*/
private void initWindowed(Resolution output)
{
final Canvas canvas = new Canvas(conf);
canvas.setBackground(Color.BLACK);
canvas.setEnabled(true);
canvas.setVisible(true);
canvas.setIgnoreRepaint(true);
frame.add(canvas);
canvas.setPreferredSize(new Dimension(output.getWidth(), output.getHeight()));
frame.pack();
frame.setLocationRelativeTo(null);
ToolsAwt.createBufferStrategy(canvas, conf);
buf = canvas.getBufferStrategy();
// Set input listeners
componentForKeyboard = canvas;
componentForMouse = canvas;
componentForCursor = frame;
frame.validate();
}
代码示例来源:origin: stackoverflow.com
add(drawArea);
createBufferStrategy(2);
bufferStrategy = drawArea.getBufferStrategy();
代码示例来源:origin: stackoverflow.com
strategy = getBufferStrategy();
Graphics g = strategy.getDrawGraphics();
this.g2 = (Graphics2D) g;
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = this.getBufferStrategy();
代码示例来源:origin: org.bytedeco/javacv
@Override public void paint(Graphics g) {
// Calling BufferStrategy.show() here sometimes throws
// NullPointerException or IllegalStateException,
// but otherwise seems to work fine.
try {
if (canvas.getWidth() <= 0 || canvas.getHeight() <= 0) {
return;
}
BufferStrategy strategy = canvas.getBufferStrategy();
do {
do {
g = strategy.getDrawGraphics();
if (color != null) {
g.setColor(color);
g.fillRect(0, 0, getWidth(), getHeight());
}
if (image != null) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
}
if (buffer != null) {
g.drawImage(buffer, 0, 0, getWidth(), getHeight(), null);
}
g.dispose();
} while (strategy.contentsRestored());
strategy.show();
} while (strategy.contentsLost());
} catch (NullPointerException e) {
} catch (IllegalStateException e) { }
}
};
代码示例来源:origin: stackoverflow.com
BufferStrategy bs = getBufferStrategy();
if (bs== null){
createBufferStrategy(3);
内容来源于网络,如有侵权,请联系作者删除!