예제 #1
0
        /// <summary>
        /// Get a managed SharedPtr for the given ogre object.
        /// </summary>
        /// <param name="nativeObject">The native object to get the pointer for.</param>
        /// <returns>A new SharedPtr for the object.</returns>
        public SharedPtr <T> getObject(IntPtr nativeObject)
        {
            SharedPtrEntry <T> entry;

            if (nativeObject != IntPtr.Zero && ptrDictionary.TryGetValue(nativeObject, out entry))
            {
                SharedPtr <T> sp = new SharedPtr <T>(entry.ManagedWrapper, nativeObject, entry.HeapSharedPtr, this);
                entry.addPointer(sp);
                if (OgreInterface.TrackMemoryLeaks)
                {
                    allocationStackTraces.Add(sp, new StackTrace(true));
                }
                return(sp);
            }
            return(null);
        }
예제 #2
0
        /// <summary>
        /// Return a pointer to this collection. This is done in the SharedPtr
        /// dispose method. If all the references are returned the entry will be
        /// disposed and the heap allocated shared pointer will be released.
        /// </summary>
        /// <param name="sharedPtr"></param>
        public void returnPtr(SharedPtr <T> sharedPtr)
        {
            IntPtr             key   = sharedPtr.NativeObject;
            SharedPtrEntry <T> entry = ptrDictionary[key];

            entry.removePointer(sharedPtr);
            if (OgreInterface.TrackMemoryLeaks)
            {
                allocationStackTraces.Remove(sharedPtr);
            }
            if (!entry.HasReferences)
            {
                ptrDictionary.Remove(key);
                deleteHeapSharedPtr(entry.HeapSharedPtr);
                entry.Dispose();
            }
        }
예제 #3
0
 internal MaterialPtr(SharedPtr <Material> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
예제 #4
0
 internal TexturePtr(SharedPtr <Texture> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
예제 #5
0
 internal HardwareVertexBufferSharedPtr(SharedPtr <HardwareVertexBuffer> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
예제 #6
0
 internal HighLevelGpuProgramSharedPtr(SharedPtr <HighLevelGpuProgram> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
 internal GpuSharedParametersPtr(SharedPtr <GpuSharedParameters> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
예제 #8
0
 public void addPointer(SharedPtr <T> ptr)
 {
     ptrList.AddLast(ptr);
 }
예제 #9
0
 public void removePointer(SharedPtr <T> ptr)
 {
     ptrList.Remove(ptr);
 }
예제 #10
0
 internal MeshPtr(SharedPtr <Mesh> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
예제 #11
0
 internal SkeletonPtr(SharedPtr <Skeleton> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
예제 #12
0
 internal GpuProgramParametersSharedPtr(SharedPtr <GpuProgramParameters> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
예제 #13
0
 internal OgreDataStreamPtr(SharedPtr <OgreDataStream> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }
 internal HardwarePixelBufferSharedPtr(SharedPtr <HardwarePixelBuffer> sharedPtr)
 {
     this.sharedPtr = sharedPtr;
 }