Ejemplo n.º 1
0
            protected override void EnqueueWrite(CallContext CallContext, int i, long ElementCount, OpenCLNet.MemFlags MemFlags)
            {
                Type RealElementType = Value.GetType().GetElementType();
                int  ElementSize     = System.Runtime.InteropServices.Marshal.SizeOf(RealElementType);

#if USE_HOST_POINTER
                m_GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(Value, System.Runtime.InteropServices.GCHandleType.Pinned);

                MemBuffer = CallContext.Context.CreateBuffer(MemFlags | OpenCLNet.MemFlags.USE_HOST_PTR, ElementCount * ElementSize, m_GCHandle.Value.AddrOfPinnedObject());
                CallContext.Kernel.SetArg(i, MemBuffer);
#else
                MemBuffer = CallContext.Context.CreateBuffer(MemFlags, ElementCount * ElementSize, IntPtr.Zero);
                CallContext.Kernel.SetArg(i, MemBuffer);

                //
                // If the buffer is read by the device, transfer the data
                //

                if (m_ForRead)
                {
                    System.Runtime.InteropServices.GCHandle gch = System.Runtime.InteropServices.GCHandle.Alloc(Value, System.Runtime.InteropServices.GCHandleType.Pinned);

                    try
                    {
                        IntPtr p = gch.Value.AddrOfPinnedObject();
                        CallContext.CommandQueue.EnqueueWriteBuffer(MemBuffer, true, IntPtr.Zero, new IntPtr(ElementCount * ElementSize), p);
                    }
                    finally
                    {
                        gch.Free();
                    }
                }
#endif
            }
Ejemplo n.º 2
0
        public override void SetData <T>(T[] data, int startIndex, int elementCount)
        {
            if (_usage == VertexBufferUsage.Static)
            {
                throw new Exception("Can't update a vertex buffer created as Static");
            }

            GL.GetError();
            GL.BindBuffer(BufferTarget.ArrayBuffer, _buffer);

            System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned);
            try
            {
                IntPtr pointer = handle.AddrOfPinnedObject();
                int    size    = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T));

                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(elementCount * size), Gk3Main.Utils.IncrementIntPtr(pointer, size * startIndex), (BufferUsageHint)convertUsage(_usage));
            }
            finally
            {
                if (handle.IsAllocated)
                {
                    handle.Free();
                }
            }

            GlException.ThrowExceptionIfErrorExists();
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="flags"></param>
 public DebugReportCallbackWrapper(Delegate callback, SharpVk.Multivendor.DebugReportFlags?flags = null)
 {
     callback_ = callback;
     gch_      = System.Runtime.InteropServices.GCHandle.Alloc(this);
     Flags     = flags;
     Enabled   = false;
 }
Ejemplo n.º 4
0
 public StringAsPinnedUTF8(string str)
 {
     byte[] strBytes = System.Text.UTF8Encoding.UTF8.GetBytes(str);
     byte[] strBytesNulTerminated = new byte[strBytes.Length + 1]; // initialized to all 0's.
     Array.Copy(strBytes, strBytesNulTerminated, strBytes.Length);
     this.gch = SystemGCHandle.Alloc(strBytesNulTerminated, SystemGCHandleType.Pinned);
 }
Ejemplo n.º 5
0
 public PlaneApi(NativeSession nativeSession)
 {
     _nativeSession   = nativeSession;
     _tmpPoints       = new float[_maxPolygonSize * 2];
     _tmpPointsHandle = System.Runtime.InteropServices.GCHandle.Alloc(
         _tmpPoints, System.Runtime.InteropServices.GCHandleType.Pinned);
 }
