From 22b21ae3f4d6c0893507c96c21dcc3a48143757d Mon Sep 17 00:00:00 2001 From: hecomi Date: Sat, 5 Nov 2016 01:44:26 +0900 Subject: [PATCH] check texture size before recreating it. --- Assets/uDesktopDuplication/Scripts/Monitor.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Assets/uDesktopDuplication/Scripts/Monitor.cs b/Assets/uDesktopDuplication/Scripts/Monitor.cs index 38fc678..3606cfb 100644 --- a/Assets/uDesktopDuplication/Scripts/Monitor.cs +++ b/Assets/uDesktopDuplication/Scripts/Monitor.cs @@ -131,8 +131,10 @@ public class Monitor public void Render() { - Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr()); - GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id); + if (texture_) { + Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr()); + GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id); + } } public void UpdateCursorTexture(System.IntPtr ptr) @@ -155,7 +157,12 @@ public class Monitor } } + if (w <= 0 || h <= 0) { + shouldCreate = false; + } + if (shouldCreate) { + Debug.Log(w + " " + h); texture_ = new Texture2D(w, h, TextureFormat.BGRA32, false); } }