如何让 Java3D 启动得更快?
我的应用程序需要几秒钟的时间才能显示第一个带有 Canvas3D
的窗口。 我对其进行了分析,发现瓶颈在于 SimpleUniverse.getPreferredConfiguration()
; 第一次调用需要三到四秒,并且必须在渲染场景之前调用它。
我正在使用 Direct3D 渲染器 (-Dj3d.rend=d3d
),因为 OpenGL 渲染器在我的显卡上崩溃。 我有一个运行单个显示器的集成 ATI 卡。
My application takes several seconds to show the first window with a Canvas3D
in it. I've profiled it and found that the bottleneck is in SimpleUniverse.getPreferredConfiguration()
; the first call takes three or four seconds, and it must be called before the scene can be rendered.
I'm using the Direct3D renderer (-Dj3d.rend=d3d
), because the OpenGL renderer crashes on my graphics card. I have an integrated ATI card running a single monitor.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
速度变慢的原因是
SimpleUniverse.getPreferredConfiguration()
使用的GraphicsDevice.getConfigurations()
在某些系统上非常慢。 请参阅此 java.net 论坛主题,它链接到此 Java3D 错误,它又链接到 此 Sun 错误:提到的解决方法是将
-Dsun.awt.nopixfmt=true
传递给JVM,这使得底层本机代码不调用DescribePixelFormat
。这显然不是一个完美的解决方案:
但由于我无论如何都使用 Direct3D,所以这不是问题。 启动时间缩短了 3.2 秒。
The reason for the slowdown is that
GraphicsDevice.getConfigurations()
, which is used bySimpleUniverse.getPreferredConfiguration()
, is very slow on some systems. See this java.net forum thread, which links to this Java3D bug, which in turn links to this Sun bug:The workaround mentioned is to pass
-Dsun.awt.nopixfmt=true
to the JVM, which makes the underlying native code not callDescribePixelFormat
.This apparently is not a perfect solution:
But since I was using Direct3D anyway, it's not a problem. This cut 3.2 seconds off of the startup time.