[osg-users] Animating images

Brian bpdavis at knology.net
Fri Jan 18 11:27:00 PST 2008


Thanks for the suggestions, Stephan and Robert.

I've never used PBOs before, and judging from the header, that is the correct way to set it up.  Once I have the object, is it a simple matter of calling osg::Texture2D::setImage like:

texture = new osg::Texture2D;
image = new osg::Image;
image->setImage(m_Width, m_Height, 1, 
        4, GL_RGBA, GL_UNSIGNED_BYTE, m_ImageBuffer, 
        osg::Image::AllocationMode::NO_DELETE);
image->setPixelBufferObject(new osg::PixelBufferObject(image));
texture->setImage(image);

If this is correct, is there any other setup needed to complete the process?

As for the rendering of the Flash movie, the image buffer is updated via a call to OleDraw().  The call to OleDraw is made in response to a WM_TIMER message that the Flash control sends.  My current implementation is basically:

OleDraw(...) // draws to a device context which automatically updates the image buffer, m_ImageBuffer
image->setImage(m_ImageBuffer); // call to osg::Image::setImage

When you say that you "set the movie's context to the image's data", how is that done?


In regard to using a TextureRectangle, I have tried that approach, but because I am using a shader to reverse the red and blue pixel components to correct the coloring, I had trouble getting the shader to cooperate.  Plus, I read on nVidia's web site that fragment shaders are not optimized for non power-of-two textures.  I haven't abandoned this method, but I am curious to know what kind of performance hit is typically seen?

Thanks,
Brian



 On Fri Jan 18 12:37 , Stephan Huber <ratzfatz at digitalmind.de> sent:

>Brian schrieb:
>> Is there a faster alternative than using osg::Image::setImage?  Or is there a way that I can directly use HDC that the Flash control renders with OSG?
>
>try using PixelBufferObjects this will increase performance when 
>uploading the image to the gpu.
> From my head: image->setPixelBufferObject(new 
>osg::PixelBufferObject(image));
>
>Is your image power-or-two? You mentioned Texture2D, perhaps 
>TextureRectangleRect is better suited.
>
>Perhaps you can render directly into the image's data. When rendering 
>quicktime-movies I set up the movie's context to the image's data, no 
>need to copy the current frame from one buffer to another. and then 
>upload it to the GPU:
>
>
>Hope that helps,
>
>Stephan



More information about the osg-users mailing list