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  
  Managed Image creation  (Read 1491 times)
0 Members and 1 Guest are viewing this topic.
Offline z.e.r.o

Junior Devvie




Java games rock!


« Posted 2004-03-02 07:46:33 »

I create Managed Image via the GraphicsConfiguration.createCompatibleImage()
but i concerned if my code to create managed images is robust enough:

1  
2  
3  
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();


Is this a good way to acquire a GC to create Managed Images with or I have to enumarate devices and stick with the gcs currently used by the device (is so hou can acquire the gc currently used?).

My app is passive-rendered and windowed.

The fastest way to acquire accelerated sprite images is to load an image via ImageIO (a good way to load image with alpha channels without too much hassle) and then blit the Buffered Image I obtain in a Managed BufferedImage?

This method works but is really slow!

Matteo Anelli
.brain - http://www.dot-brain.com
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #1 - Posted 2004-03-02 10:10:10 »

Component has the getGraphicsConfiguration() method.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #2 - Posted 2004-03-03 03:55:30 »

Also, enumerating GraphicsDevices/GraphicsConfigs is rather expensive, so you should avoid it during your app startup if you care about startup time.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline z.e.r.o

Junior Devvie




Java games rock!


« Reply #3 - Posted 2004-03-03 15:00:26 »

Thanks.

I was concerned about startup time but I was writing a class to manage animations & frames (it's not a component) and I want it independent from the GUI (I ditched the old code that got the GC from the JFrame of the application) so we can use it on startup (before even creating the GUI or other visual components).

Matteo Anelli
.brain - http://www.dot-brain.com
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #4 - Posted 2004-03-03 15:33:04 »

Quote
Thanks.

I was concerned about startup time but I was writing a class to manage animations & frames (it's not a component) and I want it independent from the GUI (I ditched the old code that got the GC from the JFrame of the application) so we can use it on startup (before even creating the GUI or other visual components).


hmm, whether you can do that or not, depends on how exactly the underlying code works.

Is the GraphicsConfiguration returned from a Component always the same?

for example, if you change resolution, bitdepth, or drag a Frame from 1 monitor to another, is the GraphicsConfiguration of the Frame different? (or does it return different managed Images?)

If you create a managed image from a GraphicsConfiguration obtained from GraphicsDevice [1]
and then render it to a Graphics context obtained from a Component visible on GraphicsDevice [2], will the Image still be managed?
will the rendering be corrupt?
(or will the VM crash? ;P)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline z.e.r.o

Junior Devvie




Java games rock!


« Reply #5 - Posted 2004-03-03 18:04:27 »

This is the way I should phrase my first question  Tongue

I checked a couple of examples/literacy/common practices here & there and using Local and Default devices is a common solution (even if is awesomely slow).

Expecially if what you want is only having an hardware accelerated image.

My concerns about dual display just holds (maybe I should check on hardware at University)...

The fact that BufferedImages will be always managed (even when created with new) is just corridor-talk or is confirmed for 1.5?

Matteo Anelli
.brain - http://www.dot-brain.com
Offline trembovetski

Senior Devvie




If only I knew what I'm talking about!


« Reply #6 - Posted 2004-03-04 01:54:48 »

Quote
The fact that BufferedImages will be always managed (even when created with new) is just corridor-talk or is confirmed for 1.5?


BufferedImages are managed in 1.5.

Offline z.e.r.o

Junior Devvie




Java games rock!


« Reply #7 - Posted 2004-03-04 10:53:32 »

Great!  Grin

Matteo Anelli
.brain - http://www.dot-brain.com
8: Undefined index: online
File: /home/jgo/public_html/Themes/default/Display.template.php (main sub template - eval?)
Line: 161