public void Release() { lock (_surfaceLock) { if (_renderTexture != null) { _renderTexture.Dispose(); _renderTexture = null; } _isAllocated = false; } }
protected override void CreateTextureBuffer(int width, int height) { if (!RegisterDxDevice()) { base.CreateTextureBuffer(width, height); return; } IntPtr sharedResourceHandle = IntPtr.Zero; _dxTexture = new SafeTexture(_dxDevice, width, height, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default, ref sharedResourceHandle); _textureBuffer = new Texture2D(); bool result = RegisterDxTexture(_dxTexture, _textureBuffer, sharedResourceHandle); LockTexture(); _framebuffer.AttachTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, _textureBuffer, 0); UnlockTexture(); }
protected void CheckRenderTexture(int width, int height, Usage usage) { if (_renderTexture != null) { lock (_renderTexture.SyncRoot) { if (!_renderTexture.IsDisposing) { SurfaceDescription desc = _renderTexture.GetLevelDescription(0); if (desc.Width == width && desc.Height == height && desc.Usage == usage) { return; } _renderTexture.Dispose(); } } } _renderTexture = new SafeTexture(_device, width, height, 1, usage, Format.X8R8G8B8, Pool.Default); }
public override void BeginRender(int width, int height) { base.BeginRender(width, height); if (!HasDxContext) { return; } SafeTexture texture = _dxTexture; lock (texture.SyncRoot) { if (texture.IsDisposing) { DestroyTextureBuffer(); CreateTextureBuffer(width, height); } } LockTexture(); }