System.Windows.Interop.D3DImage.Lock C# (CSharp) Méthode

Lock() public méthode

Locks the D3DImage While locked you can call AddDirtyRect, SetBackBuffer, and Unlock. You can also write to your back buffer. You should not write to the back buffer without being locked.
public Lock ( ) : void
Résultat void
        public void Lock()
        {
            WritePreamble();

            LockImpl(Duration.Forever);
        }

Usage Example

        /// <summary>
        /// The render by OpenGL.
        /// </summary>
        private void RenderGLToD3dImage(D3DImage image, int w, int h, Action rendering)
        {
            if (w == 0 || h == 0)
            {
                return;
            }
            this.glControl.MakeCurrent();

            // resize D3D/OpenGL Surface if need
            this.ResizeIfNeed(w, h);

            // OnRender may be called twice in the same frame. Only render the first time.
            if (image.IsFrontBufferAvailable)
            {
                // render to sharedSurface using OpenGL
                this.wgl.WglDXLockObjectsNV(wglHandleDevice, 1, singleWglHandleSharedSurfaceArray);
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo);
                GL.DrawBuffer((DrawBufferMode)FramebufferAttachment.ColorAttachment0);
                rendering();
                GL.Finish();
                this.wgl.WglDXUnlockObjectsNV(wglHandleDevice, 1, singleWglHandleSharedSurfaceArray);

                try
                {
                    image.Lock();
                    image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, sharedSurface.NativePointer);
                    image.AddDirtyRect(new Int32Rect(0, 0, w, h));
                }
                catch (Exception ex)
                {
                    // ???
                    Console.WriteLine(ex.ToString());
                    this.device.ResetEx(ref this.presentparams);
                }
                finally
                {
                    image.Unlock();
                }
            }
        }