Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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 1672 times)
0 Members and 1 Guest are viewing this topic.
Offline sponge

Senior Newbie




Ek is Java.


« Posted 2004-05-26 17: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 19: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 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




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

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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (17 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

atombrot (39 views)
2014-08-19 09:29:53

Tekkerue (36 views)
2014-08-16 06:45:27

Tekkerue (33 views)
2014-08-16 06:22:17

Tekkerue (22 views)
2014-08-16 06:20:21

Tekkerue (33 views)
2014-08-16 06:12:11

Rayexar (67 views)
2014-08-11 02:49:23

BurntPizza (45 views)
2014-08-09 21:09:32

BurntPizza (36 views)
2014-08-08 02:01:56
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

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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!