EXT_pixel_buffer_object and render to vertex array

hello everyone!
I’ve got a problem with render-to-vertex-array functionality and I hope someone can bring some more light to it. :rolleyes:
I’m trying to use render-to-vertex-array functionality in a platform independent way (for Windows and Linux). The idea is to pass the geometry to the graphics card (NVidia GeForce 6600GT) as a texture, render it to a quad with a fragment program (with GLSL), read it back from the frame buffer into graphics memory and either alter it with a new vertex program or render it directly as a vertex array with the standard OpenGL fixed functionality.

I’ve searched quite extensively and finally I’ve found out that the extension EXT_pixel_buffer_object should allow me to do exactly what I want… but (there’s always a but) I can’t get anything but a black screen… and with an OpenGL debugger I only can assure that my texture (GL_RGB) with the geometry is properly loaded on the card. So it must be either a problem with the read back of the framebuffer to the buffer object (glReadPixels) or with the actual rendering of the vertex array.
Here is a fragment of my code illustrating the problem:

// FIRST PASS: Render texture to a quad
glUseProgramObjectARB( myGLSLProgram );
GLuint myBufferIDs = new GLuint[1];
glGenBuffersARB( 1, myBufferIDs );
glBindBufferARB( GL_PIXEL_PACK_BUFFER_EXT, myBufferIDs[0] );
glDrawBuffer( GL_FRONT );

// SECOND PASS: Read back from framebuffer and render vertex array
glUseProgramObjectARB( 0 );
glBindBufferARB( GL_PIXEL_PACK_BUFFER_EXT, myBufferIDs[0] );
glReadBuffer( GL_FRONT );
glReadPixels( 0, 0, textureSize, textureSize, GL_RGB, GL_FLOAT, (char *)NULL );
glBindBufferARB( GL_ARRAY_BUFFER, myBufferIDs[0] );
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, (char *)NULL );
for( int stripNr = 0; stripNr < totalNumOfStrips; stripNr++ ) {
    glDrawArrays( GL_TRIANGLE_STRIP, firstVertIndx, thisStripNumOfVerts );

So, what I’m doing is pretty much a reproduction of the example from the extension specification and I think it should work, but it doesn’t. I’ve tried both on Windows and on Linux with no success. :frowning:
Does anyone have any experience with this extension and render-to-vertex-array? Or any other sugestion how to do such thing without PBOs? Supposed that I’m doing something wrong and the extension can be actually used for this purpose, is there any restriction on the use of vertex arrays (indexed verts, interleaved attributes…)?

Thanks in advance for any reply :wink:

when you say ‘framebuffer’, do you mean the actual window or a pbuffer/FBO?

Using the window probably won’t do what you want, since it is probably 8bit/color, so all your vertices will get remapped to 0-1 I think (possibly needing a trip through the CPU to convert to float, so probably slow as well).

You probably want a 32 bit float pbuffer(or FBO), make sure to turn of blending (maybe some other stuff, check nvidia docs for the limitations of rendering to 32bit buffers).

You might also consider testing speed of vertex texturing if you don’t mind being limited to gf6+, not sure how that would compare to doing a copy with PBO…

Download http://rttv.users.sbb.co.yu/VideoPlayer.zip

This is my framework. In this archive you’ll find Test_PBO_VBO class. This demo is video player but you can change it to another demo - RTVA!

  1. Open project
  2. Remove VideoPlayer class (.cpp & .h)
  3. Remove DirectShow folder,
  4. Open Test_PBO_VBO.cpp and uncomment last line.
  5. Rebuild and run. You’ll see wave function.

Trick is to render to pbuffer then do glReadPixels to PBO, rebind PBO as VBO, setup vertex pointers and render.


Thanks a lot for your help, guys!
Yes, you’re right, I’m currently rendering to the framebuffer of the actual window in the first pass (actually to the front buffer so that I can see directly what’s happening).
I’ll try and render to a floating point pbuffer now (thank you for your framework yooyo!) and let you know as soon as I’ve got any results :slight_smile:

Btw, I think the documentation of PBOs is quite tricky on this point. In the example 1: Render to a vertex array, it says literally “render vertex data into framebuffer using a fragment program” and so did I… :confused: