Ejemplo n.º 1
0
        /// <summary>
        /// Make sure to call this after a Window context is made!
        /// </summary>
        /// <returns></returns>
        public static IVSyncContext CreateContext()
        {
            try
            {
                var openAdapter        = new D3DKMT_OPENADAPTERFROMHDC();
                var waitForVblankEvent = new D3DKMT_WAITFORVERTICALBLANKEVENT();

                var hdc = CreateDC(Screen.PrimaryScreen.DeviceName, null, null, IntPtr.Zero);
                openAdapter.hDc = hdc;
                var result = D3DKMTOpenAdapterFromHdc(ref openAdapter);
                if (result != 0)
                {
                    throw new Exception("D3DKMTOpenAdapterFromHdc failed");
                }

                waitForVblankEvent.hAdapter      = openAdapter.hAdapter;
                waitForVblankEvent.hDevice       = 0;
                waitForVblankEvent.VidPnSourceId = openAdapter.VidPnSourceId;

                return(new VsyncContext(waitForVblankEvent));
            }
            catch (Exception e)
            {
                ReportFactory.FallbackReport.Error(e);
            }

            return(new SimulatedVSync());
        }
Ejemplo n.º 2
0
 static extern uint D3DKMTWaitForVerticalBlankEvent(ref D3DKMT_WAITFORVERTICALBLANKEVENT pData);
Ejemplo n.º 3
0
 internal VsyncContext(D3DKMT_WAITFORVERTICALBLANKEVENT waitforverticalblankevent)
 {
     _waitforverticalblankevent = waitforverticalblankevent;
 }