示例#1
0
 protected PObject PObjectStatusSelect(DeviceResources deviceResources, GraphicsSignature graphicsSignature, ref PSODesc desc, PObject pObject, PObject loading, PObject unload, PObject error)
 {
     if (pObject == null)
     {
         return(unload);
     }
     if (pObject.Status == GraphicsObjectStatus.unload)
     {
         return(unload);
     }
     else if (pObject.Status == GraphicsObjectStatus.loaded)
     {
         if (pObject.GetVariantIndex(deviceResources, graphicsSignature, desc) != -1)
         {
             return(pObject);
         }
         else
         {
             return(error);
         }
     }
     else if (pObject.Status == GraphicsObjectStatus.loading)
     {
         return(loading);
     }
     else
     {
         return(error);
     }
 }
        internal TextureLoader(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;
            factory = new ImagingFactory2();

            textures = new Dictionary <string, Tuple <ShaderResourceView, Texture2D> >();
        }
示例#3
0
        // Keep track of mouse input.
        //bool                                pointerPressed = false;

        #endregion

        #region Initialize

        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public ImageViewerMain(DeviceResources deviceResources, AppView appView)
        {
            this.deviceResources = deviceResources;
            this.appview         = appView;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;

            // If connected, a game controller can also be used for input.
            Gamepad.GamepadAdded   += this.OnGamepadAdded;
            Gamepad.GamepadRemoved += this.OnGamepadRemoved;

            foreach (var gamepad in Gamepad.Gamepads)
            {
                OnGamepadAdded(null, gamepad);
            }

            timer1.IsFixedTimeStep      = true;
            timer1.TargetElapsedSeconds = 0.2;

            timer2.IsFixedTimeStep      = true;
            timer2.TargetElapsedSeconds = 0.02;

            stopWatch.Start();
        }
示例#4
0
        public static ResourceRecord QueryDeviceResources(EDevice device)
        {
            var    recs    = DeviceRecords;
            string devName = device.ToString();
            var    hit     = recs.device
                             .Where(d => d.name == devName)
                             .FirstOrDefault();

            if (hit == null)
            {
                return(null);
            }
            var result = new ResourceRecord()
            {
                Device = device
            };

            foreach (var resrec in hit.providedResources)
            {
                EDeviceResource res;
                if (DeviceResources.ResolveResourceType(resrec.name, out res))
                {
                    result.AssignResource(res, resrec.amount);
                }
            }
            return(result);
        }
示例#5
0
        public void Update(StepTimer timer, DeviceResources deviceResources)
        {
            // Rotate the cube.
            // Convert degrees to radians, then convert seconds to rotation angle.
            float     radiansPerSecond = 45.0f * ((float)Math.PI / 180.0f);
            double    totalRotation    = timer.TotalSeconds * radiansPerSecond;
            float     radians          = (float)System.Math.IEEERemainder(totalRotation, 2 * Math.PI);
            Matrix4x4 modelRotation    = Matrix4x4.CreateFromAxisAngle(new Vector3(0, 1, 0), -radians);


            // Position the cube.
            Matrix4x4 modelTranslation = Matrix4x4.CreateTranslation(position);


            // Multiply to get the transform matrix.
            // Note that this transform does not enforce a particular coordinate system. The calling
            // class is responsible for rendering this content in a consistent manner.
            Matrix4x4 modelTransform = modelRotation * modelTranslation;

            // The view and projection matrices are provided by the system; they are associated
            // with holographic cameras, and updated on a per-camera basis.
            // Here, we provide the model transform for the sample hologram. The model transform
            // matrix is transposed to prepare it for the shader.
            this.modelConstantBufferData.model = Matrix4x4.Transpose(modelTransform);


            // Use the D3D device context to update Direct3D device-based resources.
            var context = deviceResources.D3DDeviceContext;

            // Update the model transform buffer for the hologram.
            context.UpdateSubresource(ref this.modelConstantBufferData, this.modelConstantBuffer);
        }
        public CameraTestRenderer(DeviceResources deviceResources, PhysicalCamera physicalCamera)
        {
            this.deviceResources = deviceResources;
            this.physicalCamera  = physicalCamera;

            CreateDeviceDependentResourcesAsync();
        }
