void OnDestroy() { if (_isTextureSharingInitialized) { GlueTexShare.Release(); } }
public static bool IsTextureSharingReady() { if (_isTextureSharingInitialized == false) { GlueTexShare.Load(); GlueTexShare.Greet(); _isTextureSharingInitialized = true; } return(GlueTexShare.IsReady()); }
void InitSharedTex() { var desc = new RenderTextureDescriptor(textureSize.x, textureSize.y, RenderTextureFormat.ARGB32, 24); desc.autoGenerateMips = false; desc.sRGB = true; _renderTexture = new RenderTexture(desc); _unityCamera.targetTexture = _renderTexture; _texture = new Texture2D(_renderTexture.width, _renderTexture.height, TextureFormat.ARGB32, false, true); var nativeTexPtr = _texture.GetNativeTexturePtr(); _senderPtr = GlueTexShare.CreateSender(nativeTexPtr); var texPtr = GlueTexShare.GetTexturePointer(_senderPtr, true); _sharedTex = Texture2D.CreateExternalTexture(_renderTexture.width, _renderTexture.height, TextureFormat.ARGB32, false, false, texPtr); _commandBuffer = new CommandBuffer(); _commandBuffer.name = "Glue Copy " + this.name; _commandBuffer.CopyTexture(_renderTexture, _texture); _commandBuffer.CopyTexture(_texture, _sharedTex); DataPool.CommandBuffers.Add(this.name, _commandBuffer); if (_sharedHandlePtr == IntPtr.Zero) { _sharedHandlePtr = GlueTexShare.GetSharedHandle(_senderPtr, true); DataPool.SendFrame.Add(key, ref _sharedHandlePtr); } }