diff options
author | Sven Gothel <[email protected]> | 2014-03-10 22:18:53 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-03-10 22:18:53 +0100 |
commit | 95690a4224a1235f76675700efacba17db1e9bbd (patch) | |
tree | 375e83337b946b2f3f005da8caf503893497c171 /make/config/jogl | |
parent | 183abe017461cd1ebaf1380143db104a085af2cd (diff) | |
parent | fdd60adb1d421f2018b47ee17e9079c94b54910f (diff) |
Merge branch 'master' into 2.2-train
Diffstat (limited to 'make/config/jogl')
-rw-r--r-- | make/config/jogl/glx-CustomCCode.c | 63 | ||||
-rw-r--r-- | make/config/jogl/glx-CustomJavaCode.java | 19 | ||||
-rw-r--r-- | make/config/jogl/glx-x11.cfg | 2 | ||||
-rw-r--r-- | make/config/jogl/glxext.cfg | 2 |
4 files changed, 84 insertions, 2 deletions
diff --git a/make/config/jogl/glx-CustomCCode.c b/make/config/jogl/glx-CustomCCode.c index 5c73dfea6..3f5cf1121 100644 --- a/make/config/jogl/glx-CustomCCode.c +++ b/make/config/jogl/glx-CustomCCode.c @@ -12,6 +12,8 @@ #define RTLD_DEFAULT NULL #endif +#include <string.h> + /* We expect glXGetProcAddressARB to be defined */ extern void (*glXGetProcAddressARB(const GLubyte *procname))(); @@ -124,7 +126,7 @@ Java_jogamp_opengl_x11_glx_GLX_dispatch_1glXChooseFBConfig(JNIEnv *env, jclass _ int * _attribList_ptr = NULL; int * _nitems_ptr = NULL; GLXFBConfig * _res; - int count; + int count, i; jobject jbyteSource; jobject jbyteCopy; if ( NULL != attribList ) { @@ -139,6 +141,65 @@ Java_jogamp_opengl_x11_glx_GLX_dispatch_1glXChooseFBConfig(JNIEnv *env, jclass _ count = _nitems_ptr[0]; if (NULL == _res) return NULL; + /** Bug 961: Validate returned 'GLXFBConfig *', i.e. remove NULL pointer. */ + // fprintf(stderr, "glXChooseFBConfig.0: Count %d\n", count); + i=0; + while( i < count ) { + if( NULL == _res[i] ) { + if( 0 < count-i-1 ) { + memmove(_res+i, _res+i+1, count-i-1); + } + count--; + } else { + i++; + } + } + // fprintf(stderr, "glXChooseFBConfig.X: Count %d\n", count); + _initClazzAccess(env); + + jbyteSource = (*env)->NewDirectByteBuffer(env, _res, count * sizeof(GLXFBConfig)); + jbyteCopy = (*env)->CallStaticObjectMethod(env, clazzBuffers, cstrBuffers, jbyteSource); + (*env)->DeleteLocalRef(env, jbyteSource); + XFree(_res); + + return jbyteCopy; +} + +/* Java->C glue code: + * Java package: jogamp.opengl.x11.glx.GLX + * Java method: com.jogamp.common.nio.PointerBuffer dispatch_glXGetFBConfigs(long dpy, int screen, java.nio.IntBuffer nelements) + * C function: GLXFBConfig * glXGetFBConfigs(Display * dpy, int screen, int * nelements); + */ +JNIEXPORT jobject JNICALL +Java_jogamp_opengl_x11_glx_GLX_dispatch_1glXGetFBConfigs(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject nelements, jint nelements_byte_offset, jlong procAddress) { + typedef GLXFBConfig * (APIENTRY*_local_PFNGLXGETFBCONFIGSPROC)(Display * dpy, int screen, int * nelements); + _local_PFNGLXGETFBCONFIGSPROC ptr_glXGetFBConfigs; + int * _nelements_ptr = NULL; + GLXFBConfig * _res; + int count, i; + jobject jbyteSource; + jobject jbyteCopy; + if ( NULL != nelements ) { + _nelements_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, nelements)) + nelements_byte_offset); + } + ptr_glXGetFBConfigs = (_local_PFNGLXGETFBCONFIGSPROC) (intptr_t) procAddress; + assert(ptr_glXGetFBConfigs != NULL); + _res = (* ptr_glXGetFBConfigs) ((Display *) (intptr_t) dpy, (int) screen, (int *) _nelements_ptr); + count = _nelements_ptr[0]; + if (NULL == _res) return NULL; + + /** Bug 961: Validate returned 'GLXFBConfig *', i.e. remove NULL pointer. */ + i=0; + while( i < count ) { + if( NULL == _res[i] ) { + if( 0 < count-i-1 ) { + memmove(_res+i, _res+i+1, count-i-1); + } + count--; + } else { + i++; + } + } _initClazzAccess(env); jbyteSource = (*env)->NewDirectByteBuffer(env, _res, count * sizeof(GLXFBConfig)); diff --git a/make/config/jogl/glx-CustomJavaCode.java b/make/config/jogl/glx-CustomJavaCode.java index 4cce05dda..5a3ea392b 100644 --- a/make/config/jogl/glx-CustomJavaCode.java +++ b/make/config/jogl/glx-CustomJavaCode.java @@ -60,6 +60,25 @@ @param nitems a direct only {@link java.nio.IntBuffer} */ private static native ByteBuffer dispatch_glXChooseFBConfig(long dpy, int screen, Object attribList, int attribList_byte_offset, Object nitems, int nitems_byte_offset, long procAddress); + /** Entry point to C language function: <code> GLXFBConfig * glXGetFBConfigs(Display * dpy, int screen, int * nelements); </code> <br>Part of <code>GLX_VERSION_1_3</code> + @param nelements a direct only {@link java.nio.IntBuffer} */ + public static PointerBuffer glXGetFBConfigs(long dpy, int screen, IntBuffer nelements) { + + if (!Buffers.isDirect(nelements)) + throw new GLException("Argument \"nelements\" is not a direct buffer"); + final long __addr_ = glxProcAddressTable._addressof_glXGetFBConfigs; + if (__addr_ == 0) { + throw new GLException(String.format("Method \"%s\" not available", "glXGetFBConfigs")); + } + final ByteBuffer _res = dispatch_glXGetFBConfigs(dpy, screen, nelements, Buffers.getDirectBufferByteOffset(nelements), __addr_); + if (_res == null) return null; + return PointerBuffer.wrap(Buffers.nativeOrder(_res)); + } + + /** Entry point to C language function: <code> GLXFBConfig * glXGetFBConfigs(Display * dpy, int screen, int * nelements); </code> <br>Part of <code>GLX_VERSION_1_3</code> + @param nelements a direct only {@link java.nio.IntBuffer} */ + private static native ByteBuffer dispatch_glXGetFBConfigs(long dpy, int screen, Object nelements, int nelements_byte_offset, long procAddress); + /** Entry point to C language function: <code> XVisualInfo * glXChooseVisual(Display * dpy, int screen, int * attribList); </code> <br>Part of <code>GLX_VERSION_1_X</code> @param attribList a direct only {@link java.nio.IntBuffer} */ diff --git a/make/config/jogl/glx-x11.cfg b/make/config/jogl/glx-x11.cfg index 5955e0a38..1c138c8ae 100644 --- a/make/config/jogl/glx-x11.cfg +++ b/make/config/jogl/glx-x11.cfg @@ -44,9 +44,11 @@ Ignore glXCreateContextAttribsARB Ignore glXGetVisualFromFBConfigSGIX ManuallyImplement glXGetVisualFromFBConfig ManuallyImplement glXChooseFBConfig +ManuallyImplement glXGetFBConfigs ManuallyImplement glXChooseVisual ForceProcAddressGen glXGetVisualFromFBConfig ForceProcAddressGen glXChooseFBConfig +ForceProcAddressGen glXGetFBConfigs ForceProcAddressGen glXChooseVisual # Ignore everything not in the GLX core (up through GLX 1.4) diff --git a/make/config/jogl/glxext.cfg b/make/config/jogl/glxext.cfg index c73753e3c..d158d241f 100644 --- a/make/config/jogl/glxext.cfg +++ b/make/config/jogl/glxext.cfg @@ -60,6 +60,7 @@ CustomJavaCode GLXExtImpl private X11GLXContext _context; Ignore glXGetVisualFromFBConfig Ignore glXGetVisualFromFBConfigSGIX Ignore glXChooseFBConfig +Ignore glXGetFBConfigs Ignore glXChooseVisual Ignore glXCreateContext Ignore glXDestroyContext @@ -81,7 +82,6 @@ Ignore glXQueryExtensionsString Ignore glXQueryServerString Ignore glXGetClientString Ignore glXGetCurrentDisplay -Ignore glXChooseFBConfig Ignore glXGetFBConfigAttrib Ignore glXGetFBConfigs Ignore glXGetVisualFromFBConfig |