Exemple #1
0
        public void StartDirect3D(Window window)
        {
            Direct3DContext = new Direct3DEx();

            var presentParameters = new PresentParameters
            {
                Windowed             = true,
                SwapEffect           = SwapEffect.Discard,
                DeviceWindowHandle   = new WindowInteropHelper(window).Handle,
                PresentationInterval = SharpDX.Direct3D9.PresentInterval.Default
            };

            Direct3DDevice = new DeviceEx(Direct3DContext, 0, DeviceType.Hardware, IntPtr.Zero,
                                          CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve,
                                          presentParameters);

            // Create the device using the main window handle, and a placeholder size (1,1).
            // The actual size doesn't matter because whenever we render using this GraphicsDevice,
            // we will make sure the back buffer is large enough for the window we're rendering into.
            // Also, the handle doesn't matter because we call GraphicsDevice.Present(...) with the
            // actual window handle to render into.
            GraphicsDevice = CreateGraphicsDevice(new WindowInteropHelper(window).Handle, 1, 1);

            DeviceCreated?.Invoke(this, EventArgs.Empty);
        }
Exemple #2
0
 private void Apply(DeviceCreated @event)
 {
     this.Id                     = @event.DeviceId;
     this._deviceName            = @event.DeviceName;
     this._serialNumber          = @event.SerialNumber;
     this._lastCommunicationDate = @event.LastCommunication;
 }
