Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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()
    {
        try
        {
            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);
                streams.setRepeating(false);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

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

        streams[id].reset();
        streams[id].setPan(pan);
        streams[id].setRepeating(false);
        streams[id].play();
    }
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);
g.rotate(angle);
...
g.setTransform(transform);

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

Ricky


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.

g.rotate((float)angle);
...
g.rotate(-(float)angle);

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

Cheers,

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

-Dsun.java2d.opengl=true

(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);
g.rotate(angle);

// nothing here..

g.rotate(-angle);
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!

Cheers,

Ricky

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");
            mainFrame.setVisible(true);
            mainFrame.setIgnoreRepaint(true);           
            mainFrame.createBufferStrategy(2);
            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(Component.java:3023)
   at java.awt.Component$FlipBufferStrategy.<init>(Component.java:2998)
   at java.awt.Component.createBufferStrategy(Component.java:2925)
   at java.awt.Window.createBufferStrategy(Window.java:2041)
   at java.awt.Component.createBufferStrategy(Component.java:2857)
   at java.awt.Window.createBufferStrategy(Window.java:2016)

The fullscreen code I have that works is:

            mainFrame = new JFrame(gc);
            mainFrame.setUndecorated(true);
            mainFrame.setIgnoreRepaint(true);
            device.setFullScreenWindow(mainFrame);
            if (device.isDisplayChangeSupported())
            {
                chooseBestDisplayMode(device);
            }
           
            mainFrame.createBufferStrategy(2);
            bufferStrategy = mainFrame.getBufferStrategy();

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


            mainFrame = new JFrame("title");
            mainFrame.createBufferStrategy(2);
            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?

Cheers,

Ricky

Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

BurntPizza (20 views)
2014-09-21 02:42:18

BurntPizza (14 views)
2014-09-21 01:30:30

moogie (14 views)
2014-09-21 00:26:15

UprightPath (25 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (42 views)
2014-09-12 09:08:26

Norakomi (73 views)
2014-09-10 13:57:51

TehJavaDev (97 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
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!