Ejemplo n.º 1
0
JNIEXPORT jboolean JNICALL 
Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboolean firstUIActionOnProcess, jboolean debug) {
    if(0==_initialized) {
        if(debug) {
            errorHandlerDebug = 1;
        }
        X11UtilClazz = (jclass)(*env)->NewGlobalRef(env, clazz);
        if( JNI_TRUE == firstUIActionOnProcess ) {
            if( 0 == XInitThreads() ) {
                fprintf(stderr, "Warning: XInitThreads() failed\n");
            } else {
                _xinitThreadsOK=JNI_TRUE;
                if(debug) {
                    fprintf(stderr, "X11: XInitThreads() called for concurrent Thread support\n");
                }
            }
        } else if(debug) {
            fprintf(stderr, "X11: XInitThreads() _not_ called for concurrent Thread support\n");
        }

        _initClazzAccess(env);
        x11IOErrorHandlerEnable(1, env);
        _initialized=1;
        if(JNI_TRUE == debug) {
            fprintf(stderr, "Info: NativeWindow native init passed\n");
        }
    }
    return _xinitThreadsOK;
}
Ejemplo n.º 2
0
/*   Java->C glue code:
 *   Java package: com.sun.opengl.impl.x11.glx.GLX
 *    Java method: java.nio.LongBuffer glXChooseFBConfig(long dpy, int screen, java.nio.IntBuffer attribList, java.nio.IntBuffer nitems)
 *     C function: GLXFBConfig *  glXChooseFBConfig(Display *  dpy, int screen, const int *  attribList, int *  nitems);
 */
JNIEXPORT jobject JNICALL 
Java_com_sun_opengl_impl_x11_glx_GLX_glXChooseFBConfigCopied1__JILjava_lang_Object_2ILjava_lang_Object_2I(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject attribList, jint attribList_byte_offset, jobject nitems, jint nitems_byte_offset) {
  int * _ptr2 = NULL;
  int * _ptr3 = NULL;
  GLXFBConfig *  _res;
  int count;
  if (attribList != NULL) {
    _ptr2 = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, attribList, NULL)) + attribList_byte_offset);
  }
  if (nitems != NULL) {
    _ptr3 = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, nitems, NULL)) + nitems_byte_offset);
  }
  _res = glXChooseFBConfig((Display *) (intptr_t) dpy, (int) screen, (int *) _ptr2, (int *) _ptr3);
  count = _ptr3[0];
  if (attribList != NULL) {
    (*env)->ReleasePrimitiveArrayCritical(env, attribList, _ptr2, 0);
  }
  if (nitems != NULL) {
    (*env)->ReleasePrimitiveArrayCritical(env, nitems, _ptr3, 0);
  }
  if (_res == NULL) return NULL;

  _initClazzAccess(env);

  jobject jbyteSource = (*env)->NewDirectByteBuffer(env, _res, count * sizeof(GLXFBConfig));
  jobject jbyteCopy   = (*env)->CallStaticObjectMethod(env,
                            clazzInternalBufferUtil, cstrInternalBufferUtil, jbyteSource);

  // FIXME: remove reference/gc jbyteSource ?? 
  XFree(_res);

  return jbyteCopy;
}
Ejemplo n.º 3
0
/*   Java->C glue code:
 *   Java package: jogamp.opengl.x11.glx.GLX
 *    Java method: XVisualInfo dispatch_glXChooseVisual(long dpy, int screen, java.nio.IntBuffer attribList)
 *     C function: XVisualInfo *  glXChooseVisual(Display *  dpy, int screen, int *  attribList);
 */
