本文介绍了用JOGL画出画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个较大项目的一部分,我试图使用JOGL实现一个工具,该工具将3D渲染导出为位图格式。我们通过创建一个GLJPanel并绘制我们想要的场景然后提取位图来实现这一点。只要系统在屏幕上至少有一个可见窗口,这一切都可以正常工作 - 不一定包含我们正在绘制的面板的窗口。



但是,如果我们尝试要做到这一点,而不使任何窗口可见GLJPanel不会绘制。通过JOGL源代码我发现它不会绘制,除非它有一个有效的对等体 - 本质上,除非已经调用了addNotify()。文档说addNotify()仅在面板成为可见窗口层次的一部分时被调用。更改为GLCanvas并没有太大的区别 - 故障模式不同。 WindowsOnscreenGLDrawable.realized未设置,这意味着lockSurface返回 LOCK_SURFACE_NOT_READY ,导致makeCurrent()失败。



任何如何创建一个可以创建和导出3D场景而无需使窗口可见的Java应用程序,将非常欢迎。

解决方案

不知道我是否应该回答自己的问题,但现在我发现似乎正在开展工作。



关键是 GLPbuffer ,它是一个屏幕外的GLAutoDrawable,可以在没有可见组件的情况下创建。

有助于使其发挥作用。我会离开接受这个答案,直到我确认它是全功能的。



我也应该说,答案来自,而不是我自己的微薄脑袋。


As part of a larger project I'm trying to implement a facility using JOGL that will export 3D renderings to bitmap formats. We do this by creating a GLJPanel and drawing the scene we want to it, then extracting the bitmap. This all works fine as long as the system has at least one visible window on the screen - not necessarily the window containing the panel we are drawing to.

But if we try to do this without making any window visible the GLJPanel won't draw. Stepping through the JOGL source I find that it won't draw unless it has a valid peer - essentially unless addNotify() has been called on it. The documentation says that addNotify() is only called when the panel is made part of a visible window heirarchy. Changing to a GLCanvas doesn't make much difference - the failure mode is different. WindowsOnscreenGLDrawable.realized is not set, and this means lockSurface returns LOCK_SURFACE_NOT_READY, causing makeCurrent() to fail.

Any help would be welcome on how to create a Java app that can create and export 3D scenes without having to make it's window visible.

解决方案

Not sure if I should be answering my own question, but here goes with what I found seems to work now.

The key is GLPbuffer, which is an offscreen GLAutoDrawable and can be created without a visible component heirarchy.

This article was helpful in getting it to work. I'll leave off accepting this answer until I've confirmed it's fully functional.

I should also say that the answer came from this forum, not my own meagre brain.

这篇关于用JOGL画出画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 01:33