blob: 105afa2278de2f6a458c6555a8f527d35ebaa23e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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();
}
}
|