JNIEXPORT jobject JNICALL 
Java_jogamp_opengl_x11_glx_GLX_dispatch_1glXChooseVisual(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject attribList, jint attribList_byte_offset, jlong procAddress) {
  typedef XVisualInfo *  (APIENTRY*_local_PFNGLXCHOOSEVISUALPROC)(Display *  dpy, int screen, int *  attribList);
  _local_PFNGLXCHOOSEVISUALPROC ptr_glXChooseVisual;
  int * _attribList_ptr = NULL;
  XVisualInfo *  _res;
  jobject jbyteSource;
  jobject jbyteCopy;
    if ( NULL != attribList ) {
        _attribList_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, attribList)) + attribList_byte_offset);
    }
  ptr_glXChooseVisual = (_local_PFNGLXCHOOSEVISUALPROC) (intptr_t) procAddress;
  assert(ptr_glXChooseVisual != NULL);
  _res = (* ptr_glXChooseVisual) ((Display *) (intptr_t) dpy, (int) screen, (int *) _attribList_ptr);
  if (NULL == _res) return NULL;

  _initClazzAccess(env);

  jbyteSource = (*env)->NewDirectByteBuffer(env, _res, sizeof(XVisualInfo));
  jbyteCopy   = (*env)->CallStaticObjectMethod(env, clazzBuffers, cstrBuffers, jbyteSource);

  (*env)->DeleteLocalRef(env, jbyteSource);
  XFree(_res);

  return jbyteCopy;
}
Ejemplo n.º 4
0
/*   Java->C glue code:
 *   Java package: jogamp.opengl.x11.glx.GLX
 *    Java method: com.jogamp.common.nio.PointerBuffer dispatch_glXChooseFBConfig(long dpy, int screen, java.nio.IntBuffer attribList, java.nio.IntBuffer nitems)
 *     C function: GLXFBConfig *  glXChooseFBConfig(Display *  dpy, int screen, const int *  attribList, int *  nitems);
 */
JNIEXPORT jobject JNICALL 
Java_jogamp_opengl_x11_glx_GLX_dispatch_1glXChooseFBConfig(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject attribList, jint attribList_byte_offset, jobject nitems, jint nitems_byte_offset, jlong procAddress) {
  typedef GLXFBConfig *  (APIENTRY*_local_PFNGLXCHOOSEFBCONFIGPROC)(Display *  dpy, int screen, const int *  attribList, int *  nitems);
  _local_PFNGLXCHOOSEFBCONFIGPROC ptr_glXChooseFBConfig;
  int * _attribList_ptr = NULL;
  int * _nitems_ptr = NULL;
  GLXFBConfig *  _res;
  int count, i;
  jobject jbyteSource;
  jobject jbyteCopy;
    if ( NULL != attribList ) {
        _attribList_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, attribList)) + attribList_byte_offset);
    }
    if ( NULL != nitems ) {
        _nitems_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, nitems)) + nitems_byte_offset);
    }
  ptr_glXChooseFBConfig = (_local_PFNGLXCHOOSEFBCONFIGPROC) (intptr_t) procAddress;
  assert(ptr_glXChooseFBConfig != NULL);
  _res = (* ptr_glXChooseFBConfig) ((Display *) (intptr_t) dpy, (int) screen, (int *) _attribList_ptr, (int *) _nitems_ptr);
  count = _nitems_ptr[0];
  if (NULL == _res) return NULL;

  /**
   * Bug 961: Validate returned 'GLXFBConfig *', i.e. remove NULL pointer. 
   * Note: sizeof(GLXFBConfig) == sizeof(void*), a.k.a a 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)*sizeof(GLXFBConfig)); 
       }
       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;
}
Ejemplo n.º 5
0
/*   Java->C glue code:
 *   Java package: com.sun.opengl.impl.x11.glx.GLX
 *    Java method: XVisualInfo glXGetVisualFromFBConfig(long dpy, long config)
 *     C function: XVisualInfo *  glXGetVisualFromFBConfig(Display *  dpy, GLXFBConfig config);
 */
