void SetLogCallback() { MyDelegate callback_delegate = new MyDelegate(CallBackFunction); IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(callback_delegate); RenderPlugin.SetLogFunction(intptr_delegate); }
public void Dispose() { RenderPlugin.DestroyRenderer(rendererId); if (buffer[0] != IntPtr.Zero) { Marshal.FreeHGlobal(buffer[0]); } }
void Start() { texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture.filterMode = FilterMode.Point; texture.Apply(); GetComponent <MeshRenderer>().material.mainTexture = texture; rendererId = RenderPlugin.CreateRenderer(); Debug.LogFormat("Creating renderer: {0}", rendererId); }
public void RenderFrame(VideoFrame frame) { if (w != frame.Width || h != frame.Height) { Debug.LogFormat("Size changed!, ({0},{1}) => ({2},{3})", w, h, frame.Width, frame.Height); w = frame.Width; h = frame.Height; if (buffer[0] != IntPtr.Zero) { Marshal.FreeHGlobal(buffer[0]); } buffer[0] = Marshal.AllocHGlobal(frame.Width * frame.Height * 4); strides[0] = frame.Width * 4; } frame.ConvertInPlace(PixelFormat.FormatArgb32, buffer, strides); RenderPlugin.SetRendererFrame(rendererId, buffer[0], frame.Width, frame.Height); frame.Dispose(); }
void Update() { if (!Enabled) { return; } int newWidth = 0, newHeight = 0; if (RenderPlugin.ShouldCreateNewTexture(rendererId, ref newWidth, ref newHeight) != 0) { texture = new Texture2D(newWidth, newHeight, TextureFormat.BGRA32, false); RenderPlugin.SetRendererTexture(rendererId, texture.GetNativeTexturePtr(), newWidth, newHeight); GetComponent <MeshRenderer>().material.mainTexture = texture; } GL.IssuePluginEvent(RenderPlugin.GetRenderEventFunc(), rendererId); }