Hi,

I'm wanting to update the contents of a texture on the fly, with content from a 
Quartz Composition (Mac OSX).  Apologies in advance if this is newbie-ish - I'm 
new to OSG and .... it's big!

Quartz will render to an OpenGL context, so it'd make sense to render to an FBO 
with an attached texture to reduce copying of data. I'm wanting to try to reuse 
as much of OSG as possible to help in the management of texture resources 
across multiple contexts (as well as FBO resources).

At the moment I've a node with attached Texture (from an Image).   

I've started down the UpdateCallback route, but  I don't (maybe because I don't 
know how) have access to State (useful to get GL texture names).   I had 
thought I would be able to dynamically replace the existing texture attached to 
a node with the Quartz rendered results. While I can do that, new texture names 
aren't created until later on in the render path (and so I don't know how I'd 
set the FBO render target).

e.g:

Code:
void RenderTextureThroughQuartz::operator()(osg::Node* node, osg::NodeVisitor* 
nv)
{
        @try {
                osg::StateSet *stateSet = node->getOrCreateStateSet();
                osg::TextureRectangle *texRect = 
dynamic_cast<osg::TextureRectangle*> (stateSet->getTextureAttribute(0, 
osg::StateAttribute::TEXTURE));
                if(texRect) {
                        if(sourceTexture.get() == nil) {
                                // Save the source texture. It'll be our feed 
into the QCRenderer.
                                sourceTexture = texRect;
                                
                                // Replace the nodes texture with our 
destination texture. This texture will hold the
                                // reusult from the QCRenderer.
                                
destinationTexture->setTextureSize(sourceTexture->getTextureWidth(), 
sourceTexture->getTextureHeight());
                                
                                // Replace this texture in the node
                                stateSet->setTextureAttribute(0, 
destinationTexture.get(), osg::StateAttribute::ON);
                                NSLog(@"Replaced the nodes source texture with 
our own destination");
                        }


 

However

Code:
osg::Texture::TextureObject *destTObj = 
destinationTexture->getTextureObject(contextID);



return 0, because apply() hasn't been called on it yet.


In pseudo code, what'd I'm trying to achieve is:

- Select an FBO, with attached texture as a render target (this fbo & texture 
would ideally be managed by OSG)
- Setup the viewport etc to match the texture size
- Perform the QC Render

I'm thinking that because the FBO is rendering directly into a texture managed 
by OSG, that I wouldn't then have to perform any additional blits or copies of 
data. 

Is this at all possible?
What'd be the best callback mechanism for me to research?
How would I use TextureRectangles and FrameBufferObjects outside of a normal 
render path? Or should I not do this?
Is there example code that does anything remotely similar?

Thank you!

Cheers,
Neil

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





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

Reply via email to