Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Transparency Problems  (Read 2638 times)
0 Members and 1 Guest are viewing this topic.
Offline FireDragon

Junior Newbie





« Posted 2011-06-10 18:54:09 »

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  Sad

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

1  
img = ImageIO.read(url);


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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
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 Smiley
Best regards
FireDragon

p.s. nice forum registration process Smiley
Offline cylab

JGO Ninja


Medals: 55



« Reply #1 - Posted 2011-06-10 22:14:50 »

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

Mathias - I Know What [you] Did Last Summer!
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #2 - Posted 2011-06-10 23:03:54 »

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)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #3 - Posted 2011-06-11 00:23:17 »

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

"It's after the end of the world! Don't you know that yet?"
Offline FireDragon

Junior Newbie





« Reply #4 - Posted 2011-06-11 08:02:15 »

Hey, first of all thanks for your answers!

I added:
1  
-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)

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! Sad


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

i´ll add a linux screen later

Greetings
FireDragon
Offline pitbuller
« Reply #5 - Posted 2011-06-11 10:17:33 »

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/
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (75 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (45 views)
2014-11-29 21:32:03

toopeicgaming1999 (113 views)
2014-11-26 15:22:04

toopeicgaming1999 (100 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!