Hi Johannes,

I presume you mean "pixel buffer objects" rather than "texture buffer
objects" as this is the OpenGL naming and also the naming that the OSG
uses.

When using PixelBufferObjects in the OSG it's best to just create one
an attach it to the osg::Image that you want to stream the data.  You
just attach this osg::Image in the usual way to the osg::Texture and
it'll automatically use the PBO where the graphics driver supports and
without any addition code required.

Robert.

On Sat, Nov 28, 2009 at 9:52 PM, Johannes Schüth <[email protected]> wrote:
> Hi,
>
> i want to use texture buffer objects within my program.
>
> At the beginning i managed to get tbo's to work within a pure opengl 
> application.
>
> This is what i did:
>
> 1. create tbo
>
> Code:
>
> // create buffer object
> glGenBuffers(1, tbo);
> glBindBuffer(GL_TEXTURE_BUFFER_EXT, *tbo);
>
> // initialize buffer object
> unsigned int size = mesh_width * mesh_height * 4 * sizeof(float);
> glBufferData(GL_TEXTURE_BUFFER_EXT, size, 0, GL_DYNAMIC_DRAW);
>
> //tex
> glGenTextures(1, tex);
> glBindTexture(GL_TEXTURE_BUFFER_EXT, *tex);
> glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, *tbo);
> glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);
>
>
>
>
> 2. set data of the tbo
>
> Code:
>
> glBindBuffer(GL_TEXTURE_BUFFER_EXT, tbo);
> p = (float4*) glMapBuffer(GL_TEXTURE_BUFFER_EXT, GL_WRITE_ONLY);
>
> for (int u = 0; u < mesh_height; u++) {
>        for (int v = 0; v < mesh_width; v++) {
>                p[u + (v * mesh_width)][0] = ((float) u / mesh_height) * 2 - 
> (1.0);
>                p[u + (v * mesh_width)][1] = ((float) v / mesh_width) * 2 - 
> (1.0);
>                p[u + (v * mesh_width)][2] = 0.0f;
>                p[u + (v * mesh_width)][3] = 1.0f;
>        }
> }
> glUnmapBuffer(GL_TEXTURE_BUFFER_EXT);
> glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);
>
>
>
>
> 3. set uniform
>
> Code:
>
> glActiveTexture(GL_TEXTURE0);
> glBindTexture(GL_TEXTURE_BUFFER_EXT, displacementTex);
>
>
>
>
> And now i wanted to port this into osg. I have no idea how to create the tbo.
>
> I managed to get as far as:
>
> Code:
>
>        osg::BufferObject::Extensions* ext = osg::BufferObject::getExtensions(
>                        _gc->getState()->getContextID(), true);
>        ext->glBindBuffer(GL_TEXTURE_BUFFER_EXT, tbo);
>        unsigned int size = mesh_width * mesh_height * 4 * sizeof(float);
>        ext->glBufferData(GL_TEXTURE_BUFFER_EXT, size, 0, GL_DYNAMIC_DRAW);
>
>
>
>
> Do i have to create a osg::Texture::TextureObject Object to bind it to the 
> BufferObject? I do not know how to port these calls:
>
> Code:
>
>        glBindTexture(GL_TEXTURE_BUFFER_EXT, *tex);
>        glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, *tbo);
>
>
>
>
> My goal is to create a float buffer object by that i can access a huge amount 
> of floats within my shader.
>
> Thank you!
>
> Cheers,
> Johannes
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=20521#20521
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to