# This .cfg file is used to generate the interface to the GLX routines
# used internally by the X11GLContext implementation.
Package com.sun.opengl.impl.x11
JavaClass GLX
Style allstatic
Include gl-common-x11.cfg

EmitProcAddressTable true
ProcAddressTableClassName GLXProcAddressTable
GetProcAddressTableExpr glxProcAddressTable
# This must be present for bootstrapping
SkipProcAddressGen glXGetProcAddressARB

CustomJavaCode GLX private static GLXProcAddressTable glxProcAddressTable = new GLXProcAddressTable();
CustomJavaCode GLX public  static GLXProcAddressTable getGLXProcAddressTable() { return glxProcAddressTable; }
CustomJavaCode GLX public static native long dlsym(String name);

CustomCCode #include <inttypes.h>
CustomCCode #include <X11/Xlib.h>
CustomCCode #include <X11/Xutil.h>
CustomCCode #include <GL/glx.h>
CustomCCode /* Linux headers don't work properly */
CustomCCode #define __USE_GNU
CustomCCode #include <dlfcn.h>
CustomCCode #undef __USE_GNU

ArgumentIsString XOpenDisplay 0

# Need to expose DefaultScreen and RootWindow macros to Java
CustomJavaCode GLX public static native int  DefaultScreen(long display);
CustomJavaCode GLX public static native long RootWindow(long display, int screen);
CustomCCode JNIEXPORT jlong JNICALL 
CustomCCode Java_com_sun_opengl_impl_x11_GLX_DefaultScreen(JNIEnv *env, jclass _unused, jlong display) {
CustomCCode   return DefaultScreen((Display*) (intptr_t) display);
CustomCCode }
CustomCCode JNIEXPORT jlong JNICALL 
CustomCCode Java_com_sun_opengl_impl_x11_GLX_RootWindow(JNIEnv *env, jclass _unused, jlong display, jint screen) {
CustomCCode   return RootWindow((Display*) (intptr_t) display, screen);
CustomCCode }
CustomCCode JNIEXPORT jlong JNICALL 
CustomCCode Java_com_sun_opengl_impl_x11_GLX_dlsym(JNIEnv *env, jclass _unused, jstring name) {
CustomCCode   const jbyte* chars;
CustomCCode   void* res;
CustomCCode   chars = (*env)->GetStringUTFChars(env, name, NULL);
CustomCCode   res = dlsym(RTLD_DEFAULT, chars);
CustomCCode   (*env)->ReleaseStringUTFChars(env, name, chars);
CustomCCode   return (jlong) ((intptr_t) res);
CustomCCode }

# Get returned array's capacity from XGetVisualInfo to be correct
TemporaryCVariableDeclaration XGetVisualInfo int count;
TemporaryCVariableAssignment  XGetVisualInfo count = _ptr3[0];
ReturnValueCapacity XGetVisualInfo               count * sizeof(XVisualInfo)
# FIXME: this is terrible but currently needed because we have two
# overloadings for the third argument (IntBuffer and int[]) and can't
# specify different glue code for different overloadings
#
# The NoNio directive which was present in an earlier version of
# GlueGen, which resolved this more cleanly, is also not yet available
# in this version.
ReturnedArrayLength XGetVisualInfo               ((((Object) {3}) instanceof Buffer) ? ((IntBuffer) ((Object) {3})).get(0) : ((int[]) ((Object) {3}))[0])
ReturnValueCapacity glXChooseVisual              sizeof(XVisualInfo)
ReturnValueCapacity glXGetVisualFromFBConfig     sizeof(XVisualInfo)
ReturnValueCapacity glXGetVisualFromFBConfigSGIX sizeof(XVisualInfo)

# Ignore everything not in the GLX core (up through GLX 1.4) aside from glXGetProcAddress
# FIXME: this needs to be kept in sync with the stub headers more than usual
Ignore glXFreeContextEXT
Ignore glXGetContextIDEXT
Ignore glXGetCurrentDisplayEXT
Ignore glXImportContextEXT
Ignore glXQueryContextInfoEXT

Ignore glXCopySubBufferMESA
Ignore glXCreateGLXPixmapMESA
Ignore glXReleaseBuffersMESA
Ignore glXSet3DfxModeMESA

Ignore glXGetSyncValuesOML
Ignore glXGetMscRateOML
Ignore glXSwapBuffersMscOML
Ignore glXWaitForMscOML
Ignore glXWaitForSbcOML

Ignore glXAllocateMemoryNV
Ignore glXFreeMemoryNV

Ignore glXCushionSGI
Ignore glXGetVideoSyncSGI
Ignore glXWaitVideoSyncSGI
Ignore glXSwapIntervalSGI
Ignore glXMakeCurrentReadSGI
Ignore glXGetCurrentReadDrawableSGI

Ignore glXCreateGLXVideoSourceSGIX
Ignore glXDestroyGLXVideoSourceSGIX
Ignore glXGetFBConfigAttribSGIX
Ignore glXChooseFBConfigSGIX
Ignore glXCreateGLXPixmapWithConfigSGIX
Ignore glXCreateContextWithConfigSGIX
Ignore glXGetVisualFromFBConfigSGIX
Ignore glXGetFBConfigFromVisualSGIX
Ignore glXCreateGLXPbufferSGIX
Ignore glXDestroyGLXPbufferSGIX
Ignore glXQueryGLXPbufferSGIX
Ignore glXSelectEventSGIX
Ignore glXGetSelectedEventSGIX
Ignore glXBindChannelToWindowSGIX
Ignore glXChannelRectSGIX
Ignore glXQueryChannelRectSGIX
Ignore glXQueryChannelDeltasSGIX
Ignore glXChannelRectSyncSGIX
Ignore glXAssociateDMPbufferSGIX
Ignore glXJoinSwapGroupSGIX
Ignore glXBindSwapBarrierSGIX
Ignore glXQueryMaxSwapBarriersSGIX

Ignore glXGetTransparentIndexSUN

# Ignore non-GLX GL routines and constants
Ignore ^GL_.+
Ignore TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
Ignore CLAMP_TO_EDGE_EXT
Ignore ^gl[^X].+