Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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  
  Absolutely new to 3D and LWJGL... errors with SpaceInvaders  (Read 2912 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Posted 2005-08-09 07:55:50 »

Hi guys.

I am absolutely totally and in all ways green to everything 3D and LWJGL. That aside, I have nearly as much experience as you can get with Java2D and a large part of Java itself, so I'm not a noob coder in general.

In any case - I recently downloaded LWJGL, installed it on my computer, and am trying to figure it out from the feeble tutorials I've located on the net. I just downloaded Space Invaders by Kevin Glass (from CVS), put the source code into a new project, imported everything, put it all in the right folders etc. etc., and sounds do not work.

Here is the error that pops up:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Use -fullscreen for fullscreen mode
java.io.IOException: Stream closed
   at java.io.BufferedInputStream.ensureOpen(BufferedInputStream.java:120)
   at java.io.BufferedInputStream.read(BufferedInputStream.java:199)
   at java.io.DataInputStream.readInt(DataInputStream.java:443)
   at com.sun.media.sound.WaveFileReader.getFMT(WaveFileReader.java:244)
   at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:160)
   at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:710)
   at org.lwjgl.util.WaveData.create(WaveData.java:93)
   at SoundManager.addSound(SoundManager.java:153)
   at Game.initialize(Game.java:241)
   at Game.<init>(Game.java:178)
   at Game.main(Game.java:579)
Exception in thread "main" java.lang.NullPointerException
   at SoundManager.addSound(SoundManager.java:156)
   at Game.initialize(Game.java:241)
   at Game.<init>(Game.java:178)
   at Game.main(Game.java:579)


By commenting out various things and looking through the code I'm guessing that it is having some issue streaming the sound file into useable data. I have the sounds in the same folder as the images, which do work. Help would be appreciated.

I personally learn everything I know from looking at source code, so as long as I can get this to work I should be on my merry way.

PS - Is there any reason to convert my game from Java2D to OpenGL 2D? A comparatively small amount of  images can make even my G5 choke when using Java2D, and because OpenGL gives direct hardware access I assume it's faster. Is it reasonable to waste my time doing this?

Thank you very much, guys!

See my work:
OTC Software
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #1 - Posted 2005-08-09 08:29:35 »

looks like you need to add the sound files to the classpath

Offline anarchotron

Junior Devvie




...precious bodily fluids.


« Reply #2 - Posted 2005-08-09 15:23:19 »

If you want hardware acceleration and the potential to do awesome 2d visual effects very cheaply, OpenGL wins hands down over Java2D.  In fact the only reason I can think of for chosing Java2D over OpenGL is if you want to target platforms which have no OpenGL.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #3 - Posted 2005-08-09 16:42:15 »

Okay, I thought it might have something to do with classpath somewhere. Are those the things found in the "native" folder within the LWJGL download folder (ext .dylib && .jnilib)? I think I put all of them into my classpath folder to get LWJGL working at all in the first place. Do I need separate ones for OpenAL?

Thanks a lot.


Good to see OpenGL is a lot faster, because Java2D frankly sucks for making games. I'll definitely use it for things like windowed utilities and the like, but certainly not for games. Other platforms? Screw 'em.  Cool

See my work:
OTC Software
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #4 - Posted 2005-08-09 16:54:54 »

Okay, let me add a little more info on this...

I have Mac OS X, I'm using Eclipse. I read this page: http://lwjgl.org/installation.php and I think the problem might be that I don't have any file called "libopenal.dylib" I do have "openal.dylib" however. I went to download it again in case that will help.

I have all the files saved in my java extensions folder (where casspaths are normally read from) and I have also issued the command into the Run... configuration in Eclipse.

See my work:
OTC Software
Offline anarchotron

Junior Devvie




...precious bodily fluids.


« Reply #5 - Posted 2005-08-09 17:23:06 »

The wierd thing is, you must have your actual sound files, the .wav or whatever you are using, in your classpath.  I don't know why it works this way, but it does.  However, just adding the folder you run the game from to your classpath should do the trick usually.
Offline tom
« Reply #6 - Posted 2005-08-09 17:37:47 »

I have all the files saved in my java extensions folder (where casspaths are normally read from) and I have also issued the command into the Run... configuration in Eclipse.
NEVER add any lwjgl files to any of the the jre/jdk folders. It will only cause conflict when you get more than one in the classpath.

I just copy the native files to the project in the "Package Explorer" in Eclipse. That way they will be in "current directory" when the application is run. You can try doing the same with the wav files.

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #7 - Posted 2005-08-09 18:20:12 »

Predictably, none if this works.

As for never adding lwjgl into the jre folders, I'm not. It's where Mac OS X reads classpaths from. Library/Java/Extensions. There was absolutely nothing in the folder until I put these in there, and when I removed them it created errors within eclipse, even if I added them directly to the package explorer. Putting the sounds directly into the package explorer does not work because I already have them in there.

As for adding the wav files to my classpath, what exactly do you mean by this? Like put them in the same place as the lwjgl jar's or what? Is OpenAL that annoying that you can't reference a folder from where the executing is like with normal Java sound? It looks like you should be able to from how Kevin Glass coded this...

See my work:
OTC Software
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #8 - Posted 2005-08-09 18:41:34 »

I don't know if Eclipse handles this differently on Mac, but I usually use  -Djava.library.path="PathToLWJGLFiles" in the VM arguments bit of an Eclipse Run... config. Then you can add the dir with your resources (sounds etc.) under the classpath bit of the run config.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline tom
« Reply #9 - Posted 2005-08-09 23:09:24 »

As for adding the wav files to my classpath, what exactly do you mean by this? Like put them in the same place as the lwjgl jar's or what? Is OpenAL that annoying that you can't reference a folder from where the executing is like with normal Java sound? It looks like you should be able to from how Kevin Glass coded this...

This has nothing to do with OpenAL, but getting a file using the class loader. Don't think it goes threw all the classpaths, and the files is not picked up. Or the files is not where they should be.

Can you post a link to the tutorial. The 104 tutorials I found on google (www.cokeandcode.com) don't contain any sound.

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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #10 - Posted 2005-08-12 05:29:03 »

I got it from LWJGL's source forge.
http://cvs.sourceforge.net/viewcvs.py/java-game-lib/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/#dirlist

Unless people are interested in this for academic purposes, don't worry about it anymore. I'm just going through the Nehe tutorials instead at this point.

Thanks for all the help.

See my work:
OTC Software
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.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (75 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (45 views)
2014-11-29 21:32:03

toopeicgaming1999 (113 views)
2014-11-26 15:22:04

toopeicgaming1999 (100 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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