当前位置: 首页>>代码示例>>C#>>正文


C# IResourceManager.GetStream方法代码示例

本文整理汇总了C#中IResourceManager.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# IResourceManager.GetStream方法的具体用法?C# IResourceManager.GetStream怎么用?C# IResourceManager.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IResourceManager的用法示例。


在下文中一共展示了IResourceManager.GetStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImageGenerator

            public ImageGenerator(IResourceManager resourceLoader)
	        {
                const int width = 400;
                const int height = 400;

                // Create device and swap chain.
                _device = new Device();
                var swapChainPresenter = new WpfSwapChainPresenter();
                _swapChain = _device.CreateSwapChain(width, height, swapChainPresenter);
                _outputBitmap = swapChainPresenter.Bitmap;
                _deviceContext = _device.ImmediateContext;

                // Create RenderTargetView from the backbuffer.
                var backBuffer = Texture2D.FromSwapChain(_swapChain, 0);
                _renderTargetView = _device.CreateRenderTargetView(backBuffer);

                // Create the depth buffer
                var depthBuffer = _device.CreateTexture2D(new Texture2DDescription
                {
                    ArraySize = 1,
                    MipLevels = 1,
                    Width = width,
                    Height = height,
                    BindFlags = BindFlags.DepthStencil
                });

                // Create the depth buffer view
                _depthView = _device.CreateDepthStencilView(depthBuffer);

                // Compile Vertex and Pixel shaders
                var vertexShaderByteCode = ShaderCompiler.CompileFromFile("Modules/SampleBrowser/TechDemos/Resources/TextureSampling/Texture.fx", "VS", "vs_4_0");
                var vertexShader = _device.CreateVertexShader(vertexShaderByteCode);

                var pixelShaderByteCode = ShaderCompiler.CompileFromFile("Modules/SampleBrowser/TechDemos/Resources/TextureSampling/Texture.fx", "PS", "ps_4_1");
                var pixelShader = _device.CreatePixelShader(pixelShaderByteCode);

                // Layout from VertexShader input signature
                var layout = _device.CreateInputLayout(
                    new[]
	                {
	                    new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
	                    new InputElement("TEXCOORD", 0, Format.R32G32_Float, 0, 16)
	                }, vertexShaderByteCode);

                // Instantiate Vertex buiffer from vertex data
                var vertices = _device.CreateBuffer(new BufferDescription(BindFlags.VertexBuffer), new[]
	            {
	                // 3D coordinates              UV Texture coordinates
	                -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, // Front
	                -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
	                1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f,
	                -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
	                1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f,
	                1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f,

	                -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, // BACK
	                1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
	                -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
	                -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
	                1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
	                1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,

	                -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, // Top
	                -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
	                1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
	                -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
	                1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
	                1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f,

	                -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, // Bottom
	                1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
	                -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
	                -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f,
	                1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
	                1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f,

	                -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, // Left
	                -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
	                -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
	                -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
	                -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
	                -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f,

	                1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, // Right
	                1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
	                1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
	                1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f,
	                1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
	                1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f
	            });

                // Create Constant Buffer
                _constantBuffer = _device.CreateBuffer(new BufferDescription
                {
                    SizeInBytes = Utilities.SizeOf<Matrix>(),
                    BindFlags = BindFlags.ConstantBuffer
                });

                // Load texture and create sampler
                var textureStream = resourceLoader.GetStream(
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:rasterizr,代码行数:101,代码来源:TextureSamplingViewModel.cs


注:本文中的IResourceManager.GetStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。