私は、バッファ戦略を使用してJavaでアプリケーションを作成しています。私は私の内蔵グラフィックスで最大バッファ方式を使用する場合にのみ問題がある、それはこのエラーでクラッシュ:Javaのバッファ戦略マルチドライバ表示
Exception in thread "Thread-2" java.lang.IllegalStateException: Buffers have not been created
私はそれがクラッシュした理由は、私はAMDのビデオカードとの統合グラフィックスを使用していると考えていますつまり、2台のモニターがAMDビデオカードのグラフィックスを使用しており、1台のモニターが統合グラフィックスを使用しています。
結果的に、igpu ranモニタでアプリケーションを最大化することはできませんが、ビデオカードで動作するモニタではウィンドウを最大化できます。
Javaが私に駄目を与えている理由について説明していますか?また、ソリューションがありますので、私のigpuでモニターを最大限に活用することもできます。
これは、バッファが作成され、使用されている方法です。
サイドノート、Graphicsオブジェクトが使用されているときはいつでも、私はg.drawImage(BufferedImage, x, y, null);
private void render() {
BufferStrategy bs = this.getBufferStrategy();
if(bs == null) {
this.createBufferStrategy(3); //creation
//this being a class that implements Runnable
return;
}
Graphics g = bs.getDrawGraphics(); //bufferstrategy is converted to graphics here
g.setColor(Color.black);
g.fillRect(0, 0, mutableWidth, mutableHeight);
handler.render(g); //Graphics is transported to hundreds of objects to get displayed
g.dispose();
bs.show();
}
を使用し、私はあなたが読む必要はありません信じています
package GenRuntime;
import GenRuntime.GameObjects.Block.Block;
import GenRuntime.Handler.Handler;
import UI.UIInput.KeyInput;
import Resources.Initializer;
import java.awt.*;
import java.awt.image.BufferStrategy;
public class Game extends Canvas implements Runnable {
private static final long serialVersionUID = -240840600533728354L;
public static final int WIDTH = 800, HEIGHT = WIDTH /12 * 9;
private int mutableWidth, mutableHeight;
private int windowXLoc, windowYLoc;
private Thread thread;
private boolean running = false;
private Handler handler;
Window window;
public Game() {
handler = new Handler();
this.addKeyListener((new KeyInput(handler)));
window = new Window(WIDTH, HEIGHT, "Survior", this);
mutableHeight = HEIGHT;
mutableWidth = WIDTH;
}
public synchronized void start() {
thread = new Thread(this);
thread.start();
running = true;
}
public synchronized void stop() {
try {
thread.join();
running = false;
} catch(Exception e) {
e.printStackTrace();
}
}
public int Frames;
public void run() {
long lastTime = System.nanoTime();
double amountOfTicks = 60.0;
double ns = 1000000000/amountOfTicks;
double delta = 0;
long timer = System.currentTimeMillis();
int frames = 0;
while (running) {
long now = System.nanoTime();
delta += (now-lastTime)/ns;
lastTime = now;
while (delta >= 1) {
tick();
delta--;
}
if (running)
render();
frames++;
if(System.currentTimeMillis() - timer > 1000) {
timer += 1000;
Frames = frames;
System.out.println("FPS: " + frames);
frames = 0;
}
}
}
private void tick() {
handler.tick();
}
private void render() {
BufferStrategy bs = this.getBufferStrategy();
if(bs == null) {
this.createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.setColor(Color.black);
g.fillRect(0, 0, mutableWidth, mutableHeight);
handler.render(g);
g.dispose();
bs.show();
}
public static void main(String[] args) {
Initializer.init();
Block b = new Block();
new Game();
}
//The rest of the code is getter and setter methods. Don't worry about them
public void setSize(int width, int height) {
mutableHeight = height;
mutableWidth = width;
}
public void setSize(Dimension dim) {
mutableWidth = dim.width;
mutableHeight = dim.height;
}
public void setWindowLoc(int x, int y) {
windowXLoc = x;
windowYLoc = y;
}
public void setWindowLoc(Point p) {
windowXLoc = p.x;
windowYLoc = p.y;
}
public int getMutableWidth() {
return mutableWidth;
}
public int getMutableHeight() {
return mutableHeight;
}
public int getWindowXLoc() {
return windowXLoc;
}
public int getWindowYLoc() {
return windowYLoc;
}
}
に
-Dsun.java2d.d3d=false
を追加することによって固定されているマルチドライバの問題を持っています。 –@PaulT。更新されました –
私には不自然に見えませんが、過去に同じエラーメッセージが表示されました。おそらくこれらの[ここ](https://stackoverflow.com/questions/3435994/buffers-have-not-been-created-whilst-creating-buffers)、[ここ](https://stackoverflow.com/) 6436944/java-illegalstateexception-buffers-have-been-been-created)が役に立ちますか? –