|
From: Keith W. <kw...@cs...> - 2004-07-13 20:48:23
|
I'm still learning how and when Quesa/QD take care of memory for me. For example, to make a mipmap, I do something like this: int bufferBytes = textureDim * textureDim * 2; unsigned short* blankTextureArray = new unsigned short[bufferBytes]; // MIPMAP =========================== TQ3Mipmap mipMap; mipMap.image = Q3MemoryStorage_New((unsigned char*)blankTextureArray, bufferBytes); mipMap.useMipmapping = kQ3False; mipMap.pixelType = kQ3PixelTypeRGB16; mipMap.bitOrder = kQ3EndianBig; mipMap.byteOrder = kQ3EndianBig; mipMap.reserved = nil; mipMap.mipmaps[0].width = textureDim; mipMap.mipmaps[0].height = textureDim; mipMap.mipmaps[0].rowBytes = textureDim * 2; mipMap.mipmaps[0].offset = 0; TQ3TextureObject texture = Q3MipmapTexture_New(&mipMap); TQ3SurfaceShaderObject shader = Q3TextureShader_New(texture); Q3Object_Dispose(texture); Q3Object_Dispose(mipMap.image); Afterwhich I would traditionally assign the shader to a trimesh. No problem. The question is, do I have to explicitly free my array, ala: delete [] blankTextureArray; or does the disposal of the mipmap.image do that because it was somehow associated with the array in the Q3MemoryStorage_New call? My understanding was that every new must have a delete, that I can't hand off that allocation to another pointer for later deletion. Am I just wrong there or do I need to delete that array? ________________________________________________________________________ Keith Wiley kw...@cs... http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley "Yet mark his perfect self-contentment, and hence learn his lesson, that to be self-contented is to be vile and ignorant, and that to aspire is better than to be blindly and impotently happy." -- Edwin A. Abbott, Flatland ________________________________________________________________________ |