Пример #1
0
        internal void InitializeBeforeRun()
        {
            // Make sure that the device is already created
            deviceManager.CreateDevice();

            // Gets the graphics device service
            deviceService = Services.GetService(typeof(IDirectXDeviceService)) as IDirectXDeviceService;
            if (deviceService == null)
            {
                throw new InvalidOperationException("No deviceService found");
            }

            // Checks the graphics device
            if (deviceService.DirectXDevice == null)
            {
                throw new InvalidOperationException("No device found");
            }

            // Initialize this instance and all game systems
            Initialize();

            IsRunning = true;

            //BeginRun();

            timer.Reset();
            appTime.Update(totalTime, TimeSpan.Zero, false);
            appTime.FrameCount = 0;

            // Run an update for the first time
            updateCallback.Update(appTime);
            isFirstUpdateDone = true;
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of <see cref="Direct2DDevice" />.
 /// events via
 /// <see cref="IDirectXDeviceService" />.
 /// </summary>
 /// <exception cref="ArgumentNullException">If <paramref name="services" /> is null.</exception>
 public Direct2DDevice(IServiceRegistry services, DebugLevel debugLevel)
 {
     Contract.Requires <ArgumentNullException>(services != null, "services");
     dx11Service     = services.GetService <IDirectXDeviceService>();
     this.services   = services;
     this.debugLevel = debugLevel;
 }
Пример #3
0
 private void AttachToD3DDevice(object sender, ServiceEventArgs e)
 {
     if (e.ServiceType == typeof(IDirectXDeviceService))
     {
         dx11Service = (IDirectXDeviceService)e.Instance;
         dx11Service.DeviceCreated     += DirectXDx11ServiceOnDx11Created;
         dx11Service.DeviceDisposing   += DirectXDx11ServiceOnDx11Disposing;
         dx11Service.DeviceChangeBegin += DirectXDx11ServiceOnDx11ChangeBegin;
         dx11Service.DeviceChangeEnd   += DirectXDx11ServiceOnDx11ChangeEnd;
         dx11Service.DeviceLost        += DirectXDx11ServiceOnDx11Lost;
         services.ServiceAdded         -= AttachToD3DDevice;
     }
 }
Пример #4
0
        private void SetupDeviceEvents()
        {
            // Find the IGraphicsDeviceSerive.
            deviceService = Services.GetService(typeof(IDirectXDeviceService)) as IDirectXDeviceService;

            // If there is no graphics device service, don't go further as the whole Game would not work
            if (deviceService == null)
            {
                throw new InvalidOperationException("Unable to create find a IGraphicsDeviceService");
            }

            if (deviceService.DirectXDevice == null)
            {
                throw new InvalidOperationException("Unable to find a Device instance");
            }

            deviceService.DeviceCreated   += deviceService_DeviceCreated;
            deviceService.DeviceDisposing += deviceService_DeviceDisposing;
        }