LWJGL
May 17, 2012, 02:13:47 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: OpenAL and FloatBuffer problem  (Read 4904 times)
curmoISU
Newbie
*
Posts: 11


« on: April 16, 2005, 10:44:19 »

I'm copying the sample code almost exactly but I'm having a problem.  When trying to set any sort of position I get the following error:

java.lang.IllegalArgumentException: Number of remaining buffer elements is 0, must be at least 1
   at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:177)
   at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:197)
   at org.lwjgl.openal.AL10.alListener(AL10.java:1014)


Here's the code where its failing:

    FloatBuffer sourcePos = BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f });

    /** Velocity of the source sound. */
    FloatBuffer sourceVel = BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f });

    /** Position of the listener. */
    FloatBuffer listenerPos = BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f });

    /** Velocity of the listener. */
    FloatBuffer listenerVel = BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f });

    /** Orientation of the listener. (first 3 elements are "at", second 3 are "up") */
    FloatBuffer listenerOri =
        BufferUtils.createFloatBuffer(6).put(new float[] { 0.0f, 0.0f, -1.0f,  0.0f, 1.0f, 0.0f });
   
    public void play3DSound(Sound sound, Vector3F sourcePosition, Vector3F sourceVelocityScaledDirection)
    {
       
        AL10.alListener(AL10.AL_POSITION,    listenerPos); //FAILS
        AL10.alListener(AL10.AL_VELOCITY,    listenerVel); //FAILS
        AL10.alListener(AL10.AL_ORIENTATION, listenerOri);   //FAILS
       
        AL10.alSourcei(sound.getAlSourceID(), AL10.AL_BUFFER,   sound.getAlSoundID());
        AL10.alSourcef(sound.getAlSourceID(), AL10.AL_PITCH,    1.0f          );
        AL10.alSourcef(sound.getAlSourceID(), AL10.AL_GAIN,     1.0f          );
        AL10.alSource (sound.getAlSourceID(), AL10.AL_POSITION, sourcePos     ); //FAILS
        AL10.alSource (sound.getAlSourceID(), AL10.AL_VELOCITY, sourceVel     ); //FAILS
 
        AL10.alSourcePlay(sound.getAlSourceID());
}

All of the lines marked //FAIL above will fail if put first with that buffer error.  What am I doing wrong???  I've tried in 0.95 and 0.96 with the same result.  Its like its expecting there to be 4 elements for each vector., but if I set the size of the buffers to 4, the error goes away but the sound doesnt' work.  Please help!
Logged
curmoISU
Newbie
*
Posts: 11


« Reply #1 on: April 16, 2005, 12:22:06 »

I discovered that if I .rewind() t he buffers, that error goes away.  However, I still don't hear the sound being played... ??
Logged
curmoISU
Newbie
*
Posts: 11


« Reply #2 on: April 16, 2005, 12:26:10 »

I fixed it.. When I was loading the sound file into a ByteBuffer I was forgetting to rewind it as well!  Its all fixed now!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!