Hi, i’ve read this wiki site:
https://www.khronos.org/opengl/wiki/Pixel_Buffer_Object#Downloads
memory isnt an issue for me
i want to make the download operation as efficient as possible, so i’m considering to use an additional rendertarget (a “double-buffered” rendertarget)
my current framebuffer:
2 color attachments, 1 is a rgba color texture, 1 is a 32bit integer texture to store unique “ID” values of all rendered objects
each frame:
– clear all attachments
– render into both attachments simultaneously (MRT)
– read the integer texture (basically 1 pixel at cursor position)
– glBlitFramebuffer(…) to copy the rgba texture into the windows framebuffer
question: how should i do that ???
assuming my attachments are:
GL_COLOR_ATTACHMENT0 rgba texture
GL_COLOR_ATTACHMENT1 1st integer texture
GL_COLOR_ATTACHMENT2 2nd integer texture
should i call each frame:
GLenum buffers[] = {
GL_COLOR_ATTACHMENT0, // rgba
GL_COLOR_ATTACHMENT1, // 1st integer texture
};
glDrawbuffers(2, buffers);
glReadBuffer(GL_COLOR_ATTACHMENT2);
… and every next frame:
GLenum buffers[] = {
GL_COLOR_ATTACHMENT0, // rgba
GL_COLOR_ATTACHMENT2, // 2st integer texture
};
glDrawbuffers(2, buffers);
glReadBuffer(GL_COLOR_ATTACHMENT1);
or is there a better solution ? perhaps using a second FBO ?
or can i make somehow use of GL_READ_FRAMEBUFFER and GL_DRAW_FRAMEBUFFER ?
thanks for any suggestions !!