Antonio Bleile wrote:
> Hi,
> 
> how about this code here:
> 
> ImagePtr img1 = Image::create();
> 
> beginEditCP(img1);
>   img1->set(Image::OSG_RGBA_PF, 512, 512);
> endEditCP(img1);
> 
> beginEditCP(m_pCopyTexture2);
>   m_pCopyTexture2->setMinFilter(GL_LINEAR);
>   m_pCopyTexture2->setMagFilter(GL_LINEAR);
>   m_pCopyTexture2->setTarget(GL_TEXTURE_2D);
>   m_pCopyTexture2->setInternalFormat(GL_RGBA8);
>   m_pCopyTexture2->setImage(img1);
> endEditCP(m_pCopyTexture2);
> 
> 
> When am I supposed to delete img1? Is the destructor
> of the texture taking care? If I use subRefCP of the
> image immediately, the system crashes. If I apply the
> OpenGL metaphor on this sample, I would expect that
> I can delete the image. But obviously the image is
> uploaded to texture memory later....

AFAIK, you can't really do that. OpenSG always keep a copy around due to 
clustering, etc.

However, it _may_ work to render using the image (or validate it to a 
window, same thing), then subref it. But I would expect that the 
TextureChunk will get upset (i.e. crash) when it is destructeed as it 
also tries to subref it. And if you set it's imageptr to zero, it will 
upload an empty image during the next rendering.

This is a bit interesting in general. I don't know if OpenSG allows, or 
has any plans to allow these types of memory optimizations. (Applies 
both to textures and geometries).

Cheers,
/Marcus

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to