In OpenGL, is there a way to use framebuffer data as vertex data without moving the data through the CPU? Ideally, a framebuffer object could be recast as a vertex buffer object directly on the GPU. I’d like to use the fragment shader to generate a mesh and then render that mesh.
Share
There’s a couple ways you could go about this, the first has already been mentioned by spudd86 (except you need to use
GL_PIXEL_PACK_BUFFER, that’s the one that’s written to byglReadPixels).The other is to use a framebuffer object and then read from its texture in your vertex shader, mapping from a vertex id (that you would have to manage) to a texture location. If this is a one-time operation though I’d go with copying it over to a PBO and then binding into
GL_ARRAY_BUFFERand then just using it as a VBO.