示例#7
0
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public WmrMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;

            // If connected, a game controller can also be used for input.
            Gamepad.GamepadAdded   += this.OnGamepadAdded;
            Gamepad.GamepadRemoved += this.OnGamepadRemoved;

            foreach (var gamepad in Gamepad.Gamepads)
            {
                OnGamepadAdded(null, gamepad);
            }

            canGetHolographicDisplayForCamera = ApiInformation.IsPropertyPresent(typeof(HolographicCamera).FullName, "Display");
            canGetDefaultHolographicDisplay   = ApiInformation.IsMethodPresent(typeof(HolographicDisplay).FullName, "GetDefault");
            canCommitDirect3D11DepthBuffer    = ApiInformation.IsMethodPresent(typeof(HolographicCameraRenderingParameters).FullName, "CommitDirect3D11DepthBuffer");
            canUseWaitForNextFrameReadyAPI    = ApiInformation.IsMethodPresent(typeof(HolographicSpace).FullName, "WaitForNextFrameReady");

            if (canGetDefaultHolographicDisplay)
            {
                // Subscribe for notifications about changes to the state of the default HolographicDisplay
                // and its SpatialLocator.
                HolographicSpace.IsAvailableChanged += this.OnHolographicDisplayIsAvailableChanged;
            }

            // Acquire the current state of the default HolographicDisplay and its SpatialLocator.
            OnHolographicDisplayIsAvailableChanged(null, null);
        }
示例#8
0
        private DeviceResources GetDeviceResources()
        {
            if (_deviceResources != null && _deviceResources.IsDeviceRemoved)
            {
                // All references to the existing D3D device must be released before a new device
                // can be created.

                _deviceResources = null;
                _main.OnDeviceRemoved();

#if DEBUG
                ComPtr <IDXGIDebug1> dxgiDebug = default;
                Guid iid = DXGIDebug.IID_IDXGIDebug1;
                if (TerraFX.Interop.Windows.SUCCEEDED(DXGI.DXGIGetDebugInterface1(0, &iid, (void **)dxgiDebug.GetAddressOf())))
                {
                    dxgiDebug.Ptr->ReportLiveObjects(new Guid(0xe48ae283, 0xda80, 0x490b, 0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x8),
                                                     DXGI_DEBUG_RLO_FLAGS.DXGI_DEBUG_RLO_SUMMARY | DXGI_DEBUG_RLO_FLAGS.DXGI_DEBUG_RLO_IGNORE_INTERNAL);
                }
#endif
            }

            if (_deviceResources == null)
            {
                _deviceResources = new DeviceResources();
                _deviceResources.SetWindow(CoreWindow.GetForCurrentThread());
                _main.CreateRenderers(_deviceResources);
            }
            return(_deviceResources);
        }
示例#9
0
 public StandardLayout(DeviceResources deviceResources) : base()
 {
     for (int i = 0; i < BlendMode.c_parameterCount; i++)
     {
         Parameters[i] = new DCParameter();
     }
 }
