Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
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  
  Accelerated (transparent) images once again...  (Read 930 times)
0 Members and 1 Guest are viewing this topic.
Offline KnisterPeter

Senior Newbie




Java games rock!


« Posted 2005-06-15 18:26:21 »

Hi there.
I want to load images and have them hw accelerated. I've read many tutorials, the JavaDoc and the forum topics here and think I have done everything correct, but my images are never gets accelerated.
Am I missing something? Below is my code for image loading if anyone could give me a hint:

This one is my the real image loading (my codec files):
1  
2  
            
return ImageIO.read(location);


This one manages the resource for my engine:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
        this.image = (BufferedImage) this.codec.decode(this.location);
        ImageCapabilities ic = this.image.getCapabilities(this.image
                .createGraphics().getDeviceConfiguration());
        Core.getLogger().info("Image locat: " + this.location);
        Core.getLogger().info("Image accel: " + ic.isAccelerated());
        Core.getLogger().info("Image volat: " + ic.isTrueVolatile());

        GraphicsConfiguration gc = GraphicsEnvironment
                .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getDefaultConfiguration();
        BufferedImage accelImage = gc.createCompatibleImage(this.image
                .getWidth(), this.image.getHeight(), this.image
                .getTransparency());

        Graphics2D g2 = accelImage.createGraphics();
        g2.setComposite(AlphaComposite.Src);
        g2.drawImage(this.image, 0, 0, null);
        g2.dispose();
        ic = accelImage.getCapabilities(accelImage.createGraphics()
                .getDeviceConfiguration());

        Core.getLogger().info("AccelImage locat: " + this.location);
        Core.getLogger().info("AccelImage accel: " + ic.isAccelerated());
        Core.getLogger().info("AccelImage volat: " + ic.isTrueVolatile());

But any of the debug outputs give no acceleration and no volatile on output.  Sad

Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #1 - Posted 2005-06-15 18:32:55 »

If you're transparency from the image is coming back as more than BITMASK the images won't get accelerated on most platforms (without setting certain flags).

Try setting the transparency of your created compatible image to BITMASK.

Kev

Offline KnisterPeter

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-06-15 18:49:09 »

I've tried so.
I also tried Transparency.OPAQUE
as well as setting these system properties:
sun.java2d.opengl
sun.java2d.translaccel
sun.java2d.accthreshold

But nothing has given me an accelerated image.
Not to forget: I'm using WindowsXP

Games published by our own members! Check 'em out!
Try the Free Demo of Revenge of the Titans
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #3 - Posted 2005-06-16 04:18:11 »

In order for image to get "accelerated" it needs to be copied to an accelerated surface (either
a VolatileImage or screen) several times.

Just create a scratch VolatileImage, and copy your image a couple of times onto
that image prior to checking the isAccelerated() property.

Also, if I recall correctly, there were a couple of bugs in 1.5 such that it'd always report the image
as not being accelerated =( But may be I'm confusing that with recently fixed mustang-specific bugs.

Thanks,
  Dmitri
Java2D Team
Offline KnisterPeter

Senior Newbie




Java games rock!


« Reply #4 - Posted 2005-06-16 17:40:50 »

Hmm. Either there is a bug in the isAccelerated() method as you mentioned, or my images don't get accelerated.  Sad
In my short test I load an image with ImageIO and then create a VolatileImage from the default GraphicsConfiguration.
After that I copied the BufferedImage 20 times to the VolatileImage, but the VolatileImage was not accelerated...

[Edit]: But I checked the BufferedImage wich was reported as accelerated. Thanks for your help[/Edit]

Offline KnisterPeter

Senior Newbie




Java games rock!


« Reply #5 - Posted 2005-06-16 19:01:56 »

Another addition:
I only get an accelerated transparent (translucent) image if I set translaccel to true (as documented).
But withou also specifying 'sun.java2d.accthreshold=0' I got no acceleration. Is this the normal behaviour (I use the opengl rendering pipe).
This occurs on jdk 1.5 as well as jdk 1.6-ea.

Offline Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Reply #6 - Posted 2005-06-16 19:54:45 »

yes, its a bug (don't have the ID handy).

VIs with alpha-values could be accerlated, but currently are not :-(
I think this will be fixed till mustang release..

lg Clemens
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (91 views)
2013-05-17 21:29:12

alaslipknot (100 views)
2013-05-16 21:24:48

gouessej (130 views)
2013-05-16 00:53:38

gouessej (125 views)
2013-05-16 00:17:58

theagentd (136 views)
2013-05-15 15:01:13

theagentd (123 views)
2013-05-15 15:00:54

StreetDoggy (165 views)
2013-05-14 15:56:26

kutucuk (187 views)
2013-05-12 17:10:36

kutucuk (190 views)
2013-05-12 15:36:09

UnluckyDevil (196 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.142 seconds with 20 queries.