Skip to content

Commit

Permalink
refactored and upgraed lwjgl3 module.
Browse files Browse the repository at this point in the history
  • Loading branch information
JavaSaBr authored and Nehon committed Feb 26, 2018
1 parent 28353cf commit 555a348
Show file tree
Hide file tree
Showing 17 changed files with 998 additions and 811 deletions.
2 changes: 1 addition & 1 deletion jme3-lwjgl3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if (!hasProperty('mainClass')) {
ext.mainClass = ''
}

def lwjglVersion = '3.1.2'
def lwjglVersion = '3.1.5'

sourceCompatibility = '1.8'

Expand Down
62 changes: 41 additions & 21 deletions jme3-lwjgl3/src/main/java/com/jme3/audio/lwjgl/LwjglAL.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,110 +31,130 @@
*/package com.jme3.audio.lwjgl;

import com.jme3.audio.openal.AL;
import com.jme3.system.NativeLibraryLoader;
import com.jme3.system.Platform;
import org.lwjgl.openal.AL10;
import org.lwjgl.openal.AL11;

import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

/**
* The LWJGL implementation of {@link AL}.
*/
public final class LwjglAL implements AL {

public LwjglAL() {
}

public String alGetString(int parameter) {
@Override
public String alGetString(final int parameter) {
return AL10.alGetString(parameter);
}

@Override
public int alGenSources() {
return AL10.alGenSources();
}

@Override
public int alGetError() {
return AL10.alGetError();
}

public void alDeleteSources(int numSources, IntBuffer sources) {
@Override
public void alDeleteSources(final int numSources, final IntBuffer sources) {
if (sources.position() != 0) throw new AssertionError();
if (sources.limit() != numSources) throw new AssertionError();
AL10.alDeleteSources(sources);
}

public void alGenBuffers(int numBuffers, IntBuffer buffers) {
@Override
public void alGenBuffers(final int numBuffers, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numBuffers) throw new AssertionError();
AL10.alGenBuffers(buffers);
}

public void alDeleteBuffers(int numBuffers, IntBuffer buffers) {
@Override
public void alDeleteBuffers(final int numBuffers, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numBuffers) throw new AssertionError();
AL10.alDeleteBuffers(buffers);
}

public void alSourceStop(int source) {
@Override
public void alSourceStop(final int source) {
AL10.alSourceStop(source);
}

public void alSourcei(int source, int param, int value) {
@Override
public void alSourcei(final int source, final int param, final int value) {
AL10.alSourcei(source, param, value);
}

public void alBufferData(int buffer, int format, ByteBuffer data, int size, int frequency) {
@Override
public void alBufferData(final int buffer, final int format, final ByteBuffer data, final int size, final int frequency) {
if (data.position() != 0) throw new AssertionError();
if (data.limit() != size) throw new AssertionError();
AL10.alBufferData(buffer, format, data, frequency);
}

public void alSourcePlay(int source) {
@Override
public void alSourcePlay(final int source) {
AL10.alSourcePlay(source);
}

public void alSourcePause(int source) {
@Override
public void alSourcePause(final int source) {
AL10.alSourcePause(source);
}

public void alSourcef(int source, int param, float value) {
@Override
public void alSourcef(final int source, final int param, final float value) {
AL10.alSourcef(source, param, value);
}

public void alSource3f(int source, int param, float value1, float value2, float value3) {
@Override
public void alSource3f(final int source, final int param, final float value1, final float value2, final float value3) {
AL10.alSource3f(source, param, value1, value2, value3);
}

public int alGetSourcei(int source, int param) {
@Override
public int alGetSourcei(final int source, final int param) {
return AL10.alGetSourcei(source, param);
}

public void alSourceUnqueueBuffers(int source, int numBuffers, IntBuffer buffers) {
@Override
public void alSourceUnqueueBuffers(final int source, final int numBuffers, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numBuffers) throw new AssertionError();
AL10.alSourceUnqueueBuffers(source, buffers);
}

public void alSourceQueueBuffers(int source, int numBuffers, IntBuffer buffers) {
@Override
public void alSourceQueueBuffers(final int source, final int numBuffers, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numBuffers) throw new AssertionError();
AL10.alSourceQueueBuffers(source, buffers);
}

public void alListener(int param, FloatBuffer data) {
@Override
public void alListener(final int param, final FloatBuffer data) {
AL10.alListenerfv(param, data);
}

public void alListenerf(int param, float value) {
@Override
public void alListenerf(final int param, final float value) {
AL10.alListenerf(param, value);
}

public void alListener3f(int param, float value1, float value2, float value3) {
@Override
public void alListener3f(final int param, final float value1, final float value2, final float value3) {
AL10.alListener3f(param, value1, value2, value3);
}

public void alSource3i(int source, int param, int value1, int value2, int value3) {
@Override
public void alSource3i(final int source, final int param, final int value1, final int value2, final int value3) {
AL11.alSource3i(source, param, value1, value2, value3);
}

}
26 changes: 20 additions & 6 deletions jme3-lwjgl3/src/main/java/com/jme3/audio/lwjgl/LwjglALC.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,27 @@
*/
package com.jme3.audio.lwjgl;

import org.lwjgl.openal.*;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALC;
import org.lwjgl.openal.ALC10;
import org.lwjgl.openal.ALCCapabilities;
import org.lwjgl.openal.SOFTPauseDevice;

/**
* The LWJGL implementation of {@link com.jme3.audio.openal.ALC}.
*/
public class LwjglALC implements com.jme3.audio.openal.ALC {

/**
* The device id.
*/
private long device;

/**
* The context id.
*/
private long context;

@Override
public void createALC() {
device = ALC10.alcOpenDevice((ByteBuffer) null);
ALCCapabilities deviceCaps = ALC.createCapabilities(device);
Expand All @@ -52,6 +60,7 @@ public void createALC() {
AL.createCapabilities(deviceCaps);
}

@Override
public void destroyALC() {
if (context != 0) {
ALC10.alcDestroyContext(context);
Expand All @@ -64,18 +73,22 @@ public void destroyALC() {
}
}

@Override
public boolean isCreated() {
return context != 0;
}

@Override
public String alcGetString(final int parameter) {
return ALC10.alcGetString(device, parameter);
}

@Override
public boolean alcIsExtensionPresent(final String extension) {
return ALC10.alcIsExtensionPresent(device, extension);
}

@Override
public void alcGetInteger(final int param, final IntBuffer buffer, final int size) {
if (buffer.position() != 0) {
throw new AssertionError();
Expand All @@ -86,12 +99,13 @@ public void alcGetInteger(final int param, final IntBuffer buffer, final int siz
ALC10.alcGetIntegerv(device, param, buffer);
}

@Override
public void alcDevicePauseSOFT() {
SOFTPauseDevice.alcDevicePauseSOFT(device);
}

@Override
public void alcDeviceResumeSOFT() {
SOFTPauseDevice.alcDeviceResumeSOFT(device);
}

}
37 changes: 25 additions & 12 deletions jme3-lwjgl3/src/main/java/com/jme3/audio/lwjgl/LwjglEFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,62 +36,75 @@

import java.nio.IntBuffer;

/**
* The LWJGL implementation of {@link EFX}.
*/
public class LwjglEFX implements EFX {

public void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers) {
@Override
public void alGenAuxiliaryEffectSlots(final int numSlots, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numSlots) throw new AssertionError();
EXTEfx.alGenAuxiliaryEffectSlots(buffers);
}

public void alGenEffects(int numEffects, IntBuffer buffers) {
@Override
public void alGenEffects(final int numEffects, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numEffects) throw new AssertionError();
EXTEfx.alGenEffects(buffers);
}

public void alEffecti(int effect, int param, int value) {
@Override
public void alEffecti(final int effect, final int param, final int value) {
EXTEfx.alEffecti(effect, param, value);
}

public void alAuxiliaryEffectSloti(int effectSlot, int param, int value) {
@Override
public void alAuxiliaryEffectSloti(final int effectSlot, final int param, final int value) {
EXTEfx.alAuxiliaryEffectSloti(effectSlot, param, value);
}

public void alDeleteEffects(int numEffects, IntBuffer buffers) {
@Override
public void alDeleteEffects(final int numEffects, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numEffects) throw new AssertionError();
EXTEfx.alDeleteEffects(buffers);
}

public void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers) {
@Override
public void alDeleteAuxiliaryEffectSlots(final int numEffectSlots, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numEffectSlots) throw new AssertionError();
EXTEfx.alDeleteAuxiliaryEffectSlots(buffers);
}

public void alGenFilters(int numFilters, IntBuffer buffers) {
@Override
public void alGenFilters(final int numFilters, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numFilters) throw new AssertionError();
EXTEfx.alGenFilters(buffers);
}

public void alFilteri(int filter, int param, int value) {
@Override
public void alFilteri(final int filter, final int param, final int value) {
EXTEfx.alFilteri(filter, param, value);
}

public void alFilterf(int filter, int param, float value) {
@Override
public void alFilterf(final int filter, final int param, final float value) {
EXTEfx.alFilterf(filter, param, value);
}

public void alDeleteFilters(int numFilters, IntBuffer buffers) {
@Override
public void alDeleteFilters(final int numFilters, final IntBuffer buffers) {
if (buffers.position() != 0) throw new AssertionError();
if (buffers.limit() != numFilters) throw new AssertionError();
EXTEfx.alDeleteFilters(buffers);
}

public void alEffectf(int effect, int param, float value) {
@Override
public void alEffectf(final int effect, final int param, final float value) {
EXTEfx.alEffectf(effect, param, value);
}

}
Loading

0 comments on commit 555a348

Please sign in to comment.