[英]Stereo problems on Linux using Java 7 - how to change the GC of a component after it has been added to a parent
I have an AWT canvas contained within a JPanel and displayed on screen. 我有一个包含在JPanel中并显示在屏幕上的AWT画布。 I currently use Java 7 update 45 and run on Red Hat 6.
我目前使用Java 7 update 45并在Red Hat 6上运行。
When the user requests an openGL stereo capable canvas, i remove the existing canvas, create a new canvas that chooses a stereo visual and sets the appropriate GraphicsConfiguration on the canvas. 当用户请求具有openGL立体声功能的画布时,我将删除现有的画布,创建一个新的画布,该画布选择一个立体视觉效果并在画布上设置适当的GraphicsConfiguration。 The problem is, with new changes made in Java 7, when this canvas is added back to the JPanel, the GraphicsConfiguration(GC) of the Jpanel overwrites the GraphicsConfiguration of the Canvas.
问题在于,随着Java 7中的新更改,当将此画布重新添加到JPanel时,Jpanel的GraphicsConfiguration(GC)会覆盖Canvas的GraphicsConfiguration。
This happens in java.awt.Container.addImpl() where it calls the package scoped method Component.setGraphicsConfiguration() . 这发生在java.awt.Container.addImpl()中 ,在该处它调用包范围的方法Component.setGraphicsConfiguration() 。
I am currently using Reflection on this package scoped method to call the method from my code and change the GC on the canvas. 我目前在此包范围方法上使用Reflection,以从我的代码中调用该方法并更改画布上的GC。
Is there any better solution than this ? 有没有比这更好的解决方案了? In other words, how to change the GC of a component after it has been added to a parent ?
换句话说,如何在将组件添加到父组件后更改其GC?
I suggest you do not change the GC at all. 我建议您根本不要更改GC。 Instead just try to create a stereo capable GC and allow fallback to non-stereoscopic GC.
而是尝试创建具有立体声功能的GC,并允许回退到非立体GC。 If that succeeds enable the stereoscopic rendering path and menu entries.
如果成功,则启用立体渲染路径和菜单项。
The Stereoscopic regression caused by the JDK 7 AWT changes is reported in and worked on in the following bugreport: https://bugs.openjdk.java.net/browse/JDK-8036875 - Component.setGraphicsConfiguration() breaks some 3D applications 在以下错误报告中报告了JDK 7 AWT更改引起的立体回归并进行了处理: https ://bugs.openjdk.java.net/browse/JDK-8036875-Component.setGraphicsConfiguration()破坏了某些3D应用程序
A workaround made by "babor" for Java3D Canvas3D users is to override the Canvas3D hierarchyChanged method and update the topmost component using reflection to use the stereoscopic graphics configuration. “ babor”对Java3D Canvas3D用户的解决方法是重写Canvas3DarchitectureChanged方法,并使用反射更新最顶层的组件以使用立体图形配置。 http://forum.jogamp.org/Java3D-stereo-tp4029914p4031792.html
http://forum.jogamp.org/Java3D-stereo-tp4029914p4031792.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.