示例#10
0
        /// <summary>
        /// Loads vertex and pixel shaders from files and instantiates the cube geometry.
        /// </summary>
        public SpritesRenderer(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            animationEngine = new Spritesheet();
            //animationEngine.addObject("background", "idle", 1.05f, 0, 0,false);
            //animationEngine.addObject("paradog", "RunR", 1, 0, 0, false);
            //animationEngine.addObject("pipe", "normal", 0.95f, -0.1f, 0.1f, false);
            //animationEngine.addObject("pipe", "reverse", 0.95f,0.1f, 0.1f, false);
            animationEngine.setUp(30);

            ClockworkSocket.setup(animationEngine);

            //sprites = new List<Sprite>();
            //sprites.Add(new Sprite(1, 0, 0, "Assets/img/ninjacatRex.png"));
            //sprites.Add(new Sprite(-1, 0, 0, "Assets/img/ninjacatRex.png"));
            //sprites.Add(new Sprite(0, 0, -1, "Assets/img/ninjacatRex.png"));
            //sprites.Add(new Sprite(0, 0, 1, "Assets/img/ninjacatRex.png"));
            //foreach (var sprite in sprites)
            //{
            //    this.ToDispose(sprite);
            //}


            this.CreateDeviceDependentResourcesAsync();
        }
示例#11
0
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public Geoinformatics_LabMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;

            // If connected, a game controller can also be used for input.
            Gamepad.GamepadAdded   += this.OnGamepadAdded;
            Gamepad.GamepadRemoved += this.OnGamepadRemoved;

            foreach (var gamepad in Gamepad.Gamepads)
            {
                OnGamepadAdded(null, gamepad);
            }

            canGetHolographicDisplayForCamera = Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.Graphics.Holographic.HolographicCamera", "Display");
            canGetDefaultHolographicDisplay   = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.Graphics.Holographic.HolographicDisplay", "GetDefault");
            canCommitDirect3D11DepthBuffer    = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.Graphics.Holographic.HolographicCameraRenderingParameters", "CommitDirect3D11DepthBuffer");

            if (canGetDefaultHolographicDisplay)
            {
                // Subscribe for notifications about changes to the state of the default HolographicDisplay
                // and its SpatialLocator.
                HolographicSpace.IsAvailableChanged += this.OnHolographicDisplayIsAvailableChanged;
            }

            // Acquire the current state of the default HolographicDisplay and its SpatialLocator.
            OnHolographicDisplayIsAvailableChanged(null, null);
        }
 /// <summary>
 /// Loads vertex and pixel shaders from files and instantiates the cube geometry.
 /// </summary>
 public NodeRenderer(DeviceResources deviceResources, Vector3 color, float diameter = 0.05f, int tesselation = 16) : base(deviceResources)
 {
     Diameter    = diameter;
     Tesselation = tesselation;
     Color       = color;
     RenderType  = NodeType.Sphere;
 }
示例#13
0
        internal Tag(
            DeviceResources deviceResources,
            TextureLoader loader,
            int X,
            int Y,
            Matrix4x4 rotator,
            Vector3 positionLeft,
            Vector3 positionRight
            )
        {
            this.X = X;
            this.Y = Y;

            left = new PyramidRenderer(deviceResources, loader)
            {
                Position      = positionLeft,
                GlobalRotator = rotator,
                TextureFile   = "Content\\Textures\\red.png"
            };

            right = new PyramidRenderer(deviceResources, loader)
            {
                Position      = positionRight,
                GlobalRotator = rotator,
                TextureFile   = "Content\\Textures\\green.png"
            };
        }
示例#14
0
 public void Reload(DeviceResources deviceResources)
 {
     rootSignature.ReloadMMD(deviceResources);
     rootSignatureSkinning.ReloadSkinning(deviceResources);
     rootSignaturePostProcess.Reload(deviceResources, new GraphicSignatureDesc[] { GSD.CBV, GSD.SRVTable, GSD.SRVTable, GSD.CBV });
     rootSignatureCompute.ReloadCompute(deviceResources, new GraphicSignatureDesc[] { GSD.CBV, GSD.CBV, GSD.CBV, GSD.SRV, GSD.UAV, GSD.UAV });
 }
示例#15
0
        public void Dispose()
        {
            if (deviceResources != null)
            {
                deviceResources.Dispose();
                deviceResources = null;
            }

            if (main != null)
            {
                main.Dispose();
                main = null;
            }

            if (speechRecognizer != null)
            {
                speechRecognizer.Dispose();
                speechRecognizer = null;
            }

            if (Synthesizer != null)
            {
                Synthesizer.Dispose();
                Synthesizer = null;
            }

            if (MediaPlayer != null)
            {
                MediaPlayer.Dispose();
                MediaPlayer = null;
            }
        }
