Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Config Toggle to Enable / Disable HRTF Bools in OpenAl #119

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/me/eigenraven/lwjgl3ify/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class Config {
public static boolean OPENGL_DOUBLEBUFFER = true;
public static boolean OPENGL_CONTEXT_NO_ERROR = false;

public static boolean OPENAL_ENABLE_HRTF = false;

public static boolean INPUT_INVERT_WHEEL = false;
public static boolean INPUT_INVERT_X_WHEEL = false;
public static double INPUT_SCROLL_SPEED = 1.0;
Expand All @@ -91,7 +93,8 @@ public class Config {
public static final String CATEGORY_DEBUG = "debug";
public static final String CATEGORY_WINDOW = "window";
public static final String CATEGORY_INPUT = "input";
public static final String CATEGORY_GLCONTEXT = "openglContext";
public static final String CATEGORY_GLCONTEXT = "openglcontext";
public static final String CATEGORY_OPENALCONTEXT = "openalcontext";

public static Configuration config = null;

Expand Down Expand Up @@ -228,6 +231,9 @@ public static void reloadConfigObject() {
CATEGORY_GLCONTEXT,
OPENGL_CONTEXT_NO_ERROR,
"Enable GL_KHR_no_error to use faster driver code, but which can cause memory corruption in case of OpenGL errors");

OPENAL_ENABLE_HRTF = config
.getBoolean("enableHRTF", CATEGORY_OPENALCONTEXT, OPENAL_ENABLE_HRTF, "Enable HRTF sound support");
}

public static Set<String> getExtensibleEnums() {
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/org/lwjglx/openal/AL.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.lwjglx.openal;

import static me.eigenraven.lwjgl3ify.core.Config.OPENAL_ENABLE_HRTF;

import java.nio.IntBuffer;

import org.lwjgl.openal.ALC10;
Expand Down Expand Up @@ -41,6 +43,17 @@ public static void create(String deviceArguments, int contextFrequency, int cont
attribs.put(org.lwjgl.openal.ALC10.ALC_SYNC);
attribs.put(contextSynchronized ? org.lwjgl.openal.ALC10.ALC_TRUE : org.lwjgl.openal.ALC10.ALC_FALSE);

/////////////////////////////////////////////
// HRTF
if (!OPENAL_ENABLE_HRTF) {
KAMKEEL marked this conversation as resolved.
Show resolved Hide resolved
attribs.put(org.lwjgl.openal.SOFTHRTF.ALC_HRTF_SOFT);
attribs.put(org.lwjgl.openal.ALC10.ALC_FALSE);

attribs.put(org.lwjgl.openal.SOFTHRTF.ALC_HRTF_ID_SOFT);
attribs.put(0);
}
/////////////////////////////////////////////

attribs.put(org.lwjgl.openal.EXTEfx.ALC_MAX_AUXILIARY_SENDS);
attribs.put(4);

Expand All @@ -52,14 +65,12 @@ public static void create(String deviceArguments, int contextFrequency, int cont
long deviceHandle = org.lwjgl.openal.ALC10.alcOpenDevice(defaultDevice);

alcDevice = new ALCdevice(deviceHandle);

final ALCCapabilities deviceCaps = org.lwjgl.openal.ALC.createCapabilities(deviceHandle);

long contextHandle = org.lwjgl.openal.ALC10.alcCreateContext(AL.getDevice().device, attribs);
alcContext = new ALCcontext(contextHandle);
org.lwjgl.openal.ALC10.alcMakeContextCurrent(contextHandle);
org.lwjgl.openal.AL.createCapabilities(deviceCaps);

created = true;
}

Expand Down
Loading