Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java Sound & OpenAL / Problem with Audiere repeating sounds.. on: 2005-09-21 07:36:17
Hey folks,

I'm using Audiere under java, and my sounds seem to be repeating, even though I'm telling them not to.

If I call .setRepeating(true) on the streams, they loop 'tightly', i.e. as soon as the sound ends, it starts again. But when I call setRepeating(false), the loop is different - there's a gap of about a second between repeats.

Anyone experienced this problem?

My code is here:

    public static OutputStream[] streams;

    public static void init()
            AudioDevice device = new AudioDevice();
            streams = new OutputStream[SOUND_FILES.length];
            for (int i=0; i<SOUND_FILES.length; i++)
                streams = device.openSound("res/"+SOUND_FILES+".ogg", true);
        catch (Exception e)

    public static void playSound(int id, int worldX)
        float pan = (worldX - cameraX) / WORLDWIDTH;
        if (pan < 0) pan = 0;
        else if (pan > 1) pan = 1;

2  Java Game APIs & Engines / Java 2D / Re: minimizing image bit depth and resolution for better performance? on: 2005-09-13 19:34:28
Marvellous!  That fix works - thanks Dmitri.

I now have:

AffineTransform transform = g.getTransform();
g.translate(x, y);

.. and I'm back in the wonderful world of 60fps. I'm guessing this way is also slightly more optimal.

For reference, the values causing the trouble were:

0.41887902047863906 (Math.toRadians(24))
6.073745796940266 (Math.toRadians(348))
1.4311699866353502 (Math.toRadians(82)).

Thanks for the help. I've downloaded Mustang - will check it out soon


3  Java Game APIs & Engines / Java 2D / Re: minimizing image bit depth and resolution for better performance? on: 2005-09-13 15:29:23
This sounds pretty plausible, and it reminded me of the last thing I did in desperation last night before going to bed - I tried casting my double to a float, i.e.


This seemed to have the effect of changing the angles for which the slow-down occured (so angles which previously were fine now caused problems, and angles which were slow were now fine).

I'll try your suggestion this evening, and check out mustang too..


4  Java Game APIs & Engines / Java 2D / Re: minimizing image bit depth and resolution for better performance? on: 2005-09-13 14:34:56
Well, I'm doing this in Eclipse's 'VM arguments' :


(And I've also tried -Dsun.java2d.d3d=true)

Does that not enable the gl pipe?

Like I say, I'm doing g.rotate all over the shop, without any framerate dropout - it's just this one instance that causes problems, and even then only with certain angles.

And it still slows down even if I *don't* blit (just rotate).

I'll try to isolate it as some test code if possible.
5  Java Game APIs & Engines / Java 2D / Re: minimizing image bit depth and resolution for better performance? on: 2005-09-13 09:52:22
Hmm, no, I didn't think so.

My card is a Radeon9800, so perhaps background tasks are hurting me, yes

Also, I'm running it through Eclipse. I'll have to kill as much as I can and see how it does then.

As for my fullscreen framerate, that was actually my next point of investigation last night. I have a bunch of objects (well, okay, they're caterpillars), crawing along an undulating 2D landscape made of straight line segments. In their paint method, I call g.rotate(angle) ... paint ... g.rotate(-angle), to paint the caterpillars rotated to the angle of the line they're currently on.

The totally weird thing is that if I have only one caterpillar, I get 60fps a lot of the time, *until* he hits particular line segments, and thus his angle is set to certain  values (seemingly greater than 6 radians, and less than 0.5 radians). Then, with these angles,  the framerate falls to more like 30-40fps (so when I have a bunch of caterpillars, the chances are the framerate stays low most of the time).

Even weirder - this still happens even if I don't paint anything of the caterpillar, i.e.

g.translate(catx, caty);

// nothing here..

g.translate(-catx, -caty);

Oh, and I'm calling g.rotate all over the place elsewhere in my game, and it seems to cope fine with all those cases - it's just this one that causes the drop.

I realise that this is perhaps too weird to get a simple answer for. I'll have to try to isolate it as a test case, but my concern is that maybe it's happening only in combination with all the other stuff I'm painting - kind of a final-straw scenario.

Any wild speculation folks have would be appreciated anyway!



6  Java Game APIs & Engines / Java 2D / Re: minimizing image bit depth and resolution for better performance? on: 2005-09-13 01:45:27
Ah cool - that works!

I now have:

            mainFrame = new JFrame("title");
            bufferStrategy = mainFrame.getBufferStrategy();

I get only about half the FPS running in windowed mode, versus fullscreen mode (~20 a second versus ~ 40). Does this sound normal?
7  Java Game APIs & Engines / Java 2D / Re: minimizing image bit depth and resolution for better performance? on: 2005-09-13 00:13:45
Hey folks,

In this thread, a few people (Abuse and Dmitri) seem to imply that it's possible to get hardware acceleration using a BufferStrategy in Windowed Mode (good for debug)..

I'm trying to do this, and I get a runtime Exception:

java.lang.IllegalStateException: Component must have a valid peer
   at java.awt.Component$FlipBufferStrategy.createBuffers(
   at java.awt.Component$FlipBufferStrategy.<init>(
   at java.awt.Component.createBufferStrategy(
   at java.awt.Window.createBufferStrategy(
   at java.awt.Component.createBufferStrategy(
   at java.awt.Window.createBufferStrategy(

The fullscreen code I have that works is:

            mainFrame = new JFrame(gc);
            if (device.isDisplayChangeSupported())
            bufferStrategy = mainFrame.getBufferStrategy();

.. and the windowed code that doesn't is:

            mainFrame = new JFrame("title");
            bufferStrategy = mainFrame.getBufferStrategy(); 

.. and it throws the Exception on the second line (mainFrame.createBufferStrategy(2)Wink

I remember reading somewhere that the frame the BufferStrategy is created from needs to be 'undecorated', but if I call mainFrame.setUndecorated(true) after I construct it, it doesn't seem to make any difference.

Any ideas?



Pages: [1]
bilznatch (21 views)
2015-08-04 11:03:17

SHC (39 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (45 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (41 views)
2015-07-25 00:14:37

BurntPizza (51 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
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

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!