示例#16
0
        public CanvasCase(DeviceResources device, int canvasWidth, int canvasHeight, int renderBufferCount)
        {
            Width  = canvasWidth;
            Height = canvasHeight;

            DeviceResources = device;
            RenderTarget    = new RenderTexture[renderBufferCount];

            for (int i = 0; i < renderBufferCount; i++)
            {
                RenderTarget[i] = new RenderTexture(device, canvasWidth, canvasHeight, false);
            }

            UndoManager = new UndoManager();

            PaintingTexture       = new RenderTexture(device, canvasWidth, canvasHeight, false);
            PaintingTextureBackup = new RenderTexture(device, canvasWidth, canvasHeight, false);
            PaintingTextureTemp   = new RenderTexture(device, canvasWidth, canvasHeight, false);
            SelectionMaskTexture  = new RenderTexture(device, canvasWidth, canvasHeight, RenderTextureFormat.RENDERTEXTURE_FORMAT_R8_UNORM, false);

            PaintAgent = new PaintAgent(this);
            PaintAgent.SetPaintTarget(device, PaintingTexture, PaintingTextureBackup);
            PaintAgent.UndoManager = UndoManager;

            Layouts      = new ObservableCollection <PictureLayout>();
            ViewRenderer = new ViewRenderer(this);

            PaintAgent.ViewRenderer = ViewRenderer;

            Layouts.CollectionChanged += Layouts_Changed;
        }
示例#17
0
        int h     = 850; //2304;


        internal HistologyView(
            DeviceResources deviceResources,
            TextureLoader loader)
        {
            this.loader = loader;
            //image = new ImageRenderer(
            //    deviceResources: deviceResources,
            //    loader: loader,
            //    bottomLeft: new Vector3( Constants.X00, Constants.Y1, Constants.Z1 ),
            //    topLeft: new Vector3( Constants.X00, Constants.Y2, Constants.Z1 ),
            //    bottomRight: new Vector3( Constants.X01, Constants.Y1, Constants.Z0 ),
            //    topRight: new Vector3( Constants.X01, Constants.Y2, Constants.Z0 ),
            //    width: 3456,
            //    height: 2304 ) {
            //    Position = new Vector3( 0.0f, 0.0f, Constants.DistanceFromUser ),
            //    //TextureFile = "Content\\Textures\\base.jpg",
            //};

            histo = new HistologyRenderer(deviceResources: deviceResources,
                                          loader: loader,
                                          bottomLeft: new Vector3(Constants.X00, Constants.Y1, Constants.Z1),
                                          topLeft: new Vector3(Constants.X00, Constants.Y2, Constants.Z1),
                                          bottomRight: new Vector3(Constants.X01, Constants.Y1, Constants.Z0),
                                          topRight: new Vector3(Constants.X01, Constants.Y2, Constants.Z0),
                                          width: 3456,
                                          height: 2304)
            {
                Position = new Vector3(0.0f, 0.0f, Constants.DistanceFromUser),
            };
            GetHistoFromServer();
            currentImage    = ";histology;" + hj[currentImageIndex].Name + "&x=0&y=0" + "&w=" + w.ToString() + "&h=" + h.ToString() + "&level=" + level.ToString();
            Settings.Image1 = ";histology;" + hj[currentImageIndex].Name;
            Settings.Image2 = ";histology;" + hj[currentImageIndex].Name;
            UpdateImage();
        }
