updated GL and AL
This commit is contained in:
parent
6ad6f658b0
commit
e40ebdc5c6
@ -31,52 +31,49 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.audio.lwjgl;
|
package com.jme3.audio.lwjgl;
|
||||||
|
|
||||||
import com.jme3.audio.openal.ALC;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
import org.lwjgl.openal.AL;
|
||||||
|
import org.lwjgl.openal.ALC;
|
||||||
import org.lwjgl.openal.ALC10;
|
import org.lwjgl.openal.ALC10;
|
||||||
import org.lwjgl.openal.ALContext;
|
import org.lwjgl.openal.ALCCapabilities;
|
||||||
import org.lwjgl.openal.ALDevice;
|
|
||||||
import org.lwjgl.openal.SOFTPauseDevice;
|
import org.lwjgl.openal.SOFTPauseDevice;
|
||||||
|
|
||||||
public class LwjglALC implements ALC {
|
public class LwjglALC implements com.jme3.audio.openal.ALC {
|
||||||
|
|
||||||
private ALDevice device;
|
private long device;
|
||||||
private ALContext context;
|
private long context;
|
||||||
|
|
||||||
private long contextId;
|
|
||||||
private long deviceId;
|
|
||||||
|
|
||||||
public void createALC() {
|
public void createALC() {
|
||||||
device = ALDevice.create();
|
device = ALC10.alcOpenDevice((ByteBuffer) null);
|
||||||
context = ALContext.create(device);
|
ALCCapabilities deviceCaps = ALC.createCapabilities(device);
|
||||||
context.makeCurrent();
|
context = ALC10.alcCreateContext(device, (IntBuffer) null);
|
||||||
|
ALC10.alcMakeContextCurrent(context);
|
||||||
contextId = ALC10.alcGetCurrentContext();
|
AL.createCapabilities(deviceCaps);
|
||||||
deviceId = ALC10.alcGetContextsDevice(contextId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroyALC() {
|
public void destroyALC() {
|
||||||
if (context != null) {
|
if (context != 0) {
|
||||||
context.destroy();
|
ALC10.alcDestroyContext(context);
|
||||||
context = null;
|
context = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device != null) {
|
if (device != 0) {
|
||||||
device.destroy();
|
ALC10.alcCloseDevice(device);
|
||||||
device = null;
|
device = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCreated() {
|
public boolean isCreated() {
|
||||||
return context != null;
|
return context != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String alcGetString(final int parameter) {
|
public String alcGetString(final int parameter) {
|
||||||
return ALC10.alcGetString(deviceId, parameter);
|
return ALC10.alcGetString(device, parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean alcIsExtensionPresent(final String extension) {
|
public boolean alcIsExtensionPresent(final String extension) {
|
||||||
return ALC10.alcIsExtensionPresent(deviceId, extension);
|
return ALC10.alcIsExtensionPresent(device, extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alcGetInteger(final int param, final IntBuffer buffer, final int size) {
|
public void alcGetInteger(final int param, final IntBuffer buffer, final int size) {
|
||||||
@ -86,15 +83,15 @@ public class LwjglALC implements ALC {
|
|||||||
if (buffer.limit() != size) {
|
if (buffer.limit() != size) {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
ALC10.alcGetIntegerv(deviceId, param, buffer);
|
ALC10.alcGetIntegerv(device, param, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alcDevicePauseSOFT() {
|
public void alcDevicePauseSOFT() {
|
||||||
SOFTPauseDevice.alcDevicePauseSOFT(deviceId);
|
SOFTPauseDevice.alcDevicePauseSOFT(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alcDeviceResumeSOFT() {
|
public void alcDeviceResumeSOFT() {
|
||||||
SOFTPauseDevice.alcDeviceResumeSOFT(deviceId);
|
SOFTPauseDevice.alcDeviceResumeSOFT(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class GlfwJoystickInput implements JoyInput {
|
|||||||
@Override
|
@Override
|
||||||
public Joystick[] loadJoysticks(final InputManager inputManager) {
|
public Joystick[] loadJoysticks(final InputManager inputManager) {
|
||||||
for (int i = 0; i < GLFW_JOYSTICK_LAST; i++) {
|
for (int i = 0; i < GLFW_JOYSTICK_LAST; i++) {
|
||||||
if (glfwJoystickPresent(i) == GL11.GL_TRUE) {
|
if (glfwJoystickPresent(i)) {
|
||||||
final String name = glfwGetJoystickName(i);
|
final String name = glfwGetJoystickName(i);
|
||||||
final GlfwJoystick joystick = new GlfwJoystick(inputManager, this, i, name);
|
final GlfwJoystick joystick = new GlfwJoystick(inputManager, this, i, name);
|
||||||
joysticks.put(i, joystick);
|
joysticks.put(i, joystick);
|
||||||
|
@ -87,6 +87,16 @@ public class GlfwKeyInput implements KeyInput {
|
|||||||
|
|
||||||
keyInputEvents.add(event);
|
keyInputEvents.add(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetCharCallback(context.getWindowHandle(), charCallback = new GLFWCharCallback() {
|
glfwSetCharCallback(context.getWindowHandle(), charCallback = new GLFWCharCallback() {
|
||||||
@ -106,6 +116,16 @@ public class GlfwKeyInput implements KeyInput {
|
|||||||
|
|
||||||
keyInputEvents.add(released);
|
keyInputEvents.add(released);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@ -132,8 +152,8 @@ public class GlfwKeyInput implements KeyInput {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyCallback.release();
|
keyCallback.close();
|
||||||
charCallback.release();
|
charCallback.close();
|
||||||
logger.fine("Keyboard destroyed.");
|
logger.fine("Keyboard destroyed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,16 @@ public class GlfwMouseInput implements MouseInput {
|
|||||||
public void invoke(long window, double xpos, double ypos) {
|
public void invoke(long window, double xpos, double ypos) {
|
||||||
onCursorPos(window, xpos, ypos);
|
onCursorPos(window, xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
super.callback(args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() {
|
glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() {
|
||||||
@ -140,6 +150,15 @@ public class GlfwMouseInput implements MouseInput {
|
|||||||
public void invoke(final long window, final double xOffset, final double yOffset) {
|
public void invoke(final long window, final double xOffset, final double yOffset) {
|
||||||
onWheelScroll(window, xOffset, yOffset * WHEEL_SCALE);
|
onWheelScroll(window, xOffset, yOffset * WHEEL_SCALE);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
super.callback(args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() {
|
glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() {
|
||||||
@ -147,6 +166,15 @@ public class GlfwMouseInput implements MouseInput {
|
|||||||
public void invoke(final long window, final int button, final int action, final int mods) {
|
public void invoke(final long window, final int button, final int action, final int mods) {
|
||||||
onMouseButton(window, button, action, mods);
|
onMouseButton(window, button, action, mods);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
super.callback(args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setCursorVisible(cursorVisible);
|
setCursorVisible(cursorVisible);
|
||||||
@ -177,9 +205,9 @@ public class GlfwMouseInput implements MouseInput {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorPosCallback.release();
|
cursorPosCallback.close();
|
||||||
scrollCallback.release();
|
scrollCallback.close();
|
||||||
mouseButtonCallback.release();
|
mouseButtonCallback.close();
|
||||||
|
|
||||||
for (long glfwCursor : jmeToGlfwCursorMap.values()) {
|
for (long glfwCursor : jmeToGlfwCursorMap.values()) {
|
||||||
glfwDestroyCursor(glfwCursor);
|
glfwDestroyCursor(glfwCursor);
|
||||||
|
@ -75,4 +75,14 @@ class LwjglGLDebugOutputHandler extends GLDebugMessageARBCallback {
|
|||||||
|
|
||||||
System.err.println(String.format(MESSAGE_FORMAT, id, sourceStr, typeStr, severityStr, message));
|
System.err.println(String.format(MESSAGE_FORMAT, id, sourceStr, typeStr, severityStr, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
super.callback(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,9 +132,19 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
|
|||||||
final String message = GLFWErrorCallback.getDescription(description);
|
final String message = GLFWErrorCallback.getDescription(description);
|
||||||
listener.handleError(message, new Exception(message));
|
listener.handleError(message, new Exception(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close(){
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
super.callback(args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (glfwInit() != GLFW_TRUE) {
|
if (!glfwInit()) {
|
||||||
throw new IllegalStateException("Unable to initialize GLFW");
|
throw new IllegalStateException("Unable to initialize GLFW");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +171,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
|
|||||||
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
|
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
|
||||||
glfwWindowHint(GLFW_RESIZABLE, settings.isResizable() ? GLFW_TRUE : GLFW_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE, settings.isResizable() ? GLFW_TRUE : GLFW_FALSE);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_DOUBLE_BUFFER, GLFW_TRUE);
|
//glfwWindowHint(GLFW_DOUBLE_BUFFER, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_DEPTH_BITS, settings.getDepthBits());
|
glfwWindowHint(GLFW_DEPTH_BITS, settings.getDepthBits());
|
||||||
glfwWindowHint(GLFW_STENCIL_BITS, settings.getStencilBits());
|
glfwWindowHint(GLFW_STENCIL_BITS, settings.getStencilBits());
|
||||||
glfwWindowHint(GLFW_SAMPLES, settings.getSamples());
|
glfwWindowHint(GLFW_SAMPLES, settings.getSamples());
|
||||||
@ -206,12 +216,21 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
|
|||||||
settings.setResolution(width, height);
|
settings.setResolution(width, height);
|
||||||
listener.reshape(width, height);
|
listener.reshape(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
super.callback(args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() {
|
glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(final long window, final int focused) {
|
public void invoke(final long window, final boolean focus) {
|
||||||
final boolean focus = (focused == GL_TRUE);
|
|
||||||
if (wasActive != focus) {
|
if (wasActive != focus) {
|
||||||
if (!wasActive) {
|
if (!wasActive) {
|
||||||
listener.gainFocus();
|
listener.gainFocus();
|
||||||
@ -223,6 +242,16 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
|
|||||||
wasActive = !wasActive;
|
wasActive = !wasActive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(long args) {
|
||||||
|
super.callback(args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Center the window
|
// Center the window
|
||||||
@ -260,17 +289,17 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errorCallback != null) {
|
if (errorCallback != null) {
|
||||||
errorCallback.release();
|
errorCallback.close();
|
||||||
errorCallback = null;
|
errorCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowSizeCallback != null) {
|
if (windowSizeCallback != null) {
|
||||||
windowSizeCallback.release();
|
windowSizeCallback.close();
|
||||||
windowSizeCallback = null;
|
windowSizeCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowFocusCallback != null) {
|
if (windowFocusCallback != null) {
|
||||||
windowFocusCallback.release();
|
windowFocusCallback.close();
|
||||||
windowFocusCallback = null;
|
windowFocusCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,7 +489,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glfwWindowShouldClose(window) == GL_TRUE) {
|
if (glfwWindowShouldClose(window)) {
|
||||||
listener.requestClose(false);
|
listener.requestClose(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user