Compare commits

..

13 Commits

Author SHA1 Message Date
hecomi
e6407d1c3b modify raycast. 2016-12-18 14:57:31 +09:00
hecomi
620a0f3150 calculate coordinates of raycast hit point. 2016-12-15 22:17:12 +09:00
hecomi
d519dba120 add raycast api. 2016-12-15 02:30:04 +09:00
hecomi
295b41f57b fix standard shader normal bug. 2016-12-04 11:59:08 +09:00
hecomi
6a8bd86d2b fix thickness bug. 2016-12-03 23:27:31 +09:00
hecomi
22bc306732 fix zoom bug. 2016-12-03 23:15:37 +09:00
hecomi
3ed37d1436 tweak scenes. 2016-12-03 23:15:32 +09:00
hecomi
03419f2918 make monitor rotation setter private. 2016-12-03 22:34:49 +09:00
hecomi
2ee8ba35b7 add monitor rotation to editor. 2016-12-03 21:24:32 +09:00
hecomi
2a536ce018 fix scene loop bug. 2016-12-03 21:22:01 +09:00
hecomi
54531a90f3 add texture editor. 2016-12-03 21:18:12 +09:00
hecomi
ae8323fe29 add 32-bit dll. 2016-12-03 01:05:45 +09:00
hecomi
d23fe2fc3d fix indent. 2016-12-01 22:42:17 +09:00
30 changed files with 685 additions and 135 deletions

View File

