bool extgl_Open(JNIEnv *env) { if (lib_gl_handle != NULL) return true; /* * Actually we don't need the RTLD_GLOBAL flag, since the symbols * we load should be private to us. However, according to the * documentation at * * http://dri.sourceforge.net/doc/DRIuserguide.html * * DRI drivers need this flag to work properly */ lib_gl_handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_GLOBAL); if (lib_gl_handle == NULL) { throwFormattedException(env, "Error loading libGL.so.1: %s", dlerror()); return false; } lwjgl_glXGetProcAddressARB = (glXGetProcAddressARBPROC)dlsym(lib_gl_handle, "glXGetProcAddressARB"); if (lwjgl_glXGetProcAddressARB == NULL) { extgl_Close(); throwException(env, "Could not get address of glXGetProcAddressARB"); return false; } /* Unlike Windows, GLX function addresses are context-independent * so we only have to initialize the addresses once at load */ extgl_InitGLX12(); extgl_InitGLX13(); extgl_InitGLXSGISwapControl(); extgl_InitGLXARBCreateContext(); extgl_InitGLXNVPresentVideo(); extgl_InitGLXNVVideoCapture(); return true; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_nUnloadOpenGLLibrary(JNIEnv * env, jclass clazz) { extgl_Close(); }