diff options
author | Sven Gothel <[email protected]> | 2012-07-24 00:14:02 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-07-24 00:14:02 +0200 |
commit | 00bef95008b02cc71e166da122884402e9381f44 (patch) | |
tree | 8a7a1c961b462a0d8cac49d02b1010d04ca30e38 /src/nativewindow/native/x11/Xmisc.c | |
parent | 90f2156e4c48386eb2ee06acc1169a7557851e88 (diff) |
Fix GraphicsConfigurationFactory: Map factory to device-type _and_ capabilities-type; Add a pre-set nativeVisualID to chooseGraphicsConfiguration(..)
Map factory to device-type _and_ capabilities-type:
- Allows using different GraphicsConfigurationFactory implementations for different capabilities-types.
Previous impl. failed to use an OpenGL agnostic CapabilitiesImmutable for 'chooseGraphicsConfiguration(..)'
since only the GL aware factory was mapped. The latter failed since it expected a GLCapabilitiesImmutable.
- The passed capabilities-type as well as device-type given at getFactory(..)
is traversed top-to-down to find a most suitable factory:
For-All devT := getTopDownDeviceTypes(deviceType)
For-All capsT := getTopDownCapabilitiesTypes(capabilitiesType)
f = factory.get(devT, capsT);
if(f) { return f; }
end
end
Add a pre-set nativeVisualID to chooseGraphicsConfiguration(..)
- In situations where a native visualID is already chosen [by external means for example],
but we still need to query a matching GraphicsConfiguration - we require to pass
a non VisualIDHolder.VID_UNDEFINED nativeVisualID.
We had a hack implemented before within some implementations and their static calls,
however an agnostic mechanism is required to implement new NativeSurface/Window's
platform agnostic.
- X11GLXGraphicsConfigurationFactory: respect a pre-set xvisualID
- X11GLXDrawableFactory.createProxySurfaceImpl(..) queries the given windowHandle's
visualID and 'chooses' the configuration accordingly. If the visualID is undefined
an exception is thrown, since window is invalid.
These mechanics are implicit for Windows and OSX.
Fix X11GLXGraphicsConfiguration.updateGraphicsConfiguration():
- Skip any action if a valid X11GLCapabilities is already chosen, i.e. w/ visualID.
Otherwise choose a suitable configuration incl. visualID.
The latter is quite impossible and invalid, since visualID must be defined at window creation time
and the update method is issued with a valid window.
X11 - Misc:
- Added 'int jogamp.nativewindow.x11.X11Lib.GetVisualIDFromWindow(..)'
- All returned visualID's are of type 'int'
Diffstat (limited to 'src/nativewindow/native/x11/Xmisc.c')
-rw-r--r-- | src/nativewindow/native/x11/Xmisc.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index 21771c9aa..fcba8580c 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -362,14 +362,40 @@ Java_jogamp_nativewindow_x11_X11Lib_XGetVisualInfo1__JJLjava_nio_ByteBuffer_2Lja return jbyteCopy; } -JNIEXPORT jlong JNICALL +JNIEXPORT jint JNICALL +Java_jogamp_nativewindow_x11_X11Lib_GetVisualIDFromWindow(JNIEnv *env, jclass _unused, jlong display, jlong window) { + Display * dpy = (Display *)(intptr_t)display; + Window w = (Window) window; + XWindowAttributes xwa; + jlong r = 0; // undefinded + + if(NULL==dpy) { + NativewindowCommon_throwNewRuntimeException(env, "invalid display connection.."); + return; + } + + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 1, 0, 1); + memset(&xwa, 0, sizeof(XWindowAttributes)); + XGetWindowAttributes(dpy, w, &xwa); + if(NULL != xwa.visual) { + r = (jint) XVisualIDFromVisual( xwa.visual ); + } else { + r = 0; + } + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + + return r; +} + + +JNIEXPORT jint JNICALL Java_jogamp_nativewindow_x11_X11Lib_DefaultVisualID(JNIEnv *env, jclass _unused, jlong display, jint screen) { jlong r; if(0==display) { NativewindowCommon_FatalError(env, "invalid display connection.."); } NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 1, 0, 0); - r = (jlong) XVisualIDFromVisual( DefaultVisual( (Display*) (intptr_t) display, screen ) ); + r = (jint) XVisualIDFromVisual( DefaultVisual( (Display*) (intptr_t) display, screen ) ); NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 0, 0, 0); return r; } |