Re: Is there a freeImage() ref count?

New Message Reply Date view Thread view Subject view Author view

Sharon Clay (src++at++rose.asd.sgi.com)
Sun, 15 Dec 1996 23:42:09 -0800


+>---- On Dec 16, 12:35am, WDea++at++swri.edu wrote:
> Subject: Is there a freeImage() ref count?
->
->My Performer application allocates and frees textures several times.
->Some of these these textures share images. On occasion, a texture
->image is freed with pfTexture::freeImage() that is being used by
->
->Is there any way to check and see if an image is being used by another
->texture before calling pfTexture::freeImage()? An image reference count
->maybe? Or is there another way to avoid this scenario?
->

If your texture image was allocated with a pf allocation routine,
such as pfMalloc, then the image data will be reference counted when
you call pfTexture::setImage. A texture image created with pfTexLoadFile
will be such an image.
Additionally, the GL has its own copy of the texture so it is fine to
You can get the reference count of any pfMemory ptr with pfGetRef().
delete the texture image after the texture has been first applied.

It sounds like what it possibly happening is that pfTexture::freeImage()
is being called before it has actually been applied for that pfTexture.
If after a dereference, the reference count is not 0, the image memory
will not be deleted, but the image pointer for that texture will be
set to NULL. If the pfTexture was dirty (as in that image had been previously
set or changed and an apply had not yet been done)
a subsequent apply could cause the white texture.

In OpenGL, another way one can easily get the "white texture" problem is if
something has caused a GL error to happen. So, it is always good
to put a check for GL errors in your main loop to make sure this isn't
happening:

#ifndef IRISGL
   {
   int err;
   if ((err = glGetError()) != GL_NO_ERROR)
        pfNotify(PFNFY_NOTICE,PFNFY_USAGE,"OpenGL Error 0x%x - %s",err, gluErrorString(err));
   }
#endif /* GL Type */

Good luck!
src.

-- 
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++
Sharon Rose Clay (Fischler) - Silicon Graphics, Advanced Systems Dev.
src++at++sgi.com  (415) 933 - 1002  FAX: (415) 965 - 2658  MS 8U-590
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++
=======================================================================
List Archives, FAQ, FTP:  http://www.sgi.com/Technology/Performer/
            Submissions:  info-performer++at++sgi.com
        Admin. requests:  info-performer-request++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:09 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.