Transparency Problems

Hey everyone

we are currently developing a game in Java using the Java2D API and are experiencing some strange performance issues when running it in an Linux environment.
Our frame rate drops from an average of 62fps on Windows and Mac systems to about 10fps on Linux. After some hours of debugging and testing various JVM flags it seems to be that BufferedImages using a bitmask are not being accelerated under Linux.

We tested our game on different pc´s, with different hardware under Linux, and the effect stays the same. It´s an project for an university class, which has to run under Linux perfectly :frowning:

We have a some sprites on your screen, which have a lot of transparent pixels. After removing sprites and other transparent images the framerate returns to constant 60fps.
Currently we are loading our images via

img = ImageIO.read(url);

and are then creating a device compatible BufferedImage using the following method:

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

We are already using the “pmoffscreen” property.

I´ve seen that many topics about transparency problems already exists in this forum, but I didn´t really find an answer to our problem.

Has anybody an idea, what we can do, to ensure a good framerate but still using transparent images?

Thanks for reading!
I would really appreciate help :slight_smile:
Best regards
FireDragon

p.s. nice forum registration process :slight_smile:

Maybe activating the opengl pipeline may help: http://download.oracle.com/javase/6/docs/technotes/guides/2d/flags.html

What’s the performance like when you:

a) use Transparency.TRANSLUCENT (instead of BITMASK)
b) use the BufferedImage returned by ImageIO directly (instead of going through the legacy process of making it compatible)

Might be interesting comparing cpu snapshots on the different OS, using jvisualvm.exe.

Hey, first of all thanks for your answers!

I added:

-Dsun.java2d.opengl=true

but nothing changed.

[quote]What’s the performance like when you:

a) use Transparency.TRANSLUCENT (instead of BITMASK)
b) use the BufferedImage returned by ImageIO directly (instead of going through the legacy process of making it compatible)
[/quote]
When i´m unsing Transparency.TRANSCLUENT the framerate even dropps lower… The quality of the images increases but we only have now about 7 fps.

When i return the ImageIO directly, i ´ve only 2 fps! :frowning:

[quote]Might be interesting comparing cpu snapshots on the different OS, using jvisualvm.exe.
[/quote]
Here is a screenshot of a windows pc:

http://s7.directupload.net/images/110611/temp/tbm9hbsw.png

i´ll add a linux screen later

Greetings
FireDragon

I did have same problems with my java2d game. I tried everything but after a month of head banging I did get frustrated and just give up. Everything worked well with most machines but some older machines or computers with obscure graphic crad everything was just slow. Transparency also bugged somehow and colors of clouds was like at acid trip. Maybe you should test what fps you get with my game under linux enviroment. http://www.students.tut.fi/~hamala26/