JNIEXPORT jobject JNICALL 
Java_com_sun_opengl_impl_x11_glx_GLX_glXGetVisualFromFBConfigCopied0__JJ(JNIEnv *env, jclass _unused, jlong dpy, jlong config) {
  XVisualInfo *  _res;
  _res = glXGetVisualFromFBConfig((Display *) (intptr_t) dpy, (GLXFBConfig) (intptr_t) config);
  if (_res == NULL) return NULL;

  _initClazzAccess(env);

  jobject jbyteSource = (*env)->NewDirectByteBuffer(env, _res, sizeof(XVisualInfo));
  jobject jbyteCopy   = (*env)->CallStaticObjectMethod(env,
                            clazzInternalBufferUtil, cstrInternalBufferUtil, jbyteSource);

  // FIXME: remove reference/gc jbyteSource ?? 
  XFree(_res);

  return jbyteCopy;
}
Ejemplo n.º 6
0
JNIEXPORT jboolean JNICALL 
Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboolean debug) {
    if( 0 == _initialized ) {
        if(debug) {
            errorHandlerDebug = 1;
        }
        X11UtilClazz = (jclass)(*env)->NewGlobalRef(env, clazz);

        _initClazzAccess(env);
        x11IOErrorHandlerEnable(1, env);
        NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 1, 1, debug ? 0 : 1, 0 /* no dpy, force, no sync */);
        _initialized=1;
        if(JNI_TRUE == debug) {
            fprintf(stderr, "Info: NativeWindow native init passed\n");
        }
    }
    return JNI_TRUE;
}
Ejemplo n.º 7
0
JNIEXPORT void JNICALL 
Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize0(JNIEnv *env, jclass _unused, jboolean firstUIActionOnProcess) {
    if(0==_initialized) {
        if( JNI_TRUE == firstUIActionOnProcess ) {
            if( 0 == XInitThreads() ) {
                fprintf(stderr, "Warning: XInitThreads() failed\n");
            } else {
                fprintf(stderr, "Info: XInitThreads() called for concurrent Thread support\n");
            }
        } else {
            fprintf(stderr, "Info: XInitThreads() _not_ called for concurrent Thread support\n");
        }

        _initClazzAccess(env);
        x11IOErrorHandlerEnable(1, env);
        _initialized=1;
    }
}
Ejemplo n.º 8
0
/*   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. 
   * Note: sizeof(GLXFBConfig) == sizeof(void*), a.k.a a pointer
   */
  i=0;
  while( i < count ) {
    if( NULL == _res[i] ) {
       if( 0 < count-i-1 ) {
         memmove(_res+i, _res+i+1, (count-i-1)*sizeof(GLXFBConfig));
       }
       count--;
    } else {
       i++;
    }
  }
  _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;
}
Ejemplo n.º 9
0
/*   Java->C glue code:
 *   Java package: jogamp.opengl.x11.glx.GLX
 *    Java method: XVisualInfo glXGetVisualFromFBConfig(long dpy, long config)
 *     C function: XVisualInfo *  glXGetVisualFromFBConfig(Display *  dpy, GLXFBConfig config);
 */
JNIEXPORT jobject JNICALL 
Java_jogamp_opengl_x11_glx_GLX_dispatch_1glXGetVisualFromFBConfig(JNIEnv *env, jclass _unused, jlong dpy, jlong config, jlong procAddress) {
  typedef XVisualInfo* (APIENTRY*_local_PFNGLXGETVISUALFROMFBCONFIG)(Display *  dpy, GLXFBConfig config);
  _local_PFNGLXGETVISUALFROMFBCONFIG ptr_glXGetVisualFromFBConfig;
  XVisualInfo *  _res;
  jobject jbyteSource;
  jobject jbyteCopy;
  ptr_glXGetVisualFromFBConfig = (_local_PFNGLXGETVISUALFROMFBCONFIG) (intptr_t) procAddress;
  assert(ptr_glXGetVisualFromFBConfig != NULL);
  _res = (* ptr_glXGetVisualFromFBConfig) ((Display *) (intptr_t) dpy, (GLXFBConfig) (intptr_t) config);
  if (_res == NULL) return NULL;

  _initClazzAccess(env);

  jbyteSource = (*env)->NewDirectByteBuffer(env, _res, sizeof(XVisualInfo));
  jbyteCopy   = (*env)->CallStaticObjectMethod(env, clazzBuffers, cstrBuffers, jbyteSource);

  (*env)->DeleteLocalRef(env, jbyteSource);
  XFree(_res);

  return jbyteCopy;
}