summaryrefslogtreecommitdiffstats
path: root/make/config/nativewindow
diff options
context:
space:
mode:
Diffstat (limited to 'make/config/nativewindow')
-rw-r--r--make/config/nativewindow/jawt-CustomJavaCode.java27
-rw-r--r--make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java38
-rw-r--r--make/config/nativewindow/jawt-common.cfg26
-rw-r--r--make/config/nativewindow/jawt-macosx.cfg14
-rw-r--r--make/config/nativewindow/jawt-win32.cfg15
-rw-r--r--make/config/nativewindow/jawt-x11.cfg15
-rw-r--r--make/config/nativewindow/x11-CustomJavaCode.java35
-rw-r--r--make/config/nativewindow/x11-lib.cfg45
8 files changed, 215 insertions, 0 deletions
diff --git a/make/config/nativewindow/jawt-CustomJavaCode.java b/make/config/nativewindow/jawt-CustomJavaCode.java
new file mode 100644
index 000000000..3223a74b1
--- /dev/null
+++ b/make/config/nativewindow/jawt-CustomJavaCode.java
@@ -0,0 +1,27 @@
+private static volatile JAWT jawt;
+
+/** Helper routine for all users to call to access the JAWT. */
+public static JAWT getJAWT() {
+ if (jawt == null) {
+ synchronized (JAWT.class) {
+ if (jawt == null) {
+ JAWTUtil.initSingleton();
+ // Workaround for 4845371.
+ // Make sure the first reference to the JNI GetDirectBufferAddress is done
+ // from a privileged context so the VM's internal class lookups will succeed.
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ JAWT j = JAWT.create();
+ j.setVersion(JAWTFactory.JAWT_VERSION_1_4);
+ if (!JAWTFactory.JAWT_GetAWT(j)) {
+ throw new RuntimeException("Unable to initialize JAWT");
+ }
+ jawt = j;
+ return null;
+ }
+ });
+ }
+ }
+ }
+ return jawt;
+}
diff --git a/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java b/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java
new file mode 100644
index 000000000..aad0ab261
--- /dev/null
+++ b/make/config/nativewindow/jawt-DrawingSurfaceInfo-CustomJavaCode.java
@@ -0,0 +1,38 @@
+public JAWT_PlatformInfo platformInfo() {
+ return newPlatformInfo(platformInfo0(getBuffer()));
+}
+
+private native ByteBuffer platformInfo0(Buffer jthis0);
+
+private static java.lang.reflect.Method platformInfoFactoryMethod;
+
+private static JAWT_PlatformInfo newPlatformInfo(ByteBuffer buf) {
+ if (platformInfoFactoryMethod == null) {
+ String osName = (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("os.name").toLowerCase();
+ }
+ });
+ try {
+ Class factoryClass;
+ if (osName.startsWith("wind")) {
+ factoryClass = Class.forName("com.jogamp.nativewindow.impl.jawt.windows.JAWT_Win32DrawingSurfaceInfo");
+ } else if (osName.startsWith("mac os x")) {
+ factoryClass = Class.forName("com.jogamp.nativewindow.impl.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo");
+ } else {
+ // Assume Linux, Solaris, etc. Should probably test for these explicitly.
+ factoryClass = Class.forName("com.jogamp.nativewindow.impl.jawt.x11.JAWT_X11DrawingSurfaceInfo");
+ }
+ platformInfoFactoryMethod = factoryClass.getMethod("create",
+ new Class[] { ByteBuffer.class });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ try {
+ return (JAWT_PlatformInfo)
+ platformInfoFactoryMethod.invoke(null, new Object[] { buf });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+}
diff --git a/make/config/nativewindow/jawt-common.cfg b/make/config/nativewindow/jawt-common.cfg
new file mode 100644
index 000000000..4ed0a88f1
--- /dev/null
+++ b/make/config/nativewindow/jawt-common.cfg
@@ -0,0 +1,26 @@
+# Common JAWT config file
+Style AllStatic
+Package com.jogamp.nativewindow.impl.jawt
+JavaClass JAWTFactory
+JavaOutputDir gensrc/classes
+#NativeOutputDir gensrc/native/<PLATFORM>
+
+HierarchicalNativeOutput false
+
+Opaque boolean jboolean
+Opaque long struct jawt_DrawingSurface*
+
+ReturnValueCapacity GetDrawingSurface sizeof(JAWT_DrawingSurface)
+ReturnValueCapacity GetDrawingSurfaceInfo sizeof(JAWT_DrawingSurfaceInfo)
+
+IgnoreField JAWT GetComponent
+IgnoreField JAWT_DrawingSurfaceInfo platformInfo
+
+IncludeAs CustomJavaCode JAWT jawt-CustomJavaCode.java
+
+CustomCCode #include <jawt.h>
+
+import java.security.*
+import com.jogamp.nativewindow.impl.jawt.*
+
+IncludeAs CustomJavaCode JAWT_DrawingSurfaceInfo jawt-DrawingSurfaceInfo-CustomJavaCode.java
diff --git a/make/config/nativewindow/jawt-macosx.cfg b/make/config/nativewindow/jawt-macosx.cfg
new file mode 100644
index 000000000..e018af0dc
--- /dev/null
+++ b/make/config/nativewindow/jawt-macosx.cfg
@@ -0,0 +1,14 @@
+# This .cfg file is used to generate the interface to the JAWT, which
+# is used by the MacOSXOnscreenGLContext.
+Include jawt-common.cfg
+NativeOutputDir gensrc/native/MacOSX
+
+Opaque long void *
+Opaque long NSView *
+
+CustomCCode #include <inttypes.h>
+CustomCCode #include </usr/include/machine/types.h>
+
+StructPackage JAWT_MacOSXDrawingSurfaceInfo com.jogamp.nativewindow.impl.jawt.macosx
+EmitStruct JAWT_MacOSXDrawingSurfaceInfo
+Implements JAWT_MacOSXDrawingSurfaceInfo JAWT_PlatformInfo
diff --git a/make/config/nativewindow/jawt-win32.cfg b/make/config/nativewindow/jawt-win32.cfg
new file mode 100644
index 000000000..00b3a3322
--- /dev/null
+++ b/make/config/nativewindow/jawt-win32.cfg
@@ -0,0 +1,15 @@
+# This .cfg file is used to generate the interface to the JAWT, which
+# is used by the WindowsOnscreenGLContext.
+Include jawt-common.cfg
+NativeOutputDir gensrc/native/Windows
+
+Opaque long HDC
+
+IgnoreField JAWT_Win32DrawingSurfaceInfo null
+IgnoreField JAWT_Win32DrawingSurfaceInfo hpalette
+
+Include ../intptr.cfg
+
+StructPackage JAWT_Win32DrawingSurfaceInfo com.jogamp.nativewindow.impl.jawt.windows
+EmitStruct JAWT_Win32DrawingSurfaceInfo
+Implements JAWT_Win32DrawingSurfaceInfo JAWT_PlatformInfo
diff --git a/make/config/nativewindow/jawt-x11.cfg b/make/config/nativewindow/jawt-x11.cfg
new file mode 100644
index 000000000..4e7ed267b
--- /dev/null
+++ b/make/config/nativewindow/jawt-x11.cfg
@@ -0,0 +1,15 @@
+# This .cfg file is used to generate the interface to the JAWT, which
+# is used by the X11OnscreenGLContext.
+Include jawt-common.cfg
+NativeOutputDir gensrc/native/X11
+
+Opaque long Drawable
+Opaque long Display *
+
+IgnoreField JAWT_X11DrawingSurfaceInfo GetAWTColor
+
+CustomCCode #include <inttypes.h>
+
+StructPackage JAWT_X11DrawingSurfaceInfo com.jogamp.nativewindow.impl.jawt.x11
+EmitStruct JAWT_X11DrawingSurfaceInfo
+Implements JAWT_X11DrawingSurfaceInfo JAWT_PlatformInfo
diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java
new file mode 100644
index 000000000..5afa86737
--- /dev/null
+++ b/make/config/nativewindow/x11-CustomJavaCode.java
@@ -0,0 +1,35 @@
+
+ /** Interface to C language function: <br> <code> XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * ); </code> */
+ public static XVisualInfo[] XGetVisualInfo(long arg0, long arg1, XVisualInfo arg2, int[] arg3, int arg3_offset)
+ {
+ if(arg3 != null && arg3.length <= arg3_offset)
+ throw new RuntimeException("array offset argument \"arg3_offset\" (" + arg3_offset + ") equals or exceeds array length (" + arg3.length + ")");
+ java.nio.ByteBuffer _res;
+ _res = XGetVisualInfo1(arg0, arg1, ((arg2 == null) ? null : arg2.getBuffer()), arg3, Buffers.SIZEOF_INT * arg3_offset);
+
+ if (_res == null) return null;
+ Buffers.nativeOrder(_res);
+ XVisualInfo[] _retarray = new XVisualInfo[getFirstElement(arg3, arg3_offset)];
+ for (int _count = 0; _count < getFirstElement(arg3, arg3_offset); _count++) {
+ _res.position(_count * XVisualInfo.size());
+ _res.limit ((1 + _count) * XVisualInfo.size());
+ java.nio.ByteBuffer _tmp = _res.slice();
+ _res.position(0);
+ _res.limit(_res.capacity());
+ _retarray[_count] = XVisualInfo.create(_tmp);
+ }
+ return _retarray;
+ }
+
+ /** Entry point to C language function: <code> XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * ); </code> */
+ private static native java.nio.ByteBuffer XGetVisualInfo1(long arg0, long arg1, java.nio.ByteBuffer arg2, Object arg3, int arg3_byte_offset);
+
+ public static native long DefaultVisualID(long display, int screen);
+
+ public static native long CreateDummyWindow(long display, int screen_index, long visualID);
+ public static native void DestroyDummyWindow(long display, long window);
+
+ public static native int XCloseDisplay(long display);
+ public static native void XUnlockDisplay(long display);
+ public static native void XLockDisplay(long display);
+
diff --git a/make/config/nativewindow/x11-lib.cfg b/make/config/nativewindow/x11-lib.cfg
new file mode 100644
index 000000000..e554259b8
--- /dev/null
+++ b/make/config/nativewindow/x11-lib.cfg
@@ -0,0 +1,45 @@
+# This .cfg file is used to generate the interface to the GLX routines
+# used internally by the X11GLContext implementation.
+Package com.jogamp.nativewindow.impl.x11
+JavaClass X11Lib
+Style AllStatic
+
+HierarchicalNativeOutput false
+
+JavaOutputDir gensrc/classes
+NativeOutputDir gensrc/native/X11
+
+# Imports needed by all glue code
+Import java.nio.*
+Import java.util.*
+
+# XID needs to be treated as a long for 32/64 bit compatibility
+Opaque long XID
+
+Opaque long Display *
+Opaque boolean Bool
+Opaque long GLXFBConfig
+
+IncludeAs CustomJavaCode X11Lib x11-CustomJavaCode.java
+# Now resides in x11/Xmisc.c: IncludeAs CustomCCode x11-CustomCCode.c
+
+ArgumentIsString XOpenDisplay 0
+ReturnsString XDisplayString
+
+# We have Custom code for the following
+Ignore XGetVisualInfo
+
+ManuallyImplement XCloseDisplay
+ManuallyImplement XUnlockDisplay
+ManuallyImplement XLockDisplay
+
+# Helper routine to make the ReturnedArrayLength expression below work correctly
+CustomJavaCode X11Lib private static int getFirstElement(IntBuffer buf) { return buf.get(buf.position()); }
+CustomJavaCode X11Lib private static int getFirstElement(int[] arr, int offset) { return arr[offset]; }
+
+CustomJavaCode XVisualInfo public static XVisualInfo create(XVisualInfo s) { XVisualInfo d = XVisualInfo.create(); d.getBuffer().put(s.getBuffer()); d.getBuffer().rewind(); s.getBuffer().rewind(); return d; }
+
+CustomCCode #include <inttypes.h>
+CustomCCode #include <X11/Xlib.h>
+CustomCCode #include <X11/Xutil.h>
+