Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 1411 times)
0 Members and 1 Guest are viewing this topic.
Offline z.e.r.o

Junior Member




Java games rock!


« Posted 2004-03-02 08: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 Coder


Medals: 11


falling into the abyss of reality


« Reply #1 - Posted 2004-03-02 11: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 Member




If only I knew what I'm talking about!


« Reply #2 - Posted 2004-03-03 04: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 Member




Java games rock!


« Reply #3 - Posted 2004-03-03 16: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 Coder


Medals: 11


falling into the abyss of reality


« Reply #4 - Posted 2004-03-03 16: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 Member




Java games rock!


« Reply #5 - Posted 2004-03-03 19: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 Member




If only I knew what I'm talking about!


« Reply #6 - Posted 2004-03-04 02: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 Member




Java games rock!


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

Great!  Grin

Matteo Anelli
.brain - http://www.dot-brain.com
kul_th_las
Guest
« Reply #8 - Posted 2004-03-04 20:41:48 »

On the BufferedImage note, here's a link to a short article that discusses just that, and a few other Java2D notes coming in 1.5.

http://java.sun.com/j2se/1.5.0/docs/guide/2d/new_features.html
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!