Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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 1205 times)
0 Members and 1 Guest are viewing this topic.
Offline KnisterPeter

Senior Newbie




Java games rock!


« Posted 2005-06-15 16: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

« JGO Spiffy Duke »


Medals: 212
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2005-06-15 16: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 16: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!
Legends of Yore - The Casual Retro Roguelike
Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #3 - Posted 2005-06-16 02: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 15: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 17: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 Devvie


Medals: 1


Java games rock!


« Reply #6 - Posted 2005-06-16 17: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.

 

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 (32 views)
2014-12-15 09:26:44

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

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

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

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

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

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

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

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

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

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