コード例 #1
0
        public async void CreateDeviceDependentResourcesAsync()
        {
            var device = Resources.D3DDevice;
            var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;

            VertexShader = ToDispose(await DirectXHelper.LoadShader <VertexShader>(device, folder, @"Content\Shaders\Texture Debug\VertexShader.cso"));

            InputElement[] vertexDescription =
            {
                new InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float,  0, 0, InputClassification.PerVertexData, 0),
                new InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float,    12, 0, InputClassification.PerVertexData, 0)
            };

            var vertexShaderBytecode = await DirectXHelper.ReadDataAsync(await folder.GetFileAsync(@"Content\Shaders\Texture Debug\VertexShader.cso"));

            InputLayout = ToDispose(new InputLayout(device, vertexShaderBytecode, vertexDescription));

            PixelShader = ToDispose(await DirectXHelper.LoadShader <PixelShader>(device, folder, @"Content\Shaders\Texture Debug\PixelShader.cso"));

            VertexPositionUV[] vertices =
            {
                new VertexPositionUV(new Vector3(0.0f, 0.0f, 0.0f), new Vector2(0.0f, 0.0f)),
                new VertexPositionUV(new Vector3(1.0f, 0.0f, 0.0f), new Vector2(1.0f, 0.0f)),
                new VertexPositionUV(new Vector3(1.0f, 1.0f, 0.0f), new Vector2(1.0f, 1.0f)),
                new VertexPositionUV(new Vector3(0.0f, 1.0f, 0.0f), new Vector2(0.0f, 1.0f))
            };
            VertexBuffer = ToDispose(SharpDX.Direct3D11.Buffer.Create(device, BindFlags.VertexBuffer, vertices));

            ushort[] indices = { 0, 1, 2, 2, 3, 0 };
            IndexBuffer = ToDispose(SharpDX.Direct3D11.Buffer.Create(device, BindFlags.IndexBuffer, indices));

            ScreenPositionBuffer = ToDispose(SharpDX.Direct3D11.Buffer.Create(device, BindFlags.ConstantBuffer, ref ScreenPositionData));
        }
コード例 #2
0
        public async Task CreateDeviceDependantResources()
        {
            var device = Resources.D3DDevice;
            var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;

            RenderVertexShader   = ToDispose(await DirectXHelper.LoadShader <VertexShader>(device, folder, @"Content\Shaders\Mesh Rendering\VertexShader.cso"));
            RenderGeometryShader = ToDispose(await DirectXHelper.LoadShader <GeometryShader>(device, folder, @"Content\Shaders\Mesh Rendering\GeometryShader.cso"));
            RenderPixelShader    = ToDispose(await DirectXHelper.LoadShader <PixelShader>(device, folder, @"Content\Shaders\Mesh Rendering\PixelShader.cso"));

            LayoutConstantBuffer = ToDispose(SharpDX.Direct3D11.Buffer.Create(device, BindFlags.ConstantBuffer, ref LayoutData));
        }
コード例 #3
0
        private async void CreateDeviceDependantResources()
        {
            var device = Resources.D3DDevice;
            var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;

            UpdateVertexShader   = ToDispose(await DirectXHelper.LoadShader <VertexShader>(device, folder, @"Content\Shaders\Mesh Updating\VertexShader.cso"));
            UpdateGeometryShader = ToDispose(await DirectXHelper.LoadShader <GeometryShader>(device, folder, @"Content\Shaders\Mesh Updating\GeometryShader.cso"));
            UpdatePixelShader    = ToDispose(await DirectXHelper.LoadShader <PixelShader>(device, folder, @"Content\Shaders\Mesh Updating\PixelShader.cso"));

            PrepassVertexShader = ToDispose(await DirectXHelper.LoadShader <VertexShader>(device, folder, @"Content\Shaders\Mesh Projection\DepthPrepassVertexShader.cso"));
            PrepassPixelShader  = ToDispose(await DirectXHelper.LoadShader <PixelShader>(device, folder, @"Content\Shaders\Mesh Projection\DepthPrepassPixelShader.cso"));

            ProjectionVertexShader   = ToDispose(await DirectXHelper.LoadShader <VertexShader>(device, folder, @"Content\Shaders\Mesh Projection\VertexShader.cso"));
            ProjectionGeometryShader = ToDispose(await DirectXHelper.LoadShader <GeometryShader>(device, folder, @"Content\Shaders\Mesh Projection\GeometryShader.cso"));
            ProjectionPixelShader    = ToDispose(await DirectXHelper.LoadShader <PixelShader>(device, folder, @"Content\Shaders\Mesh Projection\PixelShader.cso"));

            UpdateLayoutConstantBuffer = ToDispose(SharpDX.Direct3D11.Buffer.Create(device, BindFlags.ConstantBuffer, ref UpdateLayoutData));
            LayoutConstantBuffer       = ToDispose(SharpDX.Direct3D11.Buffer.Create(device, BindFlags.ConstantBuffer, ref LayoutData));
            CameraConstantBuffer       = ToDispose(SharpDX.Direct3D11.Buffer.Create(device, BindFlags.ConstantBuffer, ref CameraData));

            CreatePrepassDepthResources();

            Active = true;
        }