show not-available texture when display is not available.

This commit is contained in:
hecomi
2016-11-05 23:15:57 +09:00
parent 7774290e71
commit f9f8b14f46
9 changed files with 41 additions and 1 deletions
@@ -50,6 +50,8 @@ public static class Lib
[DllImport("uDesktopDuplication")]
public static extern IntPtr GetRenderEventFunc();
[DllImport("uDesktopDuplication")]
public static extern bool IsAvailable();
[DllImport("uDesktopDuplication")]
public static extern void GetName(int id, StringBuilder buf, int len);
[DllImport("uDesktopDuplication")]
public static extern int GetLeft(int id);
+11 -1
View File
@@ -21,6 +21,11 @@ public class Monitor
get { return id < Manager.monitorCount; }
}
public bool available
{
get { return Lib.IsAvailable(); }
}
public string name
{
get { return Lib.GetName(id); }
@@ -122,6 +127,9 @@ public class Monitor
{
get
{
if (!available) {
return Resources.Load<Texture2D>("uDesktopDuplication/Textures/NotAvailable");
}
if (texture_ == null) {
CreateTexture();
}
@@ -131,7 +139,7 @@ public class Monitor
public void Render()
{
if (texture_) {
if (texture_ && available) {
Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr());
GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id);
}
@@ -144,6 +152,8 @@ public class Monitor
void CreateTexture()
{
if (!available) return;
var w = isHorizontal ? width : height;
var h = isHorizontal ? height : width;
bool shouldCreate = true;