Java硬件加速不适用于英特尔集成显卡 [英] Java Hardware Acceleration not working with Intel Integrated Graphics

查看:318
本文介绍了Java硬件加速不适用于英特尔集成显卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我希望有人可以帮我解决这个问题。我在使用英特尔集成显卡的笔记本电脑上进行硬件加速时遇到了麻烦。

Hi everyone I hope someone can help me solve this problem. I'm having trouble getting hardware acceleration to work on a laptop with Intel Integrated Graphics.

使用Java 7更新11的硬件加速似乎不适用于使用带有JFrame的BufferStrategy的Windows 7和8计算机上的英特尔集成显卡。

Hardware Acceleration using Java 7 update 11 doesn't appear to be working with Intel Integrated Graphics on a Windows 7 and 8 machine using a BufferStrategy with a JFrame.

图形卡:英特尔(R)HD Graphics 4000

JRE:Java 7 Update 11 < br $> b $ b操作系统:Windows 7,Windows 8

Graphics Card: Intel(R) HD Graphics 4000
JRE: Java 7 Update 11
OS: Windows 7, Windows 8

如果你想验证问题你可以下载ap我创建的测试位置为: http://ndcubed.com/downloads/GraphicsTest.zip


如果您不方便下载已编译的JAR文件,可以使用以下源代码自行编译应用程序:

If you want to verify the problem you can download the app I created for testing at: http://ndcubed.com/downloads/GraphicsTest.zip

If you don't feel comfortable downloading a compiled JAR file you can compile the app yourself using the following source code:

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);
    }
}



结论



如果没有硬件加速,我创建的许多应用程序需要它在集成显卡的机器上运行缓慢。我真的很困惑,为什么它不专门使用这种类型的显卡。无论如何,谢谢你阅读所有这些希望我们可以到底这个:)!

Conclusions

Without hardware acceleration a lot of apps that I've created that require it run slowly on the machine with Integrated Graphics. Its really baffling to me why its not working specifically with this type of graphics card. Anyway thank you for reading all this hopefully we can get to the bottom of this :)!

推荐答案

我只是想出来的任何有同样问题的人。这是安装的JRE类型。我在64位机器上安装了32位JRE环境,由于某种原因它没有使用集成的英特尔图形芯片。但是,在安装适当的64位JRE后,页面翻转和硬件加速可与英特尔集成芯片一起使用。

I just figured it out for anyone who is having this same issue. It was the type of JRE installed. I had the 32bit JRE environment installed on a 64bit machine and for some reason it wasn't utilizing the integrated Intel graphics chip. However after installing the appropriate 64bit JRE, page flipping and hardware acceleration work with the Intel integrated chip.

您可以在以下位置下载其他版本的JRE: http://www.oracle.com/technetwork/java/javase/downloads/ jre7-downloads-1880261.html

You can download other versions of the JRE at: http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html

真的很奇怪我不敢相信我偶然发现了答案。希望这可以帮助将来的某个人:)

Really strange can't believe I stumbled upon the answer. Hope this helps someone in the future :)

这篇关于Java硬件加速不适用于英特尔集成显卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