问题
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.
My question is, is window context enough to somehow render it to texture?
We cannot alter code of our client, but we need to render Editor windows on top of their java SDK.
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/50895022/render-to-texture-using-only-opengl-context-id-java