summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik De Rijcke <[email protected]>2015-05-06 16:30:42 +0200
committerSven Gothel <[email protected]>2019-11-21 03:28:50 +0100
commitf4281b5ee80d7674134bfee357695a98382884a3 (patch)
treee54ad95c7e67505d9605de2a988eed1350ed7f59
parentcd07cb251ae2df8e8cfd455a91cbe7d5394a77e0 (diff)
detect gbm platform on linux when no other display server is running
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java23
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java48
2 files changed, 65 insertions, 6 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
index fcd4f54eb..5adba1703 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
@@ -44,6 +44,7 @@ import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.LongObjectHashMap;
import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
import com.jogamp.opengl.egl.EGL;
+import com.jogamp.opengl.egl.EGLExt;
/**
* This implementation provides recursive calls to
@@ -196,7 +197,27 @@ public class EGLDisplayUtil {
}
return singletonEGLDisplay.eglDisplay;
}
- final long eglDisplay = EGL.eglGetDisplay(nativeDisplay_id);
+
+ final String nativeWindowType = NativeWindowFactory.getNativeWindowType(false);
+ int platform = 0;
+ final long eglDisplay;
+ if(nativeWindowType == NativeWindowFactory.TYPE_X11) {
+ platform = EGLExt.EGL_PLATFORM_X11_KHR;
+ }else if(nativeWindowType == NativeWindowFactory.TYPE_ANDROID) {
+ platform = EGLExt.EGL_PLATFORM_ANDROID_KHR;
+ }else if(nativeWindowType == NativeWindowFactory.TYPE_GBM){
+ platform = EGLExt.EGL_PLATFORM_GBM_MESA;
+ } else if(nativeWindowType == NativeWindowFactory.TYPE_WAYLAND){
+ // TODO
+ platform = EGLExt.EGL_PLATFORM_WAYLAND_KHR;
+ }
+ if( platform != 0){
+ eglDisplay = EGL.eglGetPlatformDisplay(platform, nativeDisplay_id, null);
+ }
+ else{
+ eglDisplay = EGL.eglGetDisplay(nativeDisplay_id);
+ }
+
if(DEBUG) {
System.err.println("EGLDisplayUtil.eglGetDisplay.X: eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+
EGLContext.toHexString(eglDisplay)+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
index 63063bef7..5539a13b1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
@@ -33,6 +33,7 @@
package com.jogamp.nativewindow;
+import java.io.File;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -43,14 +44,12 @@ import java.util.List;
import java.util.Map;
import com.jogamp.nativewindow.util.Point;
-import com.jogamp.nativewindow.util.PointImmutable;
-
import jogamp.common.os.PlatformPropsImpl;
import jogamp.nativewindow.BcmVCArtifacts;
import jogamp.nativewindow.Debug;
import jogamp.nativewindow.NativeWindowFactoryImpl;
-import jogamp.nativewindow.ToolkitProperties;
import jogamp.nativewindow.ResourceToolkitLock;
+import jogamp.nativewindow.ToolkitProperties;
import jogamp.nativewindow.WrappedWindow;
import jogamp.nativewindow.ios.IOSUtil;
import jogamp.nativewindow.macosx.OSXUtil;
@@ -84,6 +83,12 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen;
public abstract class NativeWindowFactory {
protected static final boolean DEBUG;
+ /** Wayland/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
+ public static final String TYPE_WAYLAND = ".wayland";
+
+ /** GBM/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
+ public static final String TYPE_GBM = ".gbm";
+
/** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
public static final String TYPE_EGL = ".egl";
@@ -156,7 +161,6 @@ public abstract class NativeWindowFactory {
return TYPE_WINDOWS;
case OPENKODE:
return TYPE_EGL;
-
case LINUX:
case FREEBSD:
case SUNOS:
@@ -165,10 +169,44 @@ public abstract class NativeWindowFactory {
if( BcmVCArtifacts.guessVCIVUsed() ) {
return TYPE_BCM_VC_IV;
}
- return TYPE_X11;
+ if(guessX()){
+ return TYPE_X11;
+ }
+ if(guessWayland()){
+ //TODO
+ return TYPE_WAYLAND;
+ }
+ if(guessGBM()){
+ return TYPE_GBM;
+ }
+ return TYPE_DEFAULT;
}
}
+ private static boolean guessX() {
+ return System.getProperty("DISPLAY") !=null;
+ }
+
+ private static boolean guessWayland() {
+ //TODO we can/should do a more elaborate check and try looking for a wayland-0 socket in $XDG_RUNTIME_DIR
+ return System.getProperty("WAYLAND_DISPLAY") !=null;
+ }
+
+ private static boolean guessGBM() {
+ //FIXME this is not the best way to check if we have gbm-egl support, but does a good easy way actually exist?
+ return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ private final File vcliblocation = new File(
+ "/dev/dri/card0");
+ @Override
+ public Boolean run() {
+ if ( vcliblocation.isFile() ) {
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ } ).booleanValue();
+ }
+
static {
final boolean[] _DEBUG = new boolean[] { false };
final String[] _tmp = new String[] { null };