Exemple #3
0
        public void UpdateHandles(IntPtr[] sharedResourceHandles, string sharedMmapName)
        {
            _sharedRendererClient.SetHandles(sharedResourceHandles, sharedMmapName);

            if (GraphicsDevice == null && _sharedRendererClient.GraphicsDeviceExpected)
            {
                // We have been requested to create a graphics device.
                var parameters = new PresentationParameters();

                parameters.BackBufferWidth      = 1;
                parameters.BackBufferHeight     = 1;
                parameters.BackBufferFormat     = SurfaceFormat.Color;
                parameters.DepthStencilFormat   = DepthFormat.Depth24;
                parameters.DeviceWindowHandle   = IntPtr.Zero;
                parameters.PresentationInterval = PresentInterval.Immediate;
                parameters.IsFullScreen         = false;

                GraphicsDevice = new GraphicsDevice(
                    GraphicsAdapter.DefaultAdapter,
                    GraphicsProfile.HiDef,
                    parameters);

                DeviceCreated?.Invoke(this, EventArgs.Empty);
            }

            if (GraphicsDevice != null && !_sharedRendererClient.GraphicsDeviceExpected)
            {
                DeviceDisposing?.Invoke(this, EventArgs.Empty);

                GraphicsDevice.Dispose();
                GraphicsDevice = null;
            }

            _sharedRendererClient.UpdateTextures(GraphicsDevice);
        }
        private void InitSystem()
        {
            Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(1000, 1000, Self, new Evalutate(), ActorRefs.NoSender);

            var gatewaystrepo = repositoryManager.Ask <List <GatewayModel> >(new GetAll()).Result;

            foreach (var gateway in gatewaystrepo)
            {
                var gatewayCreated     = new GatewayCreated(gateway.Id);
                var gatewaySended      = new GatewaySended(gateway.Id, gateway.Value);
                var gatewayStarted     = new GatewayStarted(gateway.Id, gateway.Ip);
                var gatewayUpdate      = new GatewayUpdate(gateway.Id, gateway.Name);
                var gatewayDisconnectd = new GatewayDisconnected(gateway.Id);
                var gatewayStatus      = new GatewayStatus(gateway.Id);

                deviceManager.Tell(gatewayCreated.GatewayPhysicalCreated);
                dashboardManager.Tell(gatewayCreated.GatewayDashBoardCreated);

                deviceManager.Tell(gatewaySended.GatewayPhysicalSended);
                dashboardManager.Tell(gatewaySended.GatewayDashBoardSended);

                dashboardManager.Tell(gatewayStarted.GatewayDashBoardStarted);

                dashboardManager.Tell(gatewayUpdate.GatewayDashBoardUpdate);

                deviceManager.Tell(gatewayDisconnectd.GatewayPhysicalDisconnected);
                dashboardManager.Tell(gatewayDisconnectd.GatewayDashBoardDisconnected);

                deviceManager.Tell(gatewayStatus.GatewayPhysicalStatus);

                foreach (var device in gateway.Devices)
                {
                    var deviceInfo        = new DeviceInfo(device.Id, gateway.Id);
                    var deviceCreated     = new DeviceCreated(deviceInfo);
                    var deviceSended      = new DeviceSended(deviceInfo, device.Value);
                    var deviceStarted     = new DeviceStarted(deviceInfo, device.Ip);
                    var deviceUpdate      = new DeviceUpdate(deviceInfo, device.Name);
                    var deviceDisconnectd = new DeviceDisconnected(deviceInfo);
                    var deviceStatus      = new DeviceStatus(deviceInfo);

                    deviceManager.Tell(deviceCreated.DevicePhysicalCreated);
                    dashboardManager.Tell(deviceCreated.DeviceDashBoardCreated);

                    deviceManager.Tell(deviceSended.DevicePhysicalSended);
                    dashboardManager.Tell(deviceSended.DeviceDashBoardSended);

                    dashboardManager.Tell(deviceStarted.DeviceDashBoardStarted);

                    dashboardManager.Tell(deviceUpdate.DeviceDashBoardUpdate);

                    deviceManager.Tell(deviceDisconnectd.DevicePhysicalDisconnected);
                    dashboardManager.Tell(deviceDisconnectd.DeviceDashBoardDisconnected);

                    deviceManager.Tell(deviceStatus.DevicePhysicalStatus);
                }
            }
        }
        public void UpdateHandles(IntPtr[] sharedResourceHandles, int currentWriteIndex)
        {
            _currentWriteIndex = currentWriteIndex;

            if (GraphicsDevice == null && sharedResourceHandles[_currentWriteIndex] != IntPtr.Zero)
            {
                // We have been requested to create a graphics device.
                var parameters = new PresentationParameters();

                parameters.BackBufferWidth      = 1;
                parameters.BackBufferHeight     = 1;
                parameters.BackBufferFormat     = SurfaceFormat.Color;
                parameters.DepthStencilFormat   = DepthFormat.Depth24;
                parameters.DeviceWindowHandle   = IntPtr.Zero;
                parameters.PresentationInterval = PresentInterval.Immediate;
                parameters.IsFullScreen         = false;

                GraphicsDevice = new GraphicsDevice(
                    GraphicsAdapter.DefaultAdapter,
                    GraphicsProfile.HiDef,
                    parameters);

                DeviceCreated?.Invoke(this, EventArgs.Empty);
            }

            if (GraphicsDevice != null && sharedResourceHandles[_currentWriteIndex] == IntPtr.Zero)
            {
                DeviceDisposing?.Invoke(this, EventArgs.Empty);

                GraphicsDevice.Dispose();
                GraphicsDevice = null;
            }

            if (_sharedResourceHandles[_currentWriteIndex] != sharedResourceHandles[_currentWriteIndex])
            {
                for (var i = 0; i < RenderTargetBufferConfiguration.RTBufferSize; i++)
                {
                    _renderTargets[i]?.Dispose();
                    _renderTargets[i] = null;
                }

                for (var i = 0; i < RenderTargetBufferConfiguration.RTBufferSize; i++)
                {
                    if (GraphicsDevice != null)
                    {
                        _renderTargets[i] = RenderTarget2D.FromSharedResourceHandle(
                            GraphicsDevice,
                            sharedResourceHandles[i]);
                    }
                }

                _sharedResourceHandles = sharedResourceHandles;
            }
        }
Exemple #6
0
 private void RaiseDeviceCreated(int id, string displayName, int volume, bool isMuted)
 {
     if (SynchronizationContext.Current != _synchronizationContext)
     {
         _synchronizationContext.Post(o => DeviceCreated?.Invoke(this, id, displayName, volume, isMuted), null);
     }
     else
     {
         DeviceCreated.Invoke(this, id, displayName, volume, isMuted);
     }
 }
 public GraphicsDeviceService(GraphicsDevice device)
 {
     this.device             = device;
     device.Disposing       += new EventHandler <EventArgs>(device_Disposing);
     device.DeviceResetting += new EventHandler <EventArgs>(device_DeviceResetting);
     device.DeviceReset     += new EventHandler <EventArgs>(device_DeviceReset);
     if (DeviceCreated != null)
     {
         DeviceCreated.Invoke(device, new EventArgs());
     }
 }
