Add jaggl_dri implementation

master
Graham 5 years ago
parent 3f34611c0d
commit 9192a0d905
  1. 21
      gl-dri-natives/pom.xml
  2. 29
      gl-dri-natives/src/main/c/jaggl_dri.c

@ -9,7 +9,26 @@
</parent> </parent>
<artifactId>openrs2-gl-dri-natives</artifactId> <artifactId>openrs2-gl-dri-natives</artifactId>
<packaging>jar</packaging> <packaging>nar</packaging>
<name>OpenRS2 GL DRI Natives</name> <name>OpenRS2 GL DRI Natives</name>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<configuration>
<linker>
<sysLibs>
<sysLib>
<type>shared</type>
<name>dl</name>
</sysLib>
</sysLibs>
</linker>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

@ -0,0 +1,29 @@
#include "jaggl_X11_dri.h"
#include <dlfcn.h>
#include <stddef.h>
static void *jaggl_dri_handle;
JNIEXPORT jboolean JNICALL Java_jaggl_X11_dri_open(JNIEnv *env, jclass cls, jstring path) {
if (jaggl_dri_handle) {
dlclose(jaggl_dri_handle);
jaggl_dri_handle = NULL;
}
const char *path_str = (*env)->GetStringUTFChars(env, path, NULL);
jaggl_dri_handle = dlopen(path_str, RTLD_LAZY | RTLD_GLOBAL);
(*env)->ReleaseStringUTFChars(env, path, path_str);
return jaggl_dri_handle != NULL;
}
JNIEXPORT jboolean JNICALL Java_jaggl_X11_dri_close(JNIEnv *env, jclass cls) {
if (jaggl_dri_handle) {
dlclose(jaggl_dri_handle);
jaggl_dri_handle = NULL;
return JNI_TRUE;
}
return JNI_FALSE;
}
Loading…
Cancel
Save