Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (612)
Games in Android Showcase (172)
games submitted by our members
Games in WIP (659)
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 1933 times)
0 Members and 1 Guest are viewing this topic.
Offline sponge

Senior Newbie

Ek is Java.

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


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().

« Reply #1 - Posted 2004-05-26 19:35:07 »


And what is the easiest/best way to load images? currently, I'm using Toolkit.getToolkit().getImage(). 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

Exp: 12 years

Where's the Kaboom?

« Reply #2 - Posted 2004-05-27 17: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 18: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

Exp: 12 years

Where's the Kaboom?

« Reply #4 - Posted 2004-05-29 20: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: 2

pixels! :x

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

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

If there isn't a good reason... don't :>;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.

afikri (12 views)
2015-08-31 09:30:22

afikri (19 views)
2015-08-31 09:30:07

afikri (9 views)
2015-08-31 09:27:24

afikri (13 views)
2015-08-31 09:26:40

Roquen (16 views)
2015-08-29 11:30:54

GamerC4 (30 views)
2015-08-22 20:38:50

GamerC4 (26 views)
2015-08-22 20:37:18

GamerC4 (30 views)
2015-08-22 20:37:01

Kefwar (39 views)
2015-08-22 18:07:24

GamerC4 (26 views)
2015-08-22 01:00:24
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 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‑
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!