Ejemplo n.º 6
0
        private Mogre.Image SystemtoMogreImage(System.Drawing.Image image)
        {
            Stream oStream = new MemoryStream();

            image.Save(oStream, System.Drawing.Imaging.ImageFormat.Png);

            /* Back to the start of the stream */
            oStream.Position = 0;

            /* read all the stream in a buffer */
            BinaryReader oBinaryReader = new BinaryReader(oStream);

            byte[] pBuffer = oBinaryReader.ReadBytes((int)oBinaryReader.BaseStream.Length);
            oStream.Close(); /*No more needed */

            Mogre.Image oMogreImage = new Mogre.Image();

            unsafe
            {
                System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(pBuffer, System.Runtime.InteropServices.GCHandleType.Pinned);
                byte *pUnsafeByte   = (byte *)handle.AddrOfPinnedObject();
                void *pUnsafeBuffer = (void *)handle.AddrOfPinnedObject();

                MemoryDataStream oMemoryStream  = new MemoryDataStream(pUnsafeBuffer, (uint)pBuffer.Length);
                DataStreamPtr    oPtrDataStream = new DataStreamPtr(oMemoryStream);
                oMogreImage = oMogreImage.Load(oPtrDataStream, "png");
                handle.Free();
            }

            return(oMogreImage);
        }
Ejemplo n.º 7
0
        private string GetMemory(object obj)
        {
            System.Runtime.InteropServices.GCHandle h = System.Runtime.InteropServices.GCHandle.Alloc(obj, System.Runtime.InteropServices.GCHandleType.Pinned);
            IntPtr addr = h.AddrOfPinnedObject();

            return(addr.ToString("X"));
        }
Ejemplo n.º 8
0
        public unsafe static T[] Create <T>(void *source, int length)
        {
            System.Type type = typeof(T);

            int sizeInBytes = System.Runtime.InteropServices.Marshal.SizeOf(type);

            T[] output = new T[length];

            if (type.IsPrimitive)
            {
                // Make sure the array won't be moved around by the GC
                System.Runtime.InteropServices.GCHandle handleOutput = default(System.Runtime.InteropServices.GCHandle);

                try
                {
                    handleOutput = System.Runtime.InteropServices.GCHandle.Alloc(output, System.Runtime.InteropServices.GCHandleType.Pinned);

                    int byteLength = length * sizeInBytes;

                    // There are faster ways to do this, particularly by using wider types or by
                    // handling special lengths.
                    //for (int i = 0; i < byteLength; i++)
                    //    destination[i] = ((byte*)source)[i];

                    //E,g, like this... the problem is that handle doesn't point to the array elements...
                    //Could instead give a T[] source or IntPtr.

                    System.Buffer.MemoryCopy(source, (void *)handleOutput.AddrOfPinnedObject(), byteLength, byteLength);
                }
                finally
                {
                    if (handleOutput.IsAllocated)
                    {
                        handleOutput.Free();
                    }
                }
            }
            else if (type.IsValueType)
            {
                if (false == type.IsLayoutSequential && false == type.IsExplicitLayout)
                {
                    throw new System.InvalidOperationException(string.Format("{0} does not define a StructLayout attribute", type));
                }

                System.IntPtr sourcePtr = new System.IntPtr(source);

                for (int i = 0; i < length; i++)
                {
                    System.IntPtr p = new System.IntPtr((byte *)source + i * sizeInBytes);

                    output[i] = (T)System.Runtime.InteropServices.Marshal.PtrToStructure(p, typeof(T));
                }
            }
            else
            {
                throw new System.InvalidOperationException(string.Format("{0} is not supported", type));
            }

            return(output);
        }
Ejemplo n.º 9
0
 public Packet.PacketHeader ByteArrayToNewStuff(byte[] bytes)
 {
     System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(bytes, System.Runtime.InteropServices.GCHandleType.Pinned);
     Packet.PacketHeader stuff = (Packet.PacketHeader)System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(Packet.PacketHeader));
     handle.Free();
     return(stuff);
 }
Ejemplo n.º 10
0
        private static int LuaMetaCachedGC(IntPtr l)
        {
            IntPtr pud  = l.touserdata(1);
            IntPtr hval = System.Runtime.InteropServices.Marshal.ReadIntPtr(pud);

            System.Runtime.InteropServices.GCHandle handle = new System.Runtime.InteropServices.GCHandle();
            object obj = null;

            try
            {
                handle = (System.Runtime.InteropServices.GCHandle)hval;
                obj    = handle.Target;
            }
            catch { }

            if (obj != null)
            {
                var cache = LuaObjCache.GetObjCache(l);
                if (cache != null)
                {
                    cache.Remove(obj);
                }
            }

            try
            {
                handle.Free();
            }
            catch { }

            return(0);
        }
