Note that there are some explanatory texts on larger screens.

plurals
  1. POJava2D: BufferedImage not accelerated on Ubuntu
    primarykey
    data
    text
    <p>We are currently developing a game in Java using the Java2D API and are experiencing some strange performance issues when running it in an Ubuntu environment.</p> <p>Our frame rate drops from an average of 62fps on Windows and Mac systems to about 10fps on Ubuntu. After some hours of debugging and testing various JVM flags it seems to be that BufferedImages using a bitmask are not being accelerated under Ubuntu because</p> <pre><code>System.out.println(img.getCapabilities(config).isAccelerated()); </code></pre> <p>prints out false.</p> <p>Currently we are loading our images via</p> <pre><code>img = ImageIO.read(url); </code></pre> <p>and are then creating a device compatible BufferedImage using the following method:</p> <pre><code>private static BufferedImage createCompatibleImage(BufferedImage img) { // Get default graphics device GraphicsDeviceService graphicsDevice = ServiceProvider .getService(GraphicsDeviceService.class); GraphicsConfiguration config = graphicsDevice .getGraphicsConfiguration(); // Get desired transparency mode int transparency = img.getColorModel().hasAlpha() ? Transparency.BITMASK : Transparency.OPAQUE; // Create device compatible buffered image BufferedImage ret = config.createCompatibleImage(img.getWidth(), img.getHeight(), transparency); // Draw old image onto new compatible image Graphics2D graphics = ret.createGraphics(); graphics.drawImage(img, 0, 0, null); graphics.dispose(); // Return compatible image return ret; } </code></pre> <p>When creating compatible BufferedImages using the Transparency.OPAQUE, flag the first line of code above prints out true, which indicates that the image is now accelerated and the frame rate seems to be back at normal.</p> <p>However this is of course not our desired solution since the images get drawn without any transparency at all and instead have ugly black backgrounds. </p> <p>So, does anyone know a solution to this problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload