PDA

View Full Version : Texture Buffer Object shared with Vertex Buffer Ob



marshats
09-05-2010, 12:16 PM
In reading the new OpenGL blubook Version 5, there is a section on Transform feedback which is based on using a Texture buffer object with data from a vertex buffer object. The code online does not exist so I went thru and coded this up myself. The book used

in vec3 positions; in the vertex shader and correspondingly I
set it with glVertexAttribPointer(index_Rcm, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) ); but when I glTexBuffer(GL_TEXTURE_BUFFER,GL_RGBA32F,attribute ); I can never get this code to work.


in vec3 positions;
...
glVertexAttribPointer(index_Rcm, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) );
..
glTexBuffer(GL_TEXTURE_BUFFER,GL_RGBA32F,attribute );


If I replace everything with vec4 ie


in vec4 positions;
...
glVertexAttribPointer(index_Rcm, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) );
..
glTexBuffer(GL_TEXTURE_BUFFER,GL_RGBA32F,attribute );

it works as expected.

I then read deeper into glTexBuffer (http://www.opengl.org/sdk/docs/man3/xhtml/glTexBuffer.xml) and took note of the table (for floats)

Component
Sized | Internal Format |Base Type Components| Norm| 0 1 2 3
-----------------------------------------------------------------
GL_R32F float 1 NO R 0 0 1
GL_RG32F float 2 YES R G 0 1
GL_RGBA32F float 4 NO R G B A


Does this mean that texture buffer objects can only alias a vertex buffer object with stride of 1,2,or 4 (ie stride of 3 not possible)?

randall
09-06-2010, 01:25 AM
3 components TBO were added in OpenGL 4.0

Dark Photon
09-06-2010, 07:14 AM
I then read deeper into glTexBuffer (http://www.opengl.org/sdk/docs/man3/xhtml/glTexBuffer.xml) and took note of the table (for floats)

Component
Sized | Internal Format |Base Type Components| Norm| 0 1 2 3
-----------------------------------------------------------------
GL_R32F float 1 NO R 0 0 1
GL_RG32F float 2 YES R G 0 1
GL_RGBA32F float 4 NO R G B A


Does this mean that texture buffer objects can only alias a vertex buffer object with stride of 1,2,or 4 (ie stride of 3 not possible)?
I believe this was added with ARB_texture_buffer_object_rgb32 (http://www.opengl.org/registry/specs/ARB/texture_buffer_object_rgb32.txt). Check and see if your implementation supports it. As randall mentioned, this was made core in OpenGL 4.0.

marshats
09-06-2010, 08:01 AM
Thanks. Yes, GL_RGA32F is in the 4.0 implementation and ARB_texture_buffer_object_rgb32 solved the problem.