Exemplo n.º 1
0
        /// <summary>
        /// Dispose pattern implementation of dispose method.
        /// </summary>
        /// <param name="disposing">True if disposing, false if finalizing.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (Disposed)
            {
                return;
            }

            // Ensure that all created HMDs have been disposed.
            foreach (Hmd hmd in CreatedHmds)
            {
                if (!hmd.Disposed)
                {
                    hmd.Dispose();
                }
            }

            CreatedHmds.Clear();

            if (Initialized)
            {
                Shutdown();
            }

            // Deallocate unmanaged memory again.
            FreeHGlobal(ref m_eyePosesPtr);

            OVR.Dispose();
            OVR = null;

            Disposed = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a handle to an HMD.
        ///
        /// Upon success the returned Hmd must be eventually freed with Dispose() when it is no longer needed.
        /// </summary>
        /// <param name="graphicsLuid">
        /// Provides a system specific graphics adapter identifier that locates which
        /// graphics adapter has the HMD attached. This must match the adapter used by the application
        /// or no rendering output will be possible. This is important for stability on multi-adapter systems. An
        /// application that simply chooses the default adapter will not run reliably on multi-adapter systems.
        /// </param>
        public Hmd Hmd_Create(out OVRTypes.GraphicsLuid graphicsLuid)
        {
            IntPtr hmdPtr = IntPtr.Zero;

            graphicsLuid = new OVRTypes.GraphicsLuid();
            OVRTypes.Result result = OVR.Create(ref hmdPtr, ref graphicsLuid);
            if (result < OVRTypes.Result.Success)
            {
                return(null);
            }

            Hmd hmd = new Hmd(OVR, hmdPtr);

            // Ensure that this created HMD is disposed, when this Wrap class is being disposed.
            CreatedHmds.Add(hmd);

            return(hmd);
        }