系统:ubuntu22.04
MATLAB版本:R2024a
打开MATLAB时命令行显示:
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x1d7b9905, isOwner false, <dc8a8ee, 6f08ce60>[count 0, qsz 0, owner <NULL>]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
绘图时报错:
MATLAB 遇到了低级的图形错误,可能绘制不正确。
请阅读解决低级的图形错误来了解有关避免出现此问题的举措,然后重新启动 MATLAB。
若要向 MathWorks 公司的技术支持部门提供有关此问题的详细信息,
请将此文件连同您的服务请求一起提交。
解决步骤:
1.首先按照matlab官方文档,查看OpenGL支持
Matlab
info = rendererinfo
输出会显示当前是使用软件渲染('OpenGL Software')还是硬件加速('OpenGL Hardware')
Matlab
GraphicsRenderer: 'OpenGL Software'
Vendor: 'Brian Paul'
Version: '2.1 Mesa 17.1.3'
RendererDevice: 'Mesa X11'
Details: [1×1 struct]
根据需要指定OpenGL实现后重新启动
Matlab
opengl('save','software')
opengl('save','hardware')
2.设定好之后发现还是存在同样的问题,因为之前曾经安装过远程桌面控制软件todesk,所以卸载之后重新进行上面的操作,重新启动matlab后可以正常运行。
bash
sudo apt-get remove --purge todesk
sudo apt-get autoremove