Ejemplo n.º 11
0
 public TextureContent(GraphicsDevice graphicsDevice, bool generateMipMaps, int mipMapCount, byte[] inputData, int width, int height, TextureContentFormat inputFormat, TextureContentFormat outputFormat)
 {
     this.graphicsDevice = graphicsDevice;
     System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(inputData, System.Runtime.InteropServices.GCHandleType.Pinned);
     createTexture(generateMipMaps, mipMapCount, handle.AddrOfPinnedObject(), width, height, inputFormat, outputFormat);
     handle.Free();
 }
Ejemplo n.º 12
0
Archivo: Des.cs Proyecto: Fun33/code
 /// <summary>
 /// 清除記憶體
 /// </summary>
 private void Clear(string sSecretKey)
 {
     // For additional security Pin the key.
     System.Runtime.InteropServices.GCHandle Gch = System.Runtime.InteropServices.GCHandle.Alloc(sSecretKey, System.Runtime.InteropServices.GCHandleType.Pinned);
     // Remove the Key from memory.
     ZeroMemory(Gch.AddrOfPinnedObject(), sSecretKey.Length * 2);
     Gch.Free();
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 获取字符串的地址位
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        int VarPtr(object e)
        {
            System.Runtime.InteropServices.GCHandle gh = System.Runtime.InteropServices.GCHandle.Alloc(e, System.Runtime.InteropServices.GCHandleType.Pinned);
            int gc = gh.AddrOfPinnedObject().ToInt32();

            gh.Free();
            return(gc);
        }
Ejemplo n.º 14
0
 public virtual void CopyImageData(byte[] data, int bufferSize, int bytesPerPixel)
 {
     System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try {
         {
             SharingClientPINVOKE.TagImage_CopyImageData(swigCPtr, (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), bufferSize, bytesPerPixel);
         }
     } finally { pinHandle_data.Free(); }
 }
Ejemplo n.º 15
0
 public virtual void WriteArray(byte[] data, uint length)
 {
     System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try {
         {
             SharingClientPINVOKE.NetworkOutMessage_WriteArray(swigCPtr, (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), length);
         }
     } finally { pinHandle_data.Free(); }
 }
Ejemplo n.º 16
0
 public void UnpinData()
 {
     if (m_PinnedHandle == default(System.Runtime.InteropServices.GCHandle))
     {
         return;
     }
     m_PinnedHandle.Free();
     m_PinnedHandle = default(System.Runtime.InteropServices.GCHandle);
 }
Ejemplo n.º 17
0
 public virtual bool UploadAnchor(Room room, XString anchorName, byte[] data, int dataSize)
 {
     System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try {
         {
             bool ret = SharingClientPINVOKE.RoomManager_UploadAnchor(swigCPtr, Room.getCPtr(room), XString.getCPtr(anchorName), (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), dataSize);
             return(ret);
         }
     } finally { pinHandle_data.Free(); }
 }
Ejemplo n.º 18
0
 public LuaStreamReader(System.IO.Stream stream, byte[] buffer)
     : this(stream)
 {
     if (buffer != null)
     {
         _Buffer       = buffer;
         _BufferHandle = System.Runtime.InteropServices.GCHandle.Alloc(_Buffer, System.Runtime.InteropServices.GCHandleType.Pinned);
     }
 }
Ejemplo n.º 19
0
 public virtual bool GetData(byte[] data, int dataSize)
 {
     System.Runtime.InteropServices.GCHandle pinHandle_data = System.Runtime.InteropServices.GCHandle.Alloc(data, System.Runtime.InteropServices.GCHandleType.Pinned); try {
         {
             bool ret = SharingClientPINVOKE.AnchorDownloadRequest_GetData(swigCPtr, (System.IntPtr)pinHandle_data.AddrOfPinnedObject(), dataSize);
             return(ret);
         }
     } finally { pinHandle_data.Free(); }
 }
Ejemplo n.º 20
0
 public virtual bool ProcessImage(byte[] image, int width, int height, int bytesPerPixel)
 {
     System.Runtime.InteropServices.GCHandle pinHandle_image = System.Runtime.InteropServices.GCHandle.Alloc(image, System.Runtime.InteropServices.GCHandleType.Pinned); try {
         {
             bool ret = SharingClientPINVOKE.VisualPairConnector_ProcessImage(swigCPtr, (System.IntPtr)pinHandle_image.AddrOfPinnedObject(), width, height, bytesPerPixel);
             return(ret);
         }
     } finally { pinHandle_image.Free(); }
 }
Ejemplo n.º 21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="messageSeverity"></param>
 /// <param name="messageType"></param>
 /// <param name="flags"></param>
 public DebugUtilsMessengerWrapper(Delegate callback, SharpVk.Multivendor.DebugUtilsMessageSeverityFlags messageSeverity, SharpVk.Multivendor.DebugUtilsMessageTypeFlags messageType, SharpVk.Multivendor.DebugUtilsMessengerCreateFlags?flags = null)
 {
     callback_       = callback;
     gch_            = System.Runtime.InteropServices.GCHandle.Alloc(this);
     Flags           = flags;
     MessageSeverity = messageSeverity;
     MessageType     = messageType;
     Enabled         = false;
 }
Ejemplo n.º 22
0
 public DirectBitmap(int Width, int Height)
 {
     this.Width      = Width;
     this.Height     = Height;
     this.Bits       = new Int32[this.Width * this.Height];
     this.BitsHandle = System.Runtime.InteropServices.GCHandle.Alloc(this.Bits,
                                                                     System.Runtime.InteropServices.GCHandleType.Pinned);
     this.Bitmap = new System.Drawing.Bitmap(this.Width, this.Height, this.Width * 4,
                                             System.Drawing.Imaging.PixelFormat.Format32bppPArgb, BitsHandle.AddrOfPinnedObject());
 }
Ejemplo n.º 23
0
 Action WrapContinuation(Action continuation)
 {
     Action wrapper = () =>
     {
         _gcHandle.Free();
         continuation();
     };
     _gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(wrapper);
     return wrapper;
 }
Ejemplo n.º 24
0
            public IntPtr PinData()
            {
                if (m_PinnedHandle != default(System.Runtime.InteropServices.GCHandle))
                {
                    return(m_PinnedHandle.AddrOfPinnedObject());
                }

                m_PinnedHandle = System.Runtime.InteropServices.GCHandle.Alloc(m_Data, System.Runtime.InteropServices.GCHandleType.Pinned);
                return(m_PinnedHandle.AddrOfPinnedObject());
            }
Ejemplo n.º 25
0
        private void FormDebugging_Load(object sender, EventArgs e)
        {
            frmWhiteBoard = new FormWhiteBoard();
            frmWhiteBoard.Show();

            byte x;

            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT);// x is 1

            GL.Disable(GL.GL_DEBUG_OUTPUT);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT);// x is 0

            GL.Enable(GL.GL_DEBUG_OUTPUT);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT);                 // x is 1

            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); // x is 0

            GL.Disable(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);// x is 0

            GL.Enable(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);// x is 1

            // 必须是struct
            UserParamStruct data = new UserParamStruct()
            {
                integer = 123, handle = this.glCanvas1.Handle
            };

            this.userParamInstance = System.Runtime.InteropServices.GCHandle.Alloc(
                data, System.Runtime.InteropServices.GCHandleType.Pinned);
            IntPtr ptr = userParamInstance.AddrOfPinnedObject();

            GL.DebugMessageCallback(this.callbackProc, ptr);

            GL.DebugMessageControl(
                Enumerations.DebugMessageControlSource.DONT_CARE,
                Enumerations.DebugMessageControlType.DONT_CARE,
                Enumerations.DebugMessageControlSeverity.DONT_CARE,
                0, null, true);

            StringBuilder builder = new StringBuilder();

            builder.Append("hello, this is app!");
            GL.DebugMessageInsert(
                Enumerations.DebugSource.DEBUG_SOURCE_APPLICATION_ARB,
                Enumerations.DebugType.DEBUG_TYPE_OTHER_ARB,
                0x4752415A,
                //Enumerations.DebugSeverity.DEBUG_SEVERITY_NOTIFICATION_ARB,// not valid
                Enumerations.DebugSeverity.DEBUG_SEVERITY_HIGH_ARB,
                //Enumerations.DebugSeverity.DEBUG_SEVERITY_MEDIUM_ARB,
                //Enumerations.DebugSeverity.DEBUG_SEVERITY_LOW_ARB,
                -1,
                builder);
        }
Ejemplo n.º 26
0
    private System.Collections.IEnumerator LoadFile()
    {
        ms_www = new UnityEngine.WWW(m_bankPath);

        yield return(ms_www);

        uint in_uInMemoryBankSize = 0;

        // Allocate an aligned buffer
        try
        {
            ms_pinnedArray =
                System.Runtime.InteropServices.GCHandle.Alloc(ms_www.bytes, System.Runtime.InteropServices.GCHandleType.Pinned);
            ms_pInMemoryBankPtr  = ms_pinnedArray.AddrOfPinnedObject();
            in_uInMemoryBankSize = (uint)ms_www.bytes.Length;

            // Array inside the WWW object is not aligned. Allocate a new array for which we can guarantee the alignment.
            if ((ms_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0)
            {
                var alignedBytes    = new byte[ms_www.bytes.Length + AK_BANK_PLATFORM_DATA_ALIGNMENT];
                var new_pinnedArray =
                    System.Runtime.InteropServices.GCHandle.Alloc(alignedBytes, System.Runtime.InteropServices.GCHandleType.Pinned);
                var new_pInMemoryBankPtr = new_pinnedArray.AddrOfPinnedObject();
                var alignedOffset        = 0;

                // New array is not aligned, so we will need to use an offset inside it to align our data.
                if ((new_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0)
                {
                    var alignedPtr = (new_pInMemoryBankPtr.ToInt64() + AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) &
                                     ~AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK;
                    alignedOffset        = (int)(alignedPtr - new_pInMemoryBankPtr.ToInt64());
                    new_pInMemoryBankPtr = new System.IntPtr(alignedPtr);
                }

                // Copy the bank's bytes in our new array, at the correct aligned offset.
                System.Array.Copy(ms_www.bytes, 0, alignedBytes, alignedOffset, ms_www.bytes.Length);

                ms_pInMemoryBankPtr = new_pInMemoryBankPtr;
                ms_pinnedArray.Free();
                ms_pinnedArray = new_pinnedArray;
            }
        }
        catch
        {
            yield break;
        }

        var result = AkSoundEngine.LoadBank(ms_pInMemoryBankPtr, in_uInMemoryBankSize, out ms_bankID);

        if (result != AKRESULT.AK_Success)
        {
            UnityEngine.Debug.LogError("WwiseUnity: AkMemBankLoader: bank loading failed with result " + result);
        }
    }
Ejemplo n.º 27
0
        public Font UseMemoryFont(float size)
        {
            System.Runtime.InteropServices.GCHandle hObject = System.Runtime.InteropServices.GCHandle.Alloc(Properties.Resources.iconfont, System.Runtime.InteropServices.GCHandleType.Pinned);
            IntPtr intptr            = hObject.AddrOfPinnedObject();
            PrivateFontCollection fc = new PrivateFontCollection();

            fc.AddMemoryFont(intptr, Properties.Resources.iconfont.Length);
            Font font = new Font(fc.Families[0], size, FontStyle.Regular, GraphicsUnit.Point, 0);

            return(font);
        }
Ejemplo n.º 28
0
 public void Reuse(System.IO.Stream stream, byte[] buffer)
 {
     Dispose();
     _Stream = stream;
     if (buffer != null)
     {
         _Buffer       = buffer;
         _BufferHandle = System.Runtime.InteropServices.GCHandle.Alloc(_Buffer, System.Runtime.InteropServices.GCHandleType.Pinned);
     }
     GC.ReRegisterForFinalize(this);
 }
Ejemplo n.º 29
0
        public static object GetLuaLightObject(this IntPtr l, int index)
        {
            IntPtr pud = l.touserdata(index);

            try
            {
                System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)pud;
                return(handle.Target);
            }
            catch { }
            return(null);
        }
Ejemplo n.º 30
0
 public static void Clear()
 {
     if (gcHandles != null)
     {
         foreach (PTR p in gcHandles)
         {
             System.Runtime.InteropServices.GCHandle h = System.Runtime.InteropServices.GCHandle.FromIntPtr((System.IntPtr)p);
             h.Free();
         }
     }
     gcHandles = null;
 }
Ejemplo n.º 31
0
        // Waveの再生。
        public void PlayWaveSound(Stream strm)
        {
            if (this.waveBuffer != null)                            // Waveデータの配列が空の場合、Waveの再生を停止する。
            {
                this.StopWaveSound();
            }
            this.waveBuffer = new byte[strm.Length];                // WaveデータをByte配列に格納。
            strm.Read(this.waveBuffer, 0, this.waveBuffer.Length);  // Waveデータを読み込む。

            // ガーベジコレクタによるWaveデータのメモリ移動を防ぐ。
            this.gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(this.waveBuffer, System.Runtime.InteropServices.GCHandleType.Pinned);

            // Waveの再生の開始。
            PlaySound(this.gcHandle.AddrOfPinnedObject(), IntPtr.Zero, PlaySoundFlags.SND_MEMORY | PlaySoundFlags.SND_ASYNC);
        }
Ejemplo n.º 32
0
		private new void Initialize ()
		{
			if (!(this is DeepZoomImageTileSource)) {
				ImageUriFunc func = new Mono.ImageUriFunc (GetImageUriSafe);
				handle = System.Runtime.InteropServices.GCHandle.Alloc (func);
				NativeMethods.multi_scale_tile_source_set_image_uri_func (native, func);
				
				clear_image_uri_func = ClearImageUri;
				
				if (!Deployment.QueueForShutdown (clear_image_uri_func)) {
					/* we're already shutting down */
					clear_image_uri_func ();
				}
			}
		}
Ejemplo n.º 33
0
 public PinnedStreamReader(Stream inputStream, int bufferSize)
     : base(inputStream, bufferSize)
 {
     // Pin the array
     pinningHandle = System.Runtime.InteropServices.GCHandle.Alloc(bytes, System.Runtime.InteropServices.GCHandleType.Pinned);
     fixed (byte* bytesAsPtr = &bytes[0])
         bufferStart = bytesAsPtr;
 }
Ejemplo n.º 34
0
 public WavePlayer(byte[] buffer)
 {
     this.waveBuffer = buffer;
     this.gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(
         buffer, System.Runtime.InteropServices.GCHandleType.Pinned);
 }
Ejemplo n.º 35
0
        private void FormDebugging_Load(object sender, EventArgs e)
        {
            frmWhiteBoard = new FormWhiteBoard();
            frmWhiteBoard.Show();

            byte x;
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT);// x is 1

            GL.Disable(GL.GL_DEBUG_OUTPUT);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT);// x is 0

            GL.Enable(GL.GL_DEBUG_OUTPUT);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT);// x is 1

            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);// x is 0

            GL.Disable(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);// x is 0

            GL.Enable(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
            x = GL.IsEnabled(GL.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);// x is 1

            // 必须是struct
            UserParamStruct data = new UserParamStruct() { integer = 123, handle = this.glCanvas1.Handle };
            this.userParamInstance = System.Runtime.InteropServices.GCHandle.Alloc(
                data, System.Runtime.InteropServices.GCHandleType.Pinned);
            IntPtr ptr = userParamInstance.AddrOfPinnedObject();

            GL.DebugMessageCallback(this.callbackProc, ptr);

            GL.DebugMessageControl(
                 Enumerations.DebugMessageControlSource.DONT_CARE,
                 Enumerations.DebugMessageControlType.DONT_CARE,
                  Enumerations.DebugMessageControlSeverity.DONT_CARE,
                  0, null, true);

            StringBuilder builder = new StringBuilder();
            builder.Append("hello, this is app!");
            GL.DebugMessageInsert(
                Enumerations.DebugSource.DEBUG_SOURCE_APPLICATION_ARB,
                Enumerations.DebugType.DEBUG_TYPE_OTHER_ARB,
                0x4752415A,
                //Enumerations.DebugSeverity.DEBUG_SEVERITY_NOTIFICATION_ARB,// not valid
                Enumerations.DebugSeverity.DEBUG_SEVERITY_HIGH_ARB,
                //Enumerations.DebugSeverity.DEBUG_SEVERITY_MEDIUM_ARB,
                //Enumerations.DebugSeverity.DEBUG_SEVERITY_LOW_ARB,
                -1,
                builder);
        }