Reputation: 1110
I am looking for a way to use the JOGL library to capture the output of a shader in a BufferedImage. Do I need to create a frame buffer?
(Also, I would like to have the shader use another BufferedImage as input, so I would have to upload that as a texture I assume. This seems like the easier part though.)
Upvotes: 1
Views: 206
Reputation: 211278
Do I need to create a frame buffer?
There is always a framebuffer, the default framebuffer (0). You can get the pixels of the color plane of the currently bound framebuffer (GL_FRAMEBUFFER
/GL_DRAW_FRAMEBUFFER
) with glReadPixels
.
Also, I would like to have the shader use another BufferedImage as input ...
You can generate a named framebuffer and attach a texture to its color plane. So you can render directly into this texture. Finally, you can use this texture in another shader stage. (Texture data can be read with glGetTexImage
).
You can also use a Pixel Buffer to copy the pixels from the framebuffer to texture image. Bind a buffer to the GL_PIXEL_PACK_BUFFER
target and use glReadPixels
to copy the pixel into the buffer. Bind the buffer to the GL_PIXEL_UNPACK_BUFFER
target and write the data into the texture image with glTexImage2D
.
Upvotes: 1