我的应用程序需要几秒钟才能显示第一个带有 Canvas3D
的窗口。我分析了它,发现瓶颈在 SimpleUniverse.getPreferredConfiguration()
;第一次调用需要三四秒,必须在渲染场景之前调用它。
我正在使用 Direct3D 渲染器 (-Dj3d.rend=d3d
),因为 OpenGL 渲染器在我的显卡上崩溃了。我有一个集成的 ATI 卡,运行一个显示器。
最佳答案
速度变慢的原因是 SimpleUniverse.getPreferredConfiguration()
使用的 GraphicsDevice.getConfigurations()
在某些系统上非常慢。参见 this java.net forum thread ,链接到 this Java3D bug ,它又链接到 this Sun bug :
The problem is that
::DescribePixelFormat
Win32 call is slow - takes up to 60ms to complete. ...
With the suggested workaround (which elminats [sic] the offending win32 calls) the time is significantly improved (to, like, 0ms).
提到的解决方法是将-Dsun.awt.nopixfmt=true
传递给JVM,这使得底层本地代码不调用DescribePixelFormat
.
这显然不是一个完美的解决方案:
... some applications which use OpenGL with Java may not work correctly.
但由于我一直在使用 Direct3D,所以这不是问题。 这将启动时间缩短了 3.2 秒。
关于java - 我怎样才能使 Java3D 启动得更快?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/507987/