Exemple #8
0
        private void CreateDevice(IntPtr hWnd, int width, int height, GraphicsProfile profile)
        {
            var adapter = GraphicsAdapter.DefaultAdapter;
            var pp      = new PresentationParameters {
                DeviceWindowHandle = hWnd,
                BackBufferWidth    = Math.Max(width, 1),
                BackBufferHeight   = Math.Max(height, 1),
                BackBufferFormat   = SurfaceFormat.Color,
                DepthStencilFormat = DepthFormat.Depth16
            };

            _device = new GraphicsDevice(adapter, profile, pp);

            DeviceCreated?.Invoke(this, EventArgs.Empty);
        }
        public void SurfaceCreated(ISurfaceHolder holder)
        {
            bool deviceCreated = false;

            if (_backend == GraphicsBackend.Vulkan)
            {
                if (GraphicsDevice == null)
                {
                    SwapchainSource      ss = SwapchainSource.CreateAndroidSurface(holder.Surface.Handle, JNIEnv.Handle);
                    SwapchainDescription sd = new SwapchainDescription(
                        ss,
                        (uint)Width,
                        (uint)Height,
                        DeviceOptions.SwapchainDepthFormat,
                        DeviceOptions.SyncToVerticalBlank);
                    GraphicsDevice = GraphicsDevice.CreateVulkan(DeviceOptions, sd);
                    deviceCreated  = true;
                }

                Debug.Assert(MainSwapchain == null);

                MainSwapchain = GraphicsDevice.MainSwapchain;
            }
            else
            {
                Debug.Assert(GraphicsDevice == null && MainSwapchain == null);
                SwapchainSource      ss = SwapchainSource.CreateAndroidSurface(holder.Surface.Handle, JNIEnv.Handle);
                SwapchainDescription sd = new SwapchainDescription(
                    ss,
                    (uint)Width,
                    (uint)Height,
                    DeviceOptions.SwapchainDepthFormat,
                    DeviceOptions.SyncToVerticalBlank);
                GraphicsDevice = GraphicsDevice.CreateOpenGLES(DeviceOptions, sd);
                MainSwapchain  = GraphicsDevice.MainSwapchain;
                deviceCreated  = true;
            }

            if (deviceCreated)
            {
                DeviceCreated?.Invoke();
            }

            _surfaceCreated = true;
        }
Exemple #10
0
        private void CreateDevice(IntPtr windowHandle)
        {
            _parameters = new PresentationParameters
            {
                BackBufferWidth    = 480,
                BackBufferHeight   = 320,
                BackBufferFormat   = SurfaceFormat.Color,
                DeviceWindowHandle = windowHandle,
                DepthStencilFormat = DepthFormat.Depth24Stencil8,
                IsFullScreen       = false
            };

            GraphicsDevice = new GraphicsDevice(
                GraphicsAdapter.DefaultAdapter,
                GraphicsProfile.HiDef,
                _parameters);

            DeviceCreated?.Invoke(this, EventArgs.Empty);
        }
 protected virtual void OnDeviceCreated(object sender, EventArgs args)
 {
     DeviceCreated?.Invoke(sender, args);
 }
 public void CreateDevice()
 {
     ApplyChanges();
     DeviceCreated?.Invoke(this, EventArgs.Empty);
 }
Exemple #13
0
 internal void OnDeviceCreated(EventArgs e) => DeviceCreated?.Invoke(this, e);
 protected virtual void OnDeviceCreated(EventArgs e)
 {
     DeviceCreated?.Invoke(this, e);
     ForceRendering();
 }
 protected virtual void OnDeviceCreated(DeviceCreatedEventArgs e)
 {
     DeviceCreated?.Invoke(this, e);
 }
        public void Add(DeviceCreated message)
        {
            var deviceDb = this.deviceCreateTranslator.Translate(message);

            this.dataStore.Insert(deviceDb);
        }
 // FIXME: Why does the GraphicsDeviceManager not know enough about the
 //        GraphicsDevice to raise these events without help?
 internal void OnDeviceCreated()
 {
     DeviceCreated?.Invoke(this);
 }