diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal/plugin/Lwjgl2FunctionProvider.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/internal/plugin/Lwjgl2FunctionProvider.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/Lwjgl2FunctionProvider.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/Lwjgl2FunctionProvider.java new file mode 100644 index 0000000..105afa2 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/Lwjgl2FunctionProvider.java @@ -0,0 +1,39 @@ +package cc.polyfrost.oneconfig.internal.plugin; + +import org.lwjgl.opengl.GLContext; +import org.lwjgl.system.FunctionProvider; + +import java.lang.reflect.Method; +import java.nio.ByteBuffer; + +/** + * Taken from LWJGLTwoPointFive under The Unlicense + * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a> + */ +public class Lwjgl2FunctionProvider implements FunctionProvider { + + private final Method m_getFunctionAddress; + + public Lwjgl2FunctionProvider() { + try { + m_getFunctionAddress = GLContext.class.getDeclaredMethod("getFunctionAddress", String.class); + m_getFunctionAddress.setAccessible(true); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public long getFunctionAddress(CharSequence functionName) { + try { + return (long) m_getFunctionAddress.invoke(null, functionName.toString()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public long getFunctionAddress(ByteBuffer byteBuffer) { + throw new UnsupportedOperationException(); + } +}
\ No newline at end of file |