示例#18
0
 public async Task ReloadAssets(DeviceResources deviceResources)
 {
     RayTracingScene.ReloadLibrary(await ReadFile("ms-appx:///Coocoo3DGraphics/Raytracing.cso"));
     RayTracingScene.ReloadPipelineStates(deviceResources, c_exportNames, hitGroupDescs, c_rayTracingSceneSettings);
     RayTracingScene.ReloadAllocScratchAndInstance(deviceResources, 1024 * 1024 * 64, 1024);
     Ready = true;
 }
        public void CreateDeviceDependentResources(DeviceResources resources)
        {
            this.deviceResources = resources;

            byte[] vertexShaderBytecode = File.ReadAllBytes("Triangles.VertexShader.cso");
            this.vertexShader = this.deviceResources.D3DDevice.CreateVertexShader(vertexShaderBytecode, null);

            D3D11InputElementDesc[] basicVertexLayoutDesc = new D3D11InputElementDesc[]
            {
                new D3D11InputElementDesc
                {
                    SemanticName         = "POSITION",
                    SemanticIndex        = 0,
                    Format               = DxgiFormat.R32G32Float,
                    InputSlot            = 0,
                    AlignedByteOffset    = 0,
                    InputSlotClass       = D3D11InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                }
            };

            this.inputLayout = this.deviceResources.D3DDevice.CreateInputLayout(basicVertexLayoutDesc, vertexShaderBytecode);

            byte[] pixelShaderBytecode = File.ReadAllBytes("Triangles.PixelShader.cso");
            this.pixelShader = this.deviceResources.D3DDevice.CreatePixelShader(pixelShaderBytecode, null);

            var vertexBufferDesc = D3D11BufferDesc.From(triangleVertices, D3D11BindOptions.VertexBuffer);

            this.vertexBuffer = this.deviceResources.D3DDevice.CreateBuffer(vertexBufferDesc, triangleVertices, 0, 0);

            var indexBufferDesc = D3D11BufferDesc.From(triangleIndices, D3D11BindOptions.IndexBuffer);

            this.indexBuffer = this.deviceResources.D3DDevice.CreateBuffer(indexBufferDesc, triangleIndices, 0, 0);
        }
示例#20
0
        //private TiledTexture(DeviceResources deviceResources, int _tilesCount)
        //{
        //    this.deviceResources = deviceResources;
        //    cd16 = (_tilesCount + 15) / 16;
        //    tilesCount = _tilesCount;
        //}

        public TiledTexture(DeviceResources deviceResources, byte[] data, byte[] offsetsData)
        {
            this.deviceResources = deviceResources;
            tilesCount           = offsetsData.Length / 8;
            TilesList            = new List <Vector2Int>(tilesCount);
            if (tilesCount == 0)
            {
                return;
            }
            for (int i = 0; i < tilesCount; i++)
            {
                Vector2Int vector2 = new Vector2Int()
                {
                    x = System.BitConverter.ToInt32(offsetsData, i * 8),
                    y = System.BitConverter.ToInt32(offsetsData, i * 8 + 4)
                };
                TilesList.Add(vector2);
            }
            BlocksData        = new ComputeBuffer(deviceResources, tilesCount, 1024, data);
            BlocksOffsetsData = new ComputeBuffer(deviceResources, tilesCount, 8, offsetsData);
            tileRect          = new TileRect(TilesList);
            TilesStatus       = new TileIndexCollection(tileRect);
            for (int i = 0; i < TilesList.Count; i++)
            {
                TilesStatus.Add(TilesList[i], i);
            }
        }
