Hi Oliver,

On Wed, 2005-08-10 at 18:30 +0200, Oliver Kutter wrote:
>
> I have a new problem. :-(
> I have set up my viewport with all the stuff its needs. I have 
> begin/endEdits included. I have set up my PolygonForeground with a 
> Material and the positions and texcoords. The material has normally a 
> SHLChunk and a TextureChunk, but now only a TextureChunk. This 
> TextureChunk is my problem. My particles have a size of 2^n, because of 
> the 2D textures. When I change the number of my particles, I have to 
> resize the viewport to sqrt(size_of_particles).
> That works fine, but I have to renew the image for the TextureChunk. And 
> this is the problem. The new image has a different size. That's why I 
> set the new image to the TextureChunk. (By the way, what does happen to 
> the old image? Is there something like a garbage collector, or will it 
> be overwritten?)

We use reference counting for cleanup, and that's probably the problem
that you're seeing.

>  But after changing the size 2-3 times, it crashed. It 
> doesn't crash when I clear the following lines:
> 
> // this is the size of the particles
> _iVpSize = (int)sqrt((double)_mgr.getParticles().getNumber());
> 
> // change the texture chunk
> beginEditCP (_tcInput, TextureChunk::ImageFieldMask); {
>     if (_iVpSize == 8)  _tcInput->setImage(_imIndices[0]);
>     if (_iVpSize == 16) _tcInput->setImage(_imIndices[1]);
>     if (_iVpSize == 32) _tcInput->setImage(_imIndices[2]);
>     if (_iVpSize == 64) _tcInput->setImage(_imIndices[3]);
>     _tcInput[1]->imageContentChanged();     // I wonder if this is 
> necessary?!
> } endEditCP (_tcInput, TextureChunk::ImageFieldMask);
> 
> Do I have to change anything else?

No, that should be fine. But it's probably freeing the image when you're
changing it.

The easiest fix is to use an ImageRefPtr instead of an ImagePtr for your
_imIndices array. If you don't have that (1.4 and earlier) you can use
RefPtr<ImagePtr> and #include <OSGRefPtr.h>. Sideline: it would be more
efficient (but using more texture memory) to use separate TextureChunks
instead of Images.

Hope it helps

        Dirk




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to