@@ -10,13 +10,45 @@ namespace OVRSharp.Graphics.DirectX
1010{
1111 public class DirectXCompositor : ICompositorAPI
1212 {
13+ /// <summary>
14+ /// Global, static instance of <see cref="DirectXCompositor"/>.
15+ /// </summary>
16+ public static DirectXCompositor Instance
17+ {
18+ get
19+ {
20+ if ( _instance == null )
21+ _instance = new DirectXCompositor ( ) ;
22+
23+ return _instance ;
24+ }
25+ }
26+
27+ private static DirectXCompositor _instance = null ;
28+
1329 private readonly Device device ;
1430
31+ /// <summary>
32+ /// A DirectX-based implementation of <see cref="ICompositorAPI"/>.<br/><br/>
33+ ///
34+ /// Ideally, there should ever only be one instance of this class
35+ /// at once. You can provide <see cref="Instance"/> to anything that depends
36+ /// on <see cref="ICompositorAPI"/> to ensure that this is the case.
37+ /// </summary>
1538 public DirectXCompositor ( )
1639 {
1740 device = new Device ( SharpDX . Direct3D . DriverType . Hardware , DeviceCreationFlags . Debug ) ;
1841 }
1942
43+ /// <summary>
44+ /// <inheritdoc/><br/><br/>
45+ ///
46+ /// <strong>Warning:</strong> this is a pretty slow method.
47+ /// It's fine to use this for one-off captures, but if you require
48+ /// something like a constant stream of the headset view, I recommend
49+ /// digging into a lower-level implementation.
50+ /// </summary>
51+ /// <inheritdoc/>
2052 public Bitmap GetMirrorImage ( EVREye eye = EVREye . Eye_Left )
2153 {
2254 var srvPtr = IntPtr . Zero ;
@@ -46,7 +78,7 @@ public Bitmap GetMirrorImage(EVREye eye = EVREye.Eye_Left)
4678 Usage = ResourceUsage . Staging
4779 } ) )
4880 {
49- // Copy texture to CPU so we can read from it
81+ // Copy texture to RAM so CPU can read from it
5082 device . ImmediateContext . CopyResource ( tex , cpuTex ) ;
5183 OpenVR . Compositor . ReleaseMirrorTextureD3D11 ( srvPtr ) ;
5284
0 commit comments