示例#21
0
        static void CreateComputeDevice()
        {
            var options = new DeviceResourcesOptions();

#if DEBUG
            options.Debug = true;
#endif

            deviceResources = new RenderTargetDeviceResources(1, 1, D3D11FeatureLevel.FeatureLevel110, options);

#if TEST_DOUBLE
            // Double-precision support is an optional feature of CS 5.0
            D3D11FeatureDataDoubles supportDoubles = deviceResources.D3DDevice.CheckFeatureSupportDoubles();
            if (!supportDoubles.IsDoublePrecisionFloatShaderOperationsSupported)
            {
                Console.WriteLine("No hardware double-precision capable device found, trying to create ref device.");

                deviceResources.Release();
                deviceResources = null;

                options.ForceWarp = true;
                deviceResources   = new RenderTargetDeviceResources(1, 1, D3D11FeatureLevel.FeatureLevel110, options);
            }
#endif
        }
        public void CreateDeviceDependentResources(DeviceResources resources)
        {
            this.deviceResources = resources;

            var d3dDevice = this.deviceResources.D3DDevice;

            // Create the shaders
            byte[] vertexShaderBytecode = File.ReadAllBytes("VertexShader.cso");
            this.g_pVertexShader       = d3dDevice.CreateVertexShader(vertexShaderBytecode, null);
            this.g_pHullShaderInteger  = d3dDevice.CreateHullShader(File.ReadAllBytes("HullShaderInteger.cso"), null);
            this.g_pHullShaderFracEven = d3dDevice.CreateHullShader(File.ReadAllBytes("HullShaderFracEven.cso"), null);
            this.g_pHullShaderFracOdd  = d3dDevice.CreateHullShader(File.ReadAllBytes("HullShaderFracOdd.cso"), null);
            this.g_pDomainShader       = d3dDevice.CreateDomainShader(File.ReadAllBytes("DomainShader.cso"), null);
            this.g_pPixelShader        = d3dDevice.CreatePixelShader(File.ReadAllBytes("PixelShader.cso"), null);
            this.g_pSolidColorPS       = d3dDevice.CreatePixelShader(File.ReadAllBytes("SolidColorPS.cso"), null);

            // Create our vertex input layout - this matches the BEZIER_CONTROL_POINT structure
            D3D11InputElementDesc[] layoutDesc = new D3D11InputElementDesc[]
            {
                new D3D11InputElementDesc
                {
                    SemanticName         = "POSITION",
                    SemanticIndex        = 0,
                    Format               = DxgiFormat.R32G32B32Float,
                    InputSlot            = 0,
                    AlignedByteOffset    = 0,
                    InputSlotClass       = D3D11InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                }
            };

            this.g_pPatchLayout = this.deviceResources.D3DDevice.CreateInputLayout(layoutDesc, vertexShaderBytecode);

            // Create constant buffers
            this.g_pcbPerFrame = d3dDevice.CreateBuffer(new D3D11BufferDesc(ConstantBufferConstants.Size, D3D11BindOptions.ConstantBuffer));

            // Create solid and wireframe rasterizer state objects
            D3D11RasterizerDesc rasterDesc = D3D11RasterizerDesc.Default;

            rasterDesc.CullMode           = D3D11CullMode.None;
            rasterDesc.IsDepthClipEnabled = true;

            rasterDesc.FillMode          = D3D11FillMode.Solid;
            this.g_pRasterizerStateSolid = d3dDevice.CreateRasterizerState(rasterDesc);

            rasterDesc.FillMode = D3D11FillMode.WireFrame;
            this.g_pRasterizerStateWireframe = d3dDevice.CreateRasterizerState(rasterDesc);

            D3D11BufferDesc vbdesc = D3D11BufferDesc.From(MobiusStrip.Points, D3D11BindOptions.VertexBuffer);

            this.g_pControlPointVB = d3dDevice.CreateBuffer(vbdesc, MobiusStrip.Points, 0, 0);

            XMFloat3 vecEye = new XMFloat3(1.0f, 1.5f, -3.5f);
            XMFloat3 vecAt  = new XMFloat3(0.0f, 0.0f, 0.0f);
            XMFloat3 vecUp  = new XMFloat3(0.0f, 1.0f, 0.0f);

            this.ViewMatrix = XMMatrix.LookAtLH(vecEye, vecAt, vecUp);
            this.EyePt      = vecEye;
        }
        public void CreateDeviceDependentResources(DeviceResources resources)
        {
            this.deviceResources = resources;

            byte[] vertexShaderBytecode = File.ReadAllBytes("VertexShader.cso");
            this.vertexShader = this.deviceResources.D3DDevice.CreateVertexShader(vertexShaderBytecode, null);

            D3D11InputElementDesc[] layoutDesc = new D3D11InputElementDesc[]
            {
                new D3D11InputElementDesc
                {
                    SemanticName         = "POSITION",
                    SemanticIndex        = 0,
                    Format               = DxgiFormat.R32G32B32Float,
                    InputSlot            = 0,
                    AlignedByteOffset    = 0,
                    InputSlotClass       = D3D11InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                },
                new D3D11InputElementDesc
                {
                    SemanticName         = "NORMAL",
                    SemanticIndex        = 0,
                    Format               = DxgiFormat.R32G32B32Float,
                    InputSlot            = 0,
                    AlignedByteOffset    = 12,
                    InputSlotClass       = D3D11InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                }
            };

            this.inputLayout = this.deviceResources.D3DDevice.CreateInputLayout(layoutDesc, vertexShaderBytecode);

            byte[] pixelShaderBytecode = File.ReadAllBytes("PixelShader.cso");
            this.pixelShader = this.deviceResources.D3DDevice.CreatePixelShader(pixelShaderBytecode, null);

            pixelShaderBytecode   = File.ReadAllBytes("PixelShaderSolid.cso");
            this.pixelShaderSolid = this.deviceResources.D3DDevice.CreatePixelShader(pixelShaderBytecode, null);

            var vertexBufferDesc = D3D11BufferDesc.From(MainGameComponent.Vertices, D3D11BindOptions.VertexBuffer);

            this.vertexBuffer = this.deviceResources.D3DDevice.CreateBuffer(vertexBufferDesc, MainGameComponent.Vertices, 0, 0);

            var indexBufferDesc = D3D11BufferDesc.From(MainGameComponent.Indices, D3D11BindOptions.IndexBuffer);

            this.indexBuffer = this.deviceResources.D3DDevice.CreateBuffer(indexBufferDesc, MainGameComponent.Indices, 0, 0);

            var constantBufferDesc = new D3D11BufferDesc(ConstantBufferData.Size, D3D11BindOptions.ConstantBuffer);

            this.constantBuffer = this.deviceResources.D3DDevice.CreateBuffer(constantBufferDesc);

            this.worldMatrix = XMMatrix.Identity;

            XMVector eye = new XMVector(0.0f, 4.0f, -10.0f, 0.0f);
            XMVector at  = new XMVector(0.0f, 1.0f, 0.0f, 0.0f);
            XMVector up  = new XMVector(0.0f, 1.0f, 0.0f, 0.0f);

            this.viewMatrix = XMMatrix.LookAtLH(eye, at, up);
        }
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public SimpleDXHololensAppMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;
        }