@@ -0,0 +1,119 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
namespace uDesktopDuplication
{
[CustomEditor(typeof(Texture))]
public class TextureEditor : Editor
{
Texture texture
{
get { return target as Texture; }
}
Monitor monitor
{
get { return texture.monitor; }
}
bool isAvailable
{
get { return monitor == null || !Application.isPlaying; }
}
bool basicsFolded_ = true;
bool invertFolded_ = true;
bool clipFolded_ = true;
bool matFolded_ = true;
SerializedProperty invertX_;
SerializedProperty invertY_;
SerializedProperty useClip_;
SerializedProperty clipPos_;
SerializedProperty clipScale_;
void OnEnable()
{
invertX_ = serializedObject.FindProperty("invertX_");
invertY_ = serializedObject.FindProperty("invertY_");
useClip_ = serializedObject.FindProperty("useClip_");
clipPos_ = serializedObject.FindProperty("clipPos");
clipScale_ = serializedObject.FindProperty("clipScale");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.Space();
DrawMonitor();
DrawInvert();
DrawClip();
DrawMaterial();
serializedObject.ApplyModifiedProperties();
}
void Fold(string name, ref bool folded, System.Action func)
{
folded = Utils.Foldout(name, folded);
if (folded) {
++EditorGUI.indentLevel;
func();
--EditorGUI.indentLevel;
}
}
void DrawMonitor()
{
Fold("Monitor", ref basicsFolded_, () => {
if (isAvailable) {
EditorGUILayout.HelpBox("Monitor information is available only in runtime.", MessageType.Info);
return;
}
var id = EditorGUILayout.Popup("Monitor", monitor.id, Manager.monitors.Select(x => x.name).ToArray());
if (id != monitor.id) { texture.monitorId = id; }
EditorGUILayout.IntField("ID", monitor.id);
EditorGUILayout.Toggle("Is Primary", monitor.isPrimary);
EditorGUILayout.EnumPopup("Rotation", monitor.rotation);
EditorGUILayout.Vector2Field("Resolution", new Vector2(monitor.width, monitor.height));
EditorGUILayout.Vector2Field("DPI", new Vector2(monitor.dpiX, monitor.dpiY));
});
}
void DrawInvert()
{
Fold("Invert", ref invertFolded_, () => {
texture.invertX = EditorGUILayout.Toggle("Invert X", invertX_.boolValue);
texture.invertY = EditorGUILayout.Toggle("Invert Y", invertY_.boolValue);
});
}
void DrawClip()
{
Fold("Clip", ref clipFolded_, () => {
texture.useClip = EditorGUILayout.Toggle("Use Clip", useClip_.boolValue);
EditorGUILayout.PropertyField(clipPos_);
EditorGUILayout.PropertyField(clipScale_);
});
}
void DrawMaterial()
{
Fold("Material", ref matFolded_, () => {
if (!Application.isPlaying) {
EditorGUILayout.HelpBox("These parameters are applied to the shared material when not playing.", MessageType.Info);
}
texture.meshForwardDirection = (Texture.MeshForwardDirection)EditorGUILayout.EnumPopup("Mesh Forward Direction", texture.meshForwardDirection);
texture.bend = EditorGUILayout.Toggle("Use Bend", texture.bend);
texture.width = EditorGUILayout.FloatField("Bend Width", texture.width);
texture.radius = EditorGUILayout.Slider("Bend Radius", texture.radius, texture.worldWidth / (2 * Mathf.PI), 100f);
texture.thickness = EditorGUILayout.Slider("Thickness", texture.thickness, 0f, 30f);
texture.culling = (Texture.Culling)EditorGUILayout.EnumPopup("Culling", texture.culling);
});
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1202a4540abf0ad4781c025339772c4a
timeCreated: 1480758898
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using UnityEngine;
using UnityEditor;
namespace uDesktopDuplication
{
public static class Utils
{
public static bool Foldout(string title, bool display)
{
var style = new GUIStyle("ShurikenModuleTitle");
style.font = new GUIStyle(EditorStyles.label).font;
style.border = new RectOffset(15, 7, 4, 4);
style.fixedHeight = 22;
style.contentOffset = new Vector2(20f, -2f);
var rect = GUILayoutUtility.GetRect(16f, 22f, style);
GUI.Box(rect, title, style);
var e = Event.current;
var toggleRect = new Rect(rect.x + 4f, rect.y + 2f, 13f, 13f);
if (e.type == EventType.Repaint) {
EditorStyles.foldout.Draw(toggleRect, false, false, display, false);
}
if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition)) {
display = !display;
e.Use();
}
return display;
}
public static void ReadOnlyTextField(string label, string text)
{
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.LabelField(label, GUILayout.Width(EditorGUIUtility.labelWidth - 4));
EditorGUILayout.SelectableLabel(text, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
}
EditorGUILayout.EndHorizontal();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 278117152a6252546a219a17ef6f21f4
timeCreated: 1480759393
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f68bd0626da87264cb4daca57d3c1594
timeCreated: 1481736541
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -116,7 +116,7 @@ public class MultipleMonitorCreator : MonoBehaviour
for (int i = 0; i < n; ++i) {
// Create monitor obeject
var go = Instantiate(monitorPrefab);
go.name = "Monitor " + i;
go.name = uDesktopDuplication.Manager.monitors[i].name;
// Saved infomation
if (savedInfoList.Count == i) {

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using System.Collections;
public class RaycastTest : MonoBehaviour
{
public Transform from;
public Transform to;
void Update()
{
if (!from || !to) return;
Debug.DrawLine(from.position, to.position, Color.red);
foreach (var uddTexture in GameObject.FindObjectsOfType<uDesktopDuplication.Texture>()) {
var result = uddTexture.RayCast(from.position, to.position - from.position);
if (result.hit) {
Debug.DrawLine(result.position, result.position + result.normal, Color.yellow);
Debug.Log("COORD: " + result.coords + ", DESKTOP: " + result.desktopCoord);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 810a4ad59c7d8d34e9b6014e8191fffe
timeCreated: 1481722966
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -47,7 +47,7 @@ public class UddSceneManager : MonoBehaviour
void Prev()
{
sceneNo = (sceneNo - 1) % scenes.Length;
sceneNo = (sceneNo + scenes.Length - 1) % scenes.Length;
Load();
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a3ded3542f0e6b74ea0ff9ea58aea2f2
folderAsset: yes
timeCreated: 1480693928
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
fileFormatVersion: 2
guid: 19d4c78204afead44b6de11427d7f2f6
timeCreated: 1480693943
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
CPU: x86
DefaultValueInitialized: true
Linux:
enabled: 1
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: None
LinuxUniversal:
enabled: 1
settings:
CPU: x86
OSXIntel:
enabled: 1
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: None
OSXUniversal:
enabled: 0
settings:
CPU: x86
Win:
enabled: 1
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -14,7 +14,41 @@ PluginImporter:
Editor:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
LinuxUniversal:
enabled: 0
settings:
CPU: None
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
OSXUniversal:
enabled: 0
settings:
CPU: None
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -6,7 +6,7 @@ namespace uDesktopDuplication
[AddComponentMenu("uDesktopDuplication/Texture")]
public class Texture : MonoBehaviour
{
private Monitor monitor_;
Monitor monitor_;
public Monitor monitor
{
get { return monitor_; }
@@ -14,33 +14,113 @@ public class Texture : MonoBehaviour
{
monitor_ = value;
if (monitor_ != null) {
material = GetComponent<Renderer>().material; // clone
material.mainTexture = monitor_.texture;
material.SetFloat("_Width", transform.localScale.x);
width = transform.localScale.x;
rotation = monitor.rotation;
invertX = invertX_;
invertY = invertY_;
useClip = useClip_;
}
}
}
private int lastMonitorId_ = 0;
int lastMonitorId_ = 0;
public int monitorId
{
get { return monitor.id; }
set { monitor = Manager.GetMonitor(value); }
}
[Header("Invert UVs")]
public bool invertX = false;
public bool invertY = false;
[SerializeField] bool invertX_ = false;
public bool invertX
{
get
{
return invertX_;
}
set
{
invertX_ = value;
if (invertX_) {
material.EnableKeyword("INVERT_X");
} else {
material.DisableKeyword("INVERT_X");
}
}
}
[Header("Clip")]
public bool useClip = false;
[SerializeField] bool invertY_ = false;
public bool invertY
{
get
{
return invertY_;
}
set
{
invertY_ = value;
if (invertY_) {
material.EnableKeyword("INVERT_Y");
} else {
material.DisableKeyword("INVERT_Y");
}
}
}
public MonitorRotation rotation
{
get
{
return monitor.rotation;
}
private set
{
switch (value)
{
case MonitorRotation.Identity:
material.DisableKeyword("ROTATE90");
material.DisableKeyword("ROTATE180");
material.DisableKeyword("ROTATE270");
break;
case MonitorRotation.Rotate90:
material.EnableKeyword("ROTATE90");
material.DisableKeyword("ROTATE180");
material.DisableKeyword("ROTATE270");
break;
case MonitorRotation.Rotate180:
material.DisableKeyword("ROTATE90");
material.EnableKeyword("ROTATE180");
material.DisableKeyword("ROTATE270");
break;
case MonitorRotation.Rotate270:
material.DisableKeyword("ROTATE90");
material.DisableKeyword("ROTATE180");
material.EnableKeyword("ROTATE270");
break;
default:
break;
}
}
}
[SerializeField] bool useClip_ = false;
public Vector2 clipPos = Vector2.zero;
public Vector2 clipScale = new Vector2(0.2f, 0.2f);
public enum MeshForwardDirection
public bool useClip
{
Y = 0,
Z = 1,
get
{
return useClip_;
}
set
{
useClip_ = value;
if (useClip_) {
material.EnableKeyword("USE_CLIP");
} else {
material.DisableKeyword("USE_CLIP");
}
}
}
public bool bend
@@ -61,6 +141,11 @@ public class Texture : MonoBehaviour
}
}
public enum MeshForwardDirection
{
Y = 0,
Z = 1,
}
public MeshForwardDirection meshForwardDirection
{
get
@@ -84,6 +169,24 @@ public class Texture : MonoBehaviour
}
}
public enum Culling
{
Off = 0,
Front = 1,
Back = 2,
}
public Culling culling
{
get
{
return (Culling)material.GetInt("_Cull");
}
set
{
material.SetInt("_Cull", (int)value);
}
}
public float radius
{
get { return material.GetFloat("_Radius"); }
@@ -102,10 +205,39 @@ public class Texture : MonoBehaviour
set { material.SetFloat("_Thickness", value); }
}
Material material_;
public Material material
{
get;
private set;
get
{
if (Application.isPlaying) {
return material_ ?? (material_ = GetComponent<Renderer>().material); // clone
} else {
return GetComponent<Renderer>().sharedMaterial;
}
}
}
Mesh mesh
{
get
{
return GetComponent<MeshFilter>().sharedMesh;
}
}
public float worldWidth
{
get
{
return transform.localScale.x * (mesh.bounds.extents.x * 2f);
}
}
public float worldHeight
{
get
{
return transform.localScale.y * (mesh.bounds.extents.y * 2f);
}
}
void OnEnable()
@@ -124,7 +256,7 @@ public class Texture : MonoBehaviour
void Update()
{
KeepMonitor();
monitor.shouldBeUpdated = true;
RequireUpdate();
UpdateMaterial();
}
@@ -137,6 +269,11 @@ public class Texture : MonoBehaviour
}
}
void RequireUpdate()
{
monitor.shouldBeUpdated = true;
}
void Reinitialize()
{
// Monitor instance is released here when initialized.
@@ -145,76 +282,22 @@ public class Texture : MonoBehaviour
void UpdateMaterial()
{
Invert();
Rotate();
Clip();
width = transform.localScale.x;
rotation = monitor.rotation;
material.SetVector("_ClipPositionScale", new Vector4(clipPos.x, clipPos.y, clipScale.x, clipScale.y));
}
void Invert()
public Vector3 GetWorldPositionFromCoord(Vector2 coord)
{
if (invertX) {
material.EnableKeyword("INVERT_X");
} else {
material.DisableKeyword("INVERT_X");
}
if (invertY) {
material.EnableKeyword("INVERT_Y");
} else {
material.DisableKeyword("INVERT_Y");
}
}
void Rotate()
{
switch (monitor.rotation)
{
case MonitorRotation.Identity:
material.DisableKeyword("ROTATE90");
material.DisableKeyword("ROTATE180");
material.DisableKeyword("ROTATE270");
break;
case MonitorRotation.Rotate90:
material.EnableKeyword("ROTATE90");
material.DisableKeyword("ROTATE180");
material.DisableKeyword("ROTATE270");
break;
case MonitorRotation.Rotate180:
material.DisableKeyword("ROTATE90");
material.EnableKeyword("ROTATE180");
material.DisableKeyword("ROTATE270");
break;
case MonitorRotation.Rotate270:
material.DisableKeyword("ROTATE90");
material.DisableKeyword("ROTATE180");
material.EnableKeyword("ROTATE270");
break;
default:
break;
}
}
void Clip()
{
if (useClip) {
material.EnableKeyword("USE_CLIP");
material.SetVector("_ClipPositionScale", new Vector4(clipPos.x, clipPos.y, clipScale.x, clipScale.y));
} else {
material.DisableKeyword("USE_CLIP");
}
return GetWorldPositionFromCoord((int)coord.x, (int)coord.y);
}
public Vector3 GetWorldPositionFromCoord(int u, int v)
{
// Mesh & Scale information
var mesh = GetComponent<MeshFilter>().sharedMesh;
var width = transform.localScale.x * (mesh.bounds.extents.x * 2f);
var height = transform.localScale.y * (mesh.bounds.extents.y * 2f);
// Local position (scale included).
var x = (float)(u - monitor.width / 2) / monitor.width;
var y = -(float)(v - monitor.height / 2) / monitor.height;
var localPos = new Vector3(width * x, height * y, 0f);
var localPos = new Vector3(worldWidth * x, worldHeight * y, 0f);
// Bending
if (bend) {
@@ -230,6 +313,119 @@ public class Texture : MonoBehaviour
// To world position
return transform.position + (transform.rotation * localPos);
}
public struct RayCastResult
{
public bool hit;
public Texture texture;
public Vector3 position;
public Vector3 normal;
public Vector2 coords;
public Vector2 desktopCoord;
}
static readonly RayCastResult raycastFailedResult = new RayCastResult {
hit = false,
texture = null,
position = Vector3.zero,
normal = Vector3.forward,
coords = Vector2.zero,
desktopCoord = Vector2.zero,
};
// This function can be used only for vertical (= MeshForwardDirection.Z) plane.
public RayCastResult RayCast(Vector3 from, Vector3 dir)
{
var r = radius;
var center = transform.position - transform.forward * r;
// Localize the start point of the ray and the direction.
var trs = Matrix4x4.TRS(center, transform.rotation, Vector3.one);
var invTrs = trs.inverse;
Vector3 localFrom = invTrs.MultiplyPoint3x4(from);
Vector3 localDir = invTrs.MultiplyVector(dir).normalized;
// Calculate the intersection points of circle and line on the X-Z plane.
var a = localDir.z / localDir.x;
var b = localFrom.z - a * localFrom.x;
var aa = a * a;
var bb = b * b;
var ab = a * b;
var rr = r * r;
var s = aa * rr - bb + rr;
if (s < 0f) {
return raycastFailedResult;
}
s = Mathf.Sqrt(s);
var t = aa + 1;
var lx0 = (-s - ab) / t;
var lz0 = (b - a * s) / t;
var to0 = new Vector3(lx0, 0f, lz0);
var lx1 = (s - ab) / t;
var lz1 = (a * s + b) / t;
var to1 = new Vector3(lx1, 0f, lz1);
var to = (Vector3.Dot(localDir, to0) > 0f) ? to0 : to1;
// Check if the point is inner angle of mesh width.
var toAngle = Mathf.Atan2(to.x, to.z);
var halfWidthAngle = (worldWidth / radius) * 0.5f;
if (Mathf.Abs(toAngle) > halfWidthAngle) {
return raycastFailedResult;
}
// Calculate the intersection points on XZ-Y plane.
var v = to - localFrom;
var l = Mathf.Sqrt(Mathf.Pow(v.x, 2f) + Mathf.Pow(v.z, 2f));
var ly = localFrom.y + l * localDir.y / Mathf.Sqrt(Mathf.Pow(localDir.x, 2f) + Mathf.Pow(localDir.z, 2f));
// Check if the point is inner mesh height.
var halfHeight = worldHeight * 0.5f;
if (Mathf.Abs(ly) > halfHeight) {
return raycastFailedResult;
}
// Check hit position is in the range of the ray.
to.y = ly;
var hitPos = trs.MultiplyPoint(to);
if ((hitPos - from).magnitude > dir.magnitude) {
return raycastFailedResult;
}
// Calculate coordinates.
var coordX = toAngle / halfWidthAngle * 0.5f;
var coordY = ly / halfHeight * 0.5f;
int desktopX = monitor.left + (int)((coordX + 0.5f) * monitor.width);
int desktopY = monitor.top + (int)((0.5f - coordY) * monitor.height);
// Calculate normal.
var normal = new Vector3(-to.x, 0f, -to.z);
// Result
return new RayCastResult {
hit = true,
texture = this,
position = trs.MultiplyPoint(to),
normal = trs.MultiplyVector(normal).normalized,
coords = new Vector2(coordX, coordY),
desktopCoord = new Vector2(desktopX, desktopY)
};
}
public static RayCastResult RayCastAll(Vector3 from, Vector3 dir)
{
foreach (var uddTexture in GameObject.FindObjectsOfType<uDesktopDuplication.Texture>()) {
var result = uddTexture.RayCast(from, dir);
if (result.hit) return result;
}
return raycastFailedResult;
}
}
}

View File

@@ -95,9 +95,9 @@ inline void uddBendVertex(inout float3 v, half radius, half width, half thicknes
v.x = radius * sin(angle) / width;
#else
#ifdef _FORWARD_Z
v.y *= thickness;
#elif _FORWARD_Y
v.z *= thickness;
#elif _FORWARD_Y
v.y *= thickness;
#endif
#endif
}

View File

@@ -7,6 +7,11 @@ Properties
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0, 1)) = 0.5
_Metallic ("Metallic", Range(0, 1)) = 0.0
[KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0
[Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0
[PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30
[PowerSlider(10.0)] _Thickness("Thickness", Range(0.01, 10)) = 1
_Width("Width", Range(0.0, 10.0)) = 1.0
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
}
@@ -19,18 +24,28 @@ SubShader
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard fullforwardshadows
#pragma surface surf Standard fullforwardshadows vertex:vert
#pragma multi_compile ___ INVERT_X
#pragma multi_compile ___ INVERT_Y
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
#pragma multi_compile ___ USE_BEND
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
#define SURFACE_SHADER
#include "./uDD_Common.cginc"
half _Glossiness;
half _Metallic;
half _Radius;
half _Width;
half _Thickness;
void vert(inout appdata_full v)
{
uddBendNormal(v.vertex.x, v.normal, _Radius, _Width);
uddBendVertex(v.vertex.xyz, _Radius, _Width, _Thickness);
}
void surf(Input IN, inout SurfaceOutputStandard o)
{

View File

@@ -58,9 +58,9 @@ Pass
#pragma multi_compile ___ INVERT_X
#pragma multi_compile ___ INVERT_Y
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
#pragma multi_compile ___ USE_BEND
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile _BEND_OFF _BEND_Y _BEND_Z
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
ENDCG
}

View File

@@ -54,9 +54,9 @@ Pass
#pragma multi_compile ___ INVERT_X
#pragma multi_compile ___ INVERT_Y
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
#pragma multi_compile ___ USE_BEND
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile _BEND_OFF _BEND_Y _BEND_Z
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
ENDCG
}

View File

@@ -49,19 +49,19 @@ public:
int GetDpiX() const;
int GetDpiY() const;
IDXGIOutputDuplication* GetDeskDupl();
int GetMoveRectCount() const;
DXGI_OUTDUPL_MOVE_RECT* GetMoveRects() const;
int GetDirtyRectCount() const;
RECT* GetDirtyRects() const;
int GetMoveRectCount() const;
DXGI_OUTDUPL_MOVE_RECT* GetMoveRects() const;
int GetDirtyRectCount() const;
RECT* GetDirtyRects() const;
void UseGetPixels(bool use);
bool UseGetPixels() const;
bool GetPixels(BYTE* output, int x, int y, int width, int height);
private:
void UpdateCursor(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void UpdateMetadata(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void UpdateMoveRects(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void UpdateDirtyRects(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void UpdateCursor(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void UpdateMetadata(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void UpdateMoveRects(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void UpdateDirtyRects(const DXGI_OUTDUPL_FRAME_INFO& frameInfo);
void CopyTextureFromGpuToCpu(ID3D11Texture2D* texture);
int id_ = -1;
@@ -74,9 +74,9 @@ private:
ID3D11Texture2D* unityTexture_ = nullptr;
DXGI_OUTPUT_DESC outputDesc_;
MONITORINFOEX monitorInfo_;
Buffer<BYTE> metaData_;
Buffer<BYTE> metaData_;
Microsoft::WRL::ComPtr<ID3D11Texture2D> textureForGetPixels_;
Buffer<BYTE> bufferForGetPixels_;
UINT moveRectSize_ = 0;
UINT dirtyRectSize_ = 0;;
Buffer<BYTE> bufferForGetPixels_;
UINT moveRectSize_ = 0;
UINT dirtyRectSize_ = 0;;
};

View File

@@ -104,7 +104,7 @@ bool MonitorManager::HasMonitorCountChanged() const
std::shared_ptr<Monitor> MonitorManager::GetMonitor(int id) const
{
if (id >= 0 && id < monitors_.size())
if (id >= 0 && id < static_cast<int>(monitors_.size()))
{
return monitors_[id];
}

View File

@@ -5,14 +5,14 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
@@ -25,20 +25,13 @@
<ProjectName>uDesktopDuplication</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
@@ -51,37 +44,45 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);include</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -92,21 +93,14 @@
<Command>copy /Y "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" "$(SolutionDir)..\..\Assets\$(ProjectName)\Plugins\x86_64"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>
</Command>
<Command>copy /Y "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" "$(SolutionDir)..\..\Assets\$(ProjectName)\Plugins\x86_64"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -126,6 +120,23 @@
<Command>copy /Y "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" "$(SolutionDir)..\..\Assets\$(ProjectName)\Plugins\x86_64"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>copy /Y "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" "$(SolutionDir)..\..\Assets\$(ProjectName)\Plugins\x86"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Common.cpp" />
<ClCompile Include="Debug.cpp" />