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 (404)
games submitted by our members
Games in WIP (289)
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  
  2Dgraphics and sound  (Read 1405 times)
0 Members and 1 Guest are viewing this topic.
Offline sponge

Senior Newbie




Ek is Java.


« Posted 2004-05-26 19:56:56 »

Hi

I'm writing an application game, and i'm at the part where im adding graphics and sound.  So now, what would be the simplest & fastest?  I'm thinking of using AudioClip for sound (from Applet) but think I read somewhere that that has a memory leak.  Also, should it be used in a application? I've gotten it to work in a simple application but I haven't tested it in a game situation to check for slowdown.

And what is the easiest/best way to load images? currently, I'm using Toolkit.getToolkit().getImage().

Thanks..
Inquisitor
Guest
« Reply #1 - Posted 2004-05-26 21:35:07 »

Quote

And what is the easiest/best way to load images? currently, I'm using Toolkit.getToolkit().getImage().


java.imageio.ImageIO.read() is nice and easy. But as far as I know it doesn't return a managed image, so for best performance you should re-draw it to a BufferedImage created with Component.createImage() / GraphicsConfiguration.createCompatibleImage() etc.
Someone correct if i'm wrong...
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #2 - Posted 2004-05-27 19:05:35 »

You are correct for 1.4.
With Java 1.5 and up ImageIO is the best way to go as it will return managed images.
(For 1.4 you can always copy the image to a managed image before you use it.)

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sponge

Senior Newbie




Ek is Java.


« Reply #3 - Posted 2004-05-28 20:07:04 »

What is the difference between a normal image and a managed image? I read in a tuturial you're supposed to use GraphicsConfiguration.createCompatibleImage() but it didn't explain why.

Thanks for the help so far.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #4 - Posted 2004-05-29 22:42:30 »

A managed image will be copied to VRAM so it gets accelerated without you having to do anything.  It is a 'normal' image that is accelerated behind the scenes like a typical volatile image would be.

Compatible images are good because they are created in a format that doesn't require conversion to be blitted to the screen.

Some things will invalidate the JRE's ability to accelerate the image for you.. basically if you get a reference to the raster so that you might modify the image then it isn't possible for the image to be accelerated automatically.

Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #5 - Posted 2004-06-04 07:26:21 »

>I'm thinking of using AudioClip for sound (from Applet)

If there isn't a good reason... don't :>

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Sound;action=display;num=1062877058;start=1#1

The code shows a very basic way for managing/playback of samples. Well, it works and it's all you need at the beginning.

With AudioClip you have a (rather huge) delay each time a sample is played for the first time.

That piece of code there has only a delay once the very fist time one of the samples is played (because the creation of the default mixer takes some msecs). It's somewhat ignoreable. However you could fix that by creating a mixer by yourself.

弾幕 ☆ @mahonnaiseblog
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!
 
Browse for soundtracks 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 (29 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (145 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.118 seconds with 22 queries.