示例#25
0
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public ClockworkHolographicClientMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;
        }
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public AssistantItemFinderMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;
        }
示例#27
0
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public Realtime_Hololens_RetexturingMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += OnDeviceLost;
            this.deviceResources.DeviceRestored += OnDeviceRestored;
        }
示例#28
0
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public _360VideoPlaybackMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;
        }
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public FaceTagMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;
        }
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>
        /// <param name="deviceResources"></param>
        public HolographicGeometryShaderMain(DeviceResources deviceResources)
        {
            this.deviceResources = deviceResources;

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost     += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;
        }
示例#31
0
        /// <summary>
        /// Updates resources associated with a holographic camera's swap chain.
        /// The app does not access the swap chain directly, but it does create
        /// resource views for the back buffer.
        /// </summary>
        public void CreateResourcesForBackBuffer(
            DeviceResources deviceResources,
            HolographicCameraRenderingParameters cameraParameters
            )
        {
            var device = deviceResources.D3DDevice;

            // Get the WinRT object representing the holographic camera's back buffer.
            IDirect3DSurface surface = cameraParameters.Direct3D11BackBuffer;

            // Get a DXGI interface for the holographic camera's back buffer.
            // Holographic cameras do not provide the DXGI swap chain, which is owned
            // by the system. The Direct3D back buffer resource is provided using WinRT
            // interop APIs.
            InteropStatics.IDirect3DDxgiInterfaceAccess surfaceDxgiInterfaceAccess = surface as InteropStatics.IDirect3DDxgiInterfaceAccess;
            IntPtr pResource = surfaceDxgiInterfaceAccess.GetInterface(InteropStatics.ID3D11Resource);
            Resource resource = SharpDX.CppObject.FromPointer<Resource>(pResource);
            Marshal.Release(pResource);

            // Get a Direct3D interface for the holographic camera's back buffer.
            Texture2D cameraBackBuffer = resource.QueryInterface<Texture2D>();

            // Determine if the back buffer has changed. If so, ensure that the render target view
            // is for the current back buffer.
            if ((null == d3dBackBuffer) || (d3dBackBuffer.NativePointer != cameraBackBuffer.NativePointer))
            {
                // This can change every frame as the system moves to the next buffer in the
                // swap chain. This mode of operation will occur when certain rendering modes
                // are activated.
                d3dBackBuffer = cameraBackBuffer;

                // Get the DXGI format for the back buffer.
                // This information can be accessed by the app using CameraResources::GetBackBufferDXGIFormat().
                Texture2DDescription backBufferDesc = BackBufferTexture2D.Description;
                dxgiFormat = backBufferDesc.Format;

                // Check for render target size changes.
                Size currentSize = holographicCamera.RenderTargetSize;
                if (d3dRenderTargetSize != currentSize)
                {
                    // Set render target size.
                    d3dRenderTargetSize = HolographicCamera.RenderTargetSize;
                }
            }

            // Create the constant buffer, if needed.
            if (null == viewProjectionConstantBuffer)
            {
                // Create a constant buffer to store view and projection matrices for the camera.
                ViewProjectionConstantBuffer viewProjectionConstantBufferData = new ViewProjectionConstantBuffer();
                viewProjectionConstantBuffer = this.ToDispose(SharpDX.Direct3D11.Buffer.Create(
                    device,
                    BindFlags.ConstantBuffer,
                    ref viewProjectionConstantBufferData));
            }
        }
