JavaFX 0x300b:无法获取 EGL 表面

JavaFX 0x300b: Could not get EGL surface

我正在尝试在嵌入式环境 (buildroot) 中的树莓派 3 上 运行 javafx 示例,我想 运行 它没有 X。当我 运行命令:

/root/jre-13.0.1/bin/java  -Dfile.encoding=UTF-8 --add-modules javafx.controls,javafx.fxml -Dprism.verbose=true -Djavafx.verbose=true -Dglass.platform=Monocle -Dprism.order=es2 -Djava.library.path=/root/jre-13.0.1/lib/ -Dembedded=monocle   -jar /home/root/NetBeansProjects//JavaFXFXML/dist/JavaFXFXML.jar 

我收到以下错误:

cmd : cd '/home/root/NetBeansProjects//JavaFXFXML'; '/root/jre-13.0.1//bin/java'  -Dfile.encoding=UTF-8 --add-modules javafx.controls,javafx.fxml -Dprism.verbose=true -Djavafx.verbose=true -Dglass.platform=Monocle -Dprism.order=es2 -Djava.library.path=/root/jre-13.0.1/lib/ -Dembedded=monocle   -jar /home/root/NetBeansProjects//JavaFXFXML/dist/JavaFXFXML.jar 
JavaFX launchApplication method: launchMode=LM_JAR
Prism pipeline init order: 
es2 
Using Double Precision Marlin Rasterizer
Using dirty region optimizations
Using system sized mask for primitives
Not 
f
orcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.es2.ES2Pipeline
Loading ES2 native library ... prism_es2_monocle
Loaded /root/jre-13.0.1/lib/libprism_es2_monocle.so from java.library.path
    succeeded.
GLFactory using com.sun.prism.es2.MonocleGLFactory
Loaded /root/jre-13.0.1/lib/libglass_monocle.so from java.library.path
com.sun.glass.ui.monocle.GLException: 0x300b: Could not get EGL surface
    at javafx.graphics/com.sun.glass.ui.monocle.AcceleratedScreen.<init>(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.monocle.NativePlatform.getAcceleratedScreen(Unknown Source)
    at javafx.graphics/com.sun.prism.es2.MonocleGLFactory.initialize(Unknown Source)
    at javafx.graphics/com.sun.prism.es2.ES2Pipeline.<clinit>(Unknown Source)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Unknown Source)
    at javafx.graphics/com.sun.prism.GraphicsPipeline.createPipeline(Unknown Source)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(Unknown Source)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
(X) Got class = class com.sun.prism.es2.ES2Pipeline
GraphicsPipeline.createPipeline: error initializing pipeline com.sun.prism.es2.ES2Pipeline
Graphics Device initialization failed for :  es2

我用运行 hello_triangle 和hello_dispmanx 的例子来测试gpu 加速,那里没有问题。 不知道为什么我会收到 Could not get EGL surface 错误,有什么方法可以调试此错误

Java 设置:

# java --version
openjdk 13.0.1-BellSoft 2019-10-15
OpenJDK Runtime Environment (build 13.0.1-BellSoft+9)
OpenJDK Server VM (build 13.0.1-BellSoft+9, mixed mode)

我终于明白了…… 由于我使用的是 buildroot 所有 raspberry pi userland (GPU) 库都在 /usr/lib 文件夹中。但是,深入monocle源码,更确切地说是在DispmanPlatformFactory.java中,我们可以看到他们匹配平台的方式是在/opt/vc/lib中搜索不存在的libbcm_host.so在 buildroot 配置中。对于那些使用 buildroot 的人来说,一个快速的解决方法是在 /opt/vc/lib

中创建一个符号 link 到 libbcm_host.so