Hi Art

Thanks for the post. I have been able to hack my code and add a 
PixelDataBufferObject (PDBO) instance. 
Some questions:
1) Shouldn't the CPU to GPU data transfer be done with bindBufferInWriteMode?
2) How do I get an osg TextureRectangle to point to the data in the PDBO? The 
TextureRectangle is attached to a camera in my first node and is passed as an 
input to the shader program in the second node.
3) I assume that setDataSize in PDBO is in bytes?
4) I get the following warning and a blank screen when the program runs: 
"Warning: detected OpenGL error 'invalid operation' after RenderBin::draw(,)". 
What does this mean?

I have also created a graphics context with the pbuffer enabled and used this 
as the camera graphics context in the first node.

Regards,

Asheer Bachoo
Image Processing Researcher
Signal Processing Research Group
Defence, Peace, Safety and Security
Building 44, Scientia, CSIR Pretoria
Brummeria
South Africa

Telephone: 012 841 3787
e-mail: [email protected]
>>> "Art Tevs" <[email protected]> 07/30/09 2:05 PM >>>
Hi Ascheer,

you can take a look into osgPPU::Unit::drawImplementation. There is 
PixelDataBufferObejct used to copy the data between GPU und objects attached 
with PBO (in this case this could be a CPU data).

In general the use is like this:

// CPU to GPU

Code:

PixelDataBufferObject* pbo = ...

// specify size of the buffer
pbo->setDataSize(dataSize);

// set buffer in read mode, i.e. CPU->GPU
pbo->bindBufferInReadMode(state);

// upload buffer content into the texture
state->applyTextureAttribute(Unit, Texture);
glTexSubImage2D(Texture->getTextureTarget(), 0, 0, 0, 
Texture->getTextureWidth(), Texture->getTextureHeight(), 
osg::Image::computePixelFormat(Texture->getInternalFormat()), 
osg::Image::computeFormatDataType(Texture->getInternalFormat()), NULL);

pbo->unbindBuffer(state.getContextID());




for the GPU to CPU case, it would looks like similar to this:

Code:


// bind buffer in write mode and copy texture content into the buffer
pbo->bindBufferInWriteMode(tate);
state->applyTextureAttribute(Unit, Texture);

// copy content from texture to the pbo
glGetTexImage(Texture->getTextureTarget(), 
osg::Image::computePixelFormat(Texture->getInternalFormat()), 
osg::Image::computeFormatDataType(Texture->getInternalFormat()), NULL);
pbo->unbindBuffer(state.getContextID());




Reading or writing to the memory is done between the bindBufferIn*Mode() and 
unbindBuffer() methods by similar to this:

Code:

// map buffer to some memory
// here setup target: GL_PIXEL_PACK_BUFFER_ARB if you have buffer in write mode
// or GL_PIXEL_UNPACK_BUFFER_ARB if in read mode
// second parameter either GL_READ_ONLY or GL_WRITE_ONLY
void* pboMemory = glMapBuffer(_target, _access);

// copy data from CPU to buffer
memcpy(pboMemory, dataPointer, YourDesiredDattaSize)
// or copy data from buffer to CPU
memcpy(dataPointer, pboMemory, YourDesiredDattaSize)




Of course this is just a reference. Take a look, maybe this can help you. Take 
also a look into osg/src/BufferObject.cpp which might help you to understand 
the idea behind the buffered operation.

Cheers,
Art

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15641#15641





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to