示例#32
0
        /// <summary>
        /// Releases resources associated with a holographic display back buffer.
        /// </summary>
        public void ReleaseResourcesForBackBuffer(DeviceResources deviceResources)
        {
            var context = deviceResources.D3DDeviceContext;

            this.RemoveAndDispose(ref d3dBackBuffer);

            const int D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT = 8;
            RenderTargetView[] nullViews = new RenderTargetView[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];

            // Ensure system references to the back buffer are released by clearing the render
            // target from the graphics pipeline state, and then flushing the Direct3D context.
            context.OutputMerger.SetRenderTargets(null, nullViews);
            context.Flush();
        }
示例#33
0
 public void ReleaseAllDeviceResources(DeviceResources deviceResources)
 {
     ReleaseResourcesForBackBuffer(deviceResources);
     this.RemoveAndDispose(ref viewProjectionConstantBuffer);
 }
        /// <summary>
        /// Dispose unmanaged resources
        /// </summary>
        public void Dispose()
        {
            this.deviceResources.Dispose();
            this.deviceResources = null;

            this.Adapter.Dispose();
            this.Adapter = null;
        }
        /// <summary>
        /// Loads and initializes application assets when the application is loaded.
        /// </summary>        
        public BaseHololensApplication()
        {
            this.deviceResources = new DeviceResources();

            // Register to be notified if the Direct3D device is lost.
            this.deviceResources.DeviceLost += this.OnDeviceLost;
            this.deviceResources.DeviceRestored += this.OnDeviceRestored;
        }