Xin chào tất cả mọi người Tôi hy vọng ai đó có thể giúp tôi giải quyết vấn đề này. Tôi gặp sự cố khi tăng tốc phần cứng để hoạt động trên máy tính xách tay với Đồ họa tích hợp Intel.Tăng tốc phần cứng Java không hoạt động với Đồ họa tích hợp Intel
Vấn đề:
Tăng tốc phần cứng sử dụng Java 7 update 11 không xuất hiện để được làm việc với Intel Integrated Graphics trên 7 và 8 máy tính Windows sử dụng một BufferStrategy với một JFrame.
Chi tiết
Card đồ họa: Intel (R) HD Graphics 4000
JRE: Java 7 Update 11
Hệ điều hành: Windows 7, Windows 8
Dự kiến kết quả
Kết quả thực tế
Tài
Nếu bạn muốn xác minh các vấn đề bạn có thể tải các ứng dụng tôi đã tạo cho thử nghiệm tại địa chỉ: http://ndcubed.com/downloads/GraphicsTest.zip
Nếu bạn don Không cảm thấy thoải mái khi tải xuống tệp JAR đã biên dịch, bạn có thể tự biên dịch ứng dụng bằng cách sử dụng mã nguồn sau:
package graphicstest;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferStrategy;
public class GraphicsTest extends JFrame {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new GraphicsTest();
}
});
}
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
BufferCapabilities bufferCapabilities;
BufferStrategy bufferStrategy;
int y = 0;
int delta = 1;
public GraphicsTest() {
setTitle("Hardware Acceleration Test");
setSize(500, 300);
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true);
createBufferStrategy(2);
bufferStrategy = getBufferStrategy();
bufferCapabilities = gc.getBufferCapabilities();
new AnimationThread().start();
}
class AnimationThread extends Thread {
@Override
public void run() {
while(true) {
Graphics2D g2 = null;
try {
g2 = (Graphics2D) bufferStrategy.getDrawGraphics();
draw(g2);
} finally {
if(g2 != null) g2.dispose();
}
bufferStrategy.show();
try {
Thread.sleep(16);
} catch(Exception err) {
err.printStackTrace();
}
}
}
}
public void draw(Graphics2D g2) {
if(!bufferCapabilities.isPageFlipping() || bufferCapabilities.isFullScreenRequired()) {
g2.setColor(Color.black);
g2.fillRect(0, 0, getWidth(), getHeight());
g2.setColor(Color.red);
g2.drawString("Hardware Acceleration is not supported...", 100, 100);
g2.setColor(Color.white);
g2.drawString("Page Flipping: " + (bufferCapabilities.isPageFlipping() ? "Available" : "Not Supported"), 100, 130);
g2.drawString("Full Screen Required: " + (bufferCapabilities.isFullScreenRequired() ? "Required" : "Not Required"), 100, 160);
g2.drawString("Multiple Buffer Capable: " + (bufferCapabilities.isMultiBufferAvailable() ? "Yes" : "No"), 100, 190);
} else {
g2.setColor(Color.black);
g2.fillRect(0, 0, getWidth(), getHeight());
g2.setColor(Color.white);
g2.drawString("Hardware Acceleration is Working...", 100, 100);
g2.drawString("Page Flipping: " + (bufferCapabilities.isPageFlipping() ? "Available" : "Not Supported"), 100, 130);
g2.drawString("Full Screen Required: " + (bufferCapabilities.isFullScreenRequired() ? "Required" : "Not Required"), 100, 160);
g2.drawString("Multiple Buffer Capable: " + (bufferCapabilities.isMultiBufferAvailable() ? "Yes" : "No"), 100, 190);
}
y += delta;
if((y + 50) > getHeight() || y < 0) {
delta *= -1;
}
g2.setColor(Color.blue);
g2.fillRect(getWidth()-50, y, 50, 50);
}
}
Kết luận
Nếu không có khả năng tăng tốc phần cứng rất nhiều ứng dụng mà tôi đã tạo đòi hỏi nó chạy chậm trên máy với đồ họa tích hợp. Nó thực sự bối rối với tôi tại sao nó không hoạt động đặc biệt với loại card đồ họa này. Dù sao cảm ơn bạn đã đọc tất cả điều này hy vọng chúng tôi có thể nhận được để dưới cùng của điều này :)!
Cảm ơn bạn đã đăng bài như vậy! – UDPLover