仅使用OpenGL上下文ID(Java)渲染为纹理 [英] Render to texture using only OpenGL Context ID (Java)

查看:174
本文介绍了仅使用OpenGL上下文ID(Java)渲染为纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要渲染整个游戏窗口的纹理。我们只有来自客户端的Java SDK jar,并且只能访问它们在游戏运行时创建的窗口的OpenGL窗口上下文ID。

We need to render to texture entire game window. We have only java SDK jars from our client, and we can access only OpenGL Window context ID of window they create when game runs.

我的问题是

我们不能更改客户端代码,但是我们需要渲染编辑器

We cannot alter code of our client, but we need to render Editor windows on top of their java SDK.

他们使用LWJGL进行渲染。计划是将游戏渲染到单独的窗口中,类似于:

They are using LWJGL for rendering. Plan is to render game into separate window, similar to this:

我想这只能通过提到的渲染纹理来实现。

I guess this can be only achieved via mentioned rendering to texture.

推荐答案

如果可以使用常规的openGL命令,可能有一些您可以做的事情。
的问题是您需要更改openGL的状态机,该状态机可能与他们的游戏正在发生冲突。

if you can use the regular openGL commands, there might be something that you could do. the issue is that you'd need to change the openGL's state machine which might collude with what their game is doing.

可以解决的一件事,但是再次可能会与他们的工作发生冲突。
由于您要显示其最终输出,因此可以肯定地说,它们正在渲染到默认的帧缓冲区。因此,您将创建具有纹理颜色附件的自己的帧缓冲区,并使用 glBlitFramebuffer 将默认帧缓冲区拆分为自己的帧缓冲区。这样,您应该将默认的帧缓冲区放入纹理中。
为此,您需要执行 glBindFramebuffer(GL_READ_FRAMEBUFFER,0) glBindFramebuffer(GL_DRAW_FRAMEBUFFER,**您的缓冲区**)在设置操作目标之前。

One thing that could work, but again it might clash with what they are doing. Since you want to display their final output, it's a safe bet that their are rendering to the default framebuffer. So you create your own framebuffer that has a texture color attachment, and you blit the default framebuffer into your own with glBlitFramebuffer. That way you should get the default framebuffer into a texture. for that you need to do glBindFramebuffer(GL_READ_FRAMEBUFFER, 0) and glBindFramebuffer(GL_DRAW_FRAMEBUFFER, **your buffer**) before the blitting to set the targets of the operation.

由于我不知道您是否可以为每个框架编写代码,所以我不确定可以,但是可能值得一试。

Since I don't know if you can do code for every frame I'm not sure that would work, but it might be worth a try.

这篇关于仅使用OpenGL上下文ID(Java)渲染为纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