コード例 #1
0
ファイル: InvokeArgument.cs プロジェクト: Feinbube/hybridNet
            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
            }
コード例 #2
0
ファイル: GlVertexBuffer.cs プロジェクト: shff/gk3tools
        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();
        }
コード例 #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;
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #6
0
ファイル: frmMain.cs プロジェクト: liberostelios/DPOW-Studio
        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);
        }
コード例 #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"));
        }
コード例 #8
0
ファイル: Unsafe.cs プロジェクト: acinep/net7mma-1
        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);
        }
コード例 #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);
 }
コード例 #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);
        }
コード例 #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();
 }
コード例 #12
0
ファイル: Des.cs プロジェクト: 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();
 }
コード例 #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);
        }
コード例 #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(); }
 }
コード例 #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(); }
 }
コード例 #16
0
 public void UnpinData()
 {
     if (m_PinnedHandle == default(System.Runtime.InteropServices.GCHandle))
     {
         return;
     }
     m_PinnedHandle.Free();
     m_PinnedHandle = default(System.Runtime.InteropServices.GCHandle);
 }
コード例 #17
0
ファイル: RoomManager.cs プロジェクト: framefield/ar-victoria
 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(); }
 }
コード例 #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);
     }
 }
コード例 #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(); }
 }
コード例 #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(); }
 }
コード例 #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;
 }
コード例 #22
0
ファイル: Util.cs プロジェクト: Wolfs-Bane/Pokemon-MK
 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());
 }
コード例 #23
0
 Action WrapContinuation(Action continuation)
 {
     Action wrapper = () =>
     {
         _gcHandle.Free();
         continuation();
     };
     _gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(wrapper);
     return wrapper;
 }
コード例 #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());
            }
コード例 #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);
        }
コード例 #26
0
ファイル: AkMemBankLoader.cs プロジェクト: Lrakulka/GGJ_2019
    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);
        }
    }
コード例 #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);
        }
コード例 #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);
 }
コード例 #29
0
ファイル: CapsLuaHub.cs プロジェクト: SilasDarkmoon/CapsLua
        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);
        }
コード例 #30
0
ファイル: GCHandle.cs プロジェクト: bmjoy/dnaunity
 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;
 }
コード例 #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);
        }
コード例 #32
0
ファイル: MultiScaleTileSource.cs プロジェクト: kangaroo/moon
		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 ();
				}
			}
		}
コード例 #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;
 }
コード例 #34
0
ファイル: PackBrowser.cs プロジェクト: logue/MabiPack
 public WavePlayer(byte[] buffer)
 {
     this.waveBuffer = buffer;
     this.gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(
         buffer, System.Runtime.InteropServices.GCHandleType.Pinned);
 }
コード例 #35
0
ファイル: FormDebugging.cs プロジェクト: JanneLee/CSharpGL
        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);
        }