• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Texture2DDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Texture2DDescription的典型用法代码示例。如果您正苦于以下问题:C# Texture2DDescription类的具体用法?C# Texture2DDescription怎么用?C# Texture2DDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Texture2DDescription类属于命名空间,在下文中一共展示了Texture2DDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TextureCubeArray

		/// <summary>
		/// 
		/// </summary>
		/// <param name="device"></param>
		/// <param name="size"></param>
		/// <param name="count"></param>
		/// <param name="format"></param>
		/// <param name="mips"></param>
		public TextureCubeArray ( GraphicsDevice device, int size, int count, ColorFormat format, bool mips ) : base(device)
		{
			if (count>2048/6) {
				throw new GraphicsException("Too much elements in texture array");
			}

			this.Width		=	size;
			this.Depth		=	1;
			this.Height		=	size;
			this.MipCount	=	mips ? ShaderResource.CalculateMipLevels(Width,Height) : 1;

			var texDesc = new Texture2DDescription();

			texDesc.ArraySize		=	6 * count;
			texDesc.BindFlags		=	BindFlags.ShaderResource;
			texDesc.CpuAccessFlags	=	CpuAccessFlags.None;
			texDesc.Format			=	MakeTypeless( Converter.Convert( format ) );
			texDesc.Height			=	Height;
			texDesc.MipLevels		=	0;
			texDesc.OptionFlags		=	ResourceOptionFlags.TextureCube;
			texDesc.SampleDescription.Count	=	1;
			texDesc.SampleDescription.Quality	=	0;
			texDesc.Usage			=	ResourceUsage.Default;
			texDesc.Width			=	Width;


			texCubeArray	=	new D3D.Texture2D( device.Device, texDesc );
			SRV				=	new ShaderResourceView( device.Device, texCubeArray );
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:37,代码来源:TextureCubeArray.cs


示例2: Init

 internal void Init(string name, Texture2DDescription desc, Vector2I size, int bytes)
 {
     m_name = name;
     m_size = size;
     m_desc = desc;
     m_bytes = bytes;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyGeneratedTexture.cs


示例3: MyTextureArray

        internal MyTextureArray(TexId[] mergeList)
        {
            var srcDesc = MyTextures.GetView(mergeList[0]).Description;
            Size = MyTextures.GetSize(mergeList[0]);
            ArrayLen = mergeList.Length;

            Texture2DDescription desc = new Texture2DDescription();
            desc.ArraySize = ArrayLen;
            desc.BindFlags = BindFlags.ShaderResource;
            desc.CpuAccessFlags = CpuAccessFlags.None;
            desc.Format = srcDesc.Format;
            desc.Height = (int)Size.Y;
            desc.Width = (int)Size.X;
            desc.MipLevels = 0;
            desc.SampleDescription.Count = 1;
            desc.SampleDescription.Quality = 0;
            desc.Usage = ResourceUsage.Default;
            m_resource = new Texture2D(MyRender11.Device, desc);

            // foreach mip
            var mipmaps = (int)Math.Log(Size.X, 2) + 1;

            for (int a = 0; a < ArrayLen; a++)
            {
                for (int m = 0; m < mipmaps; m++)
                {
                    MyRender11.Context.CopySubresourceRegion(MyTextures.Textures.Data[mergeList[a].Index].Resource, Resource.CalculateSubResourceIndex(m, 0, mipmaps), null, Resource,
                        Resource.CalculateSubResourceIndex(m, a, mipmaps));
                }
            }

            ShaderView = new ShaderResourceView(MyRender11.Device, Resource);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:33,代码来源:MyResource.cs


示例4: DX11RenderMip2D

        public DX11RenderMip2D(DX11RenderContext context, int w, int h, Format format)
        {
            this.context = context;
            int levels = this.CountMipLevels(w,h);
            var texBufferDesc = new Texture2DDescription
            {
                ArraySize = 1,
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = format,
                Height = h,
                Width = w,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default,
                MipLevels = levels,
            };

            
            this.Resource = new Texture2D(context.Device, texBufferDesc);
            this.desc = this.Resource.Description;

            this.SRV = new ShaderResourceView(context.Device, this.Resource);

            this.Slices = new DX11MipSliceRenderTarget[levels];

            int sw = w;
            int sh = h;

            for (int i = 0; i < levels; i++)
            {
                this.Slices[i] = new DX11MipSliceRenderTarget(this.context, this, i, w, h);
                w /= 2; h /= 2;
            }
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:35,代码来源:DX11RenderMip2D.cs


示例5: Texture2D

        public void Texture2D()
        {
            BlittableRGBA[] pixels = new BlittableRGBA[]
            {
                new BlittableRGBA(Color.Red), 
                new BlittableRGBA(Color.Green)
            };
            int sizeInBytes = ArraySizeInBytes.Size(pixels);
            Texture2DDescription description = new Texture2DDescription(2, 1, TextureFormat.RedGreenBlueAlpha8, false);

            using (GraphicsWindow window = Device.CreateWindow(1, 1))
            using (WritePixelBuffer writePixelBuffer = Device.CreateWritePixelBuffer(PixelBufferHint.Stream, sizeInBytes))
            using (Texture2D texture = Device.CreateTexture2D(description))
            {
                writePixelBuffer.CopyFromSystemMemory(pixels);

                //
                // Create texture with pixel buffer
                //
                texture.CopyFromBuffer(writePixelBuffer, BlittableRGBA.Format, BlittableRGBA.Datatype);

                //
                // Read back pixels
                //
                using (ReadPixelBuffer readPixelBuffer = texture.CopyToBuffer(BlittableRGBA.Format, BlittableRGBA.Datatype))
                {
                    BlittableRGBA[] readPixels = readPixelBuffer.CopyToSystemMemory<BlittableRGBA>();

                    Assert.AreEqual(sizeInBytes, readPixelBuffer.SizeInBytes);
                    Assert.AreEqual(pixels[0], readPixels[0]);
                    Assert.AreEqual(pixels[1], readPixels[1]);
                    Assert.AreEqual(description, texture.Description);
                }
            }
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:35,代码来源:Texture2DTests.cs


示例6: OnDeviceInitInternal

        public void OnDeviceInitInternal()
        {
            {
                Texture2DDescription desc = new Texture2DDescription();
                desc.Width = Size.X;
                desc.Height = Size.Y;
                desc.Format = m_resourceFormat;
                desc.ArraySize = 1;
                desc.MipLevels = m_mipmapLevels;
                desc.BindFlags = m_bindFlags;
                desc.Usage = m_resourceUsage;
                desc.CpuAccessFlags = m_cpuAccessFlags;
                desc.SampleDescription.Count = m_samplesCount;
                desc.SampleDescription.Quality = m_samplesQuality;
                desc.OptionFlags = m_roFlags;
                m_resource = new Texture2D(MyRender11.Device, desc);
            }
            {
                ShaderResourceViewDescription desc = new ShaderResourceViewDescription();
                desc.Format = m_srvFormat;
                desc.Dimension = ShaderResourceViewDimension.Texture2D;
                desc.Texture2D.MipLevels = m_mipmapLevels;
                desc.Texture2D.MostDetailedMip = 0;
                m_srv = new ShaderResourceView(MyRender11.Device, m_resource, desc);
            }

            m_resource.DebugName = m_name;
            m_srv.DebugName = m_name;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:29,代码来源:MyRwTextures.cs


示例7: SharedTexture

        /// <summary>
        /// Creates a default D3D11 Texture with forced Shared-Flag
        /// </summary>
        /// <param name="device"></param>
        /// <param name="description"></param>
        /// <param name="D3D10Dev"> </param>
        /// <param name="D2DFactory"> </param>
        public SharedTexture(D2DInteropHandler handler, Texture2DDescription description)
        {
            As11Tex = new Texture2D(handler.D3DDevice11, new Texture2DDescription()
                {
                    ArraySize = description.ArraySize,
                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                    CpuAccessFlags = description.CpuAccessFlags,
                    Format = description.Format,
                    Height = description.Height,
                    MipLevels = description.MipLevels,
                    OptionFlags = ResourceOptionFlags.KeyedMutex,
                    SampleDescription = description.SampleDescription,
                    Usage = description.Usage,
                    Width = description.Width
                });

            Mutex11 = new KeyedMutex(As11Tex);
            AsResource = new SlimDX.DXGI.Resource(As11Tex);

            As10Tex = handler.D3DDevice10.OpenSharedResource<SlimDX.Direct3D10.Texture2D>(AsResource.SharedHandle);
            Mutex10 = new KeyedMutex(As10Tex);
            AsSurface = As10Tex.AsSurface();
            As2DTarget = SlimDX.Direct2D.RenderTarget.FromDXGI(handler.D2DFactory, AsSurface, new RenderTargetProperties()
                                                                                                            {
                                                                                                                MinimumFeatureLevel = FeatureLevel.Direct3D10,
                                                                                                                Usage = RenderTargetUsage.None,
                                                                                                                Type = RenderTargetType.Hardware,
                                                                                                                PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)
                                                                                                            });
        }
开发者ID:hexd0t,项目名称:Garm_Net,代码行数:37,代码来源:SharedTexture.cs


示例8: RenderTexture

        public RenderTexture(Device device, Vector2I screenSize)
        {
            var textureDesc = new Texture2DDescription()
            {
                Width = screenSize.X,
                Height = screenSize.Y,
                MipLevels = 1,
                ArraySize = 1,
                Format = Format.R32G32B32A32_Float,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default,
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.None
            };

            _renderTargetTexture = new Texture2D(device, textureDesc);

            _renderTargetView = new RenderTargetView(device, _renderTargetTexture,
                new RenderTargetViewDescription
                {
                    Format = textureDesc.Format,
                    Dimension = RenderTargetViewDimension.Texture2D,
                    Texture2D = {MipSlice = 0},
                });

            // Create the render target view.
            ShaderResourceView = new ShaderResourceView(device, _renderTargetTexture,
                new ShaderResourceViewDescription
                {
                    Format = textureDesc.Format,
                    Dimension = ShaderResourceViewDimension.Texture2D,
                    Texture2D = { MipLevels = 1, MostDetailedMip = 0 },
                });
        }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:35,代码来源:RenderTexture.cs


示例9: RenderStereoTextureCommand

        public RenderStereoTextureCommand(int width, int height, StereoRenderer stereoRenderer)
            : base(width, height, stereoRenderer.Scene)
        {
            this.CommandAttributes |= CommandAttributes.StereoRendering;
            this.sceneManager = stereoRenderer.Scene;
            this.stereoRenderer = stereoRenderer;
            this.stereoCamera = (StereoCamera)stereoRenderer.Camera;
            this.stereoCamera.StereoParametersChanged += RequestUpdate;

            Texture2DDescription StereoTextureDesc = new Texture2DDescription
            {
                ArraySize = 1,
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = Format.R8G8B8A8_UNorm,
                Width = 2 * width,
                Height = height,
                MipLevels = 1,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default
            };

            Texture = new Texture2D(Game.Context.Device, StereoTextureDesc);
        }
开发者ID:yong-ja,项目名称:starodyssey,代码行数:25,代码来源:RenderStereoTextureCommand.cs


示例10: BuildVertexBuffer

        void BuildVertexBuffer(Texture2DDescription textureDesc)
        {
            var game = Game.Instance;
            var clientSize = game.RenderViewSize;
            var texWidth = textureDesc.Width;
            var texHeight = textureDesc.Height;

            var clientRatio = clientSize.Width / (float)clientSize.Height;
            var textureRatio = texWidth / (float)texHeight;

            float w = 1f;
            float h = 1f;

            if (clientRatio > textureRatio)
            {
                if (texHeight > clientSize.Height)
                {
                    w = h * textureRatio / clientRatio;
                }
                else
                {
                    h = texHeight / (float)clientSize.Height;
                    w = texWidth / (float)clientSize.Width;
                }
            }
            else
            {
                if (texWidth > clientSize.Width)
                {
                    h = w * clientRatio / textureRatio;
                }
                else
                {
                    h = texHeight / (float)clientSize.Height;
                    w = texWidth / (float)clientSize.Width;
                }
            }

            int start = 0;
            DefineVertex(ref start, w, -h, 1, 1);
            DefineVertex(ref start, -w, -h, 0, 1);
            DefineVertex(ref start, w, h, 1, 0);

            DefineVertex(ref start, w, h, 1, 0);
            DefineVertex(ref start, -w, -h, 0, 1);
            DefineVertex(ref start, -w, h, 0, 0);

            var desc = new BufferDescription();
            desc.BindFlags = BindFlags.VertexBuffer;
            desc.Usage = ResourceUsage.Default;
            desc.CpuAccessFlags = CpuAccessFlags.None;
            desc.SizeInBytes = Utilities.SizeOf<float>() * vertices.Length;
            desc.StructureByteStride = 0;
            desc.OptionFlags = ResourceOptionFlags.None;

            vertexBuffer = Buffer.Create(game.Device, vertices, desc);
            vertexBuffer.DebugName = "Preview(Texture2D)";

            vertexBufferBinding = new VertexBufferBinding(vertexBuffer, Utilities.SizeOf<float>() * VERTEX_FLOAT_COUNT, 0);
        }
开发者ID:woncomp,项目名称:LiliumLab,代码行数:60,代码来源:TexturePreview.cs


示例11: CheckTexturesConsistency

 public static bool CheckTexturesConsistency(Texture2DDescription desc1, Texture2DDescription desc2)
 {
     return desc1.Format == desc2.Format
         && desc1.MipLevels == desc2.MipLevels
         && desc1.Width == desc2.Width
         && desc1.Height == desc2.Height;
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:7,代码来源:MyResourceUtils.cs


示例12: RenderTexture

        /// <summary>
        /// Constructor
        /// Creates the texture we will render to based on the supplied width and height
        /// </summary>
        /// <param name="device">The device we will create the texture with</param>
        /// <param name="texWidth"></param>
        /// <param name="texHeight"></param>
        public RenderTexture(Device device, int texWidth, int texHeight)
        {
            Texture2DDescription textureDescription = new Texture2DDescription()
                {
                    Width = texWidth,
                    Height = texHeight,
                    MipLevels = 1,
                    ArraySize = 1,
                    Format = SlimDX.DXGI.Format.R32G32B32A32_Float,
                    SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                    CpuAccessFlags = CpuAccessFlags.None,
                    OptionFlags = ResourceOptionFlags.None,
                    Usage = ResourceUsage.Default,
                };
            Texture = new Texture2D(device, textureDescription);
            RenderTargetViewDescription renderTargetViewDescription = new RenderTargetViewDescription()
            {
                Format = textureDescription.Format,
                Dimension = RenderTargetViewDimension.Texture2D,
                MipSlice = 0,
            };

            renderTargetView = new RenderTargetView(device, Texture, renderTargetViewDescription);

            ShaderResourceViewDescription shaderResourceViewDescription = new ShaderResourceViewDescription()
            {
                Format = textureDescription.Format,
                Dimension = ShaderResourceViewDimension.Texture2D,
                MostDetailedMip = 0,
                MipLevels = 1
            };

            shaderResourceView = new ShaderResourceView(device, Texture, shaderResourceViewDescription);
        }
开发者ID:nickudell,项目名称:PigmentFramework,代码行数:42,代码来源:RenderTexture.cs


示例13: EnumerateColorAttachments

        public void EnumerateColorAttachments()
        {
            Texture2DDescription description = new Texture2DDescription(1, 1, TextureFormat.RedGreenBlue8, false);

            using (GraphicsWindow window = Device.CreateWindow(1, 1))
            using (Framebuffer framebuffer = window.Context.CreateFramebuffer())
            using (Texture2D color0 = Device.CreateTexture2D(description))
            using (Texture2D color1 = Device.CreateTexture2D(description))
            using (Texture2D color2 = Device.CreateTexture2D(description))
            {
                framebuffer.ColorAttachments[0] = color0;
                framebuffer.ColorAttachments[1] = color1;
                framebuffer.ColorAttachments[2] = color2;
                Assert.AreEqual(3, framebuffer.ColorAttachments.Count);

                framebuffer.ColorAttachments[1] = null;
                Assert.AreEqual(2, framebuffer.ColorAttachments.Count);

                framebuffer.ColorAttachments[1] = color1;
                Assert.AreEqual(3, framebuffer.ColorAttachments.Count);

                int count = 0;
                foreach (Texture2D texture in framebuffer.ColorAttachments)
                {
                    Assert.AreEqual(description, texture.Description);
                    ++count;
                }
                Assert.AreEqual(framebuffer.ColorAttachments.Count, count);
            }
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:30,代码来源:FramebufferTests.cs


示例14: TextureFromBitmap

        public static Texture2D TextureFromBitmap(Bitmap image)
        {
            BitmapData data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
                                             ImageLockMode.ReadWrite, image.PixelFormat);
            int bytes = data.Stride*image.Height;
            DataStream stream = new DataStream(bytes, true, true);
            stream.WriteRange(data.Scan0, bytes);
            stream.Position = 0;
            DataRectangle dRect = new DataRectangle(data.Stride, stream);

            Texture2DDescription texDesc = new Texture2DDescription
                                               {
                                                   ArraySize = 1,
                                                   MipLevels = 1,
                                                   SampleDescription = new SampleDescription(1, 0),
                                                   Format = Format.B8G8R8A8_UNorm,
                                                   CpuAccessFlags = CpuAccessFlags.None,
                                                   BindFlags = BindFlags.ShaderResource,
                                                   Usage = ResourceUsage.Immutable,
                                                   Height = image.Height,
                                                   Width = image.Width
                                               };

            image.UnlockBits(data);
            image.Dispose();
            Texture2D texture = new Texture2D(Game.Context.Device, texDesc, dRect);
            stream.Dispose();
            return texture;
        }
开发者ID:yong-ja,项目名称:starodyssey,代码行数:29,代码来源:ImageHelper.cs


示例15: OnResize

        void OnResize(object sender, EventArgs args)
        {
            var texDesc = new Texture2DDescription
            {
                ArraySize = 1, BindFlags = BindFlags.None,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm,
                Height = ClientSize.Height,
                Width = ClientSize.Width,
                Usage = ResourceUsage.Default,
                SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
                OptionFlags = ResourceOptionFlags.None,
                MipLevels = 1
            };

            if (mResolveTexture != null)
                mResolveTexture.Dispose();

            mResolveTexture = new Texture2D(WorldFrame.Instance.GraphicsContext.Device, texDesc);

            if (mMapTexture != null) mMapTexture.Dispose();

            texDesc.CpuAccessFlags = CpuAccessFlags.Read;
            texDesc.Usage = ResourceUsage.Staging;
            mMapTexture = new Texture2D(WorldFrame.Instance.GraphicsContext.Device, texDesc);

            mTarget.Resize(ClientSize.Width, ClientSize.Height, true);
            mCamera.SetAspect((float) ClientSize.Width / ClientSize.Height);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:29,代码来源:ModelRenderControl.cs


示例16: DX11CubeDepthStencil

        public DX11CubeDepthStencil(DX11RenderContext context, int size, SampleDescription sd, Format format)
        {
            this.context = context;

            var texBufferDesc = new Texture2DDescription
            {
                ArraySize = 6,
                BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = DepthFormatsHelper.GetGenericTextureFormat(format),
                Height = size,
                Width = size,
                OptionFlags = ResourceOptionFlags.TextureCube,
                SampleDescription = sd,
                Usage = ResourceUsage.Default,
                MipLevels = 1
            };

            this.Resource = new Texture2D(context.Device, texBufferDesc);

            this.desc = texBufferDesc;

            //Create faces SRV/RTV
            this.SliceDSV = new DX11SliceDepthStencil[6];

            ShaderResourceViewDescription svd = new ShaderResourceViewDescription()
            {
                Dimension = ShaderResourceViewDimension.TextureCube,
                Format = DepthFormatsHelper.GetSRVFormat(format),
                MipLevels = 1,
                MostDetailedMip = 0,
                First2DArrayFace = 0
            };

            DepthStencilViewDescription dsvd = new DepthStencilViewDescription()
            {
                ArraySize= 6,
                Dimension = DepthStencilViewDimension.Texture2DArray,
                FirstArraySlice = 0,
                Format = DepthFormatsHelper.GetDepthFormat(format),
                MipSlice = 0
            };

            this.DSV = new DepthStencilView(context.Device, this.Resource, dsvd);

            if (context.IsFeatureLevel11)
            {
                dsvd.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                if (format == Format.D24_UNorm_S8_UInt) { dsvd.Flags |= DepthStencilViewFlags.ReadOnlyStencil; }

                this.ReadOnlyDSV = new DepthStencilView(context.Device, this.Resource, dsvd);
            }

            this.SRV = new ShaderResourceView(context.Device, this.Resource, svd);

            for (int i = 0; i < 6; i++)
            {
                this.SliceDSV[i] = new DX11SliceDepthStencil(context, this, i, DepthFormatsHelper.GetDepthFormat(format));
            }
        }
开发者ID:arturoc,项目名称:FeralTic,代码行数:60,代码来源:DX11CubeDepthStencil.cs


示例17: GenerateTextureFromField

        /// <summary>
        /// Takes a scala field as input anf generates a 2D texture.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="field"></param>
        /// <returns></returns>
        public static Texture2D GenerateTextureFromField(Device device, Field field, Texture2DDescription? description = null)
        {
            System.Diagnostics.Debug.Assert(field.Size.Length == 2);

            Texture2DDescription desc;

            // Either use the given description, or create a render target/shader resource bindable one.
            if (description == null)
                desc = new Texture2DDescription
                {
                    ArraySize = 1,
                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                    CpuAccessFlags = CpuAccessFlags.None,
                    Format = Format.R32_Float,
                    Width = field.Size[0],
                    Height = field.Size[1],
                    MipLevels = 1,
                    OptionFlags = ResourceOptionFlags.None,
                    SampleDescription = new SampleDescription(1, 0),
                    Usage = ResourceUsage.Default
                };
            else
                desc = (Texture2DDescription)description;

            // Put field data into stream/rectangle object
            DataRectangle texData = new DataRectangle(field.Size[0] * sizeof(float), field.GetDataStream());

            // Create texture.
            Texture2D tex = new Texture2D(device, desc, texData);

            return tex;
        }
开发者ID:AnkeAnke,项目名称:FlowSharp,代码行数:38,代码来源:ColorMapping.cs


示例18: DX11RenderTextureArray

        public DX11RenderTextureArray(DX11RenderContext context, int w, int h, int elemcnt, Format format)
        {
            this.context = context;

            var texBufferDesc = new Texture2DDescription
            {
                ArraySize = elemcnt,
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = format,
                Height = h,
                Width = w,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1,0),
                Usage = ResourceUsage.Default,
            };

            this.Resource = new Texture2D(context.Device, texBufferDesc);

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                ArraySize = elemcnt,
                FirstArraySlice = 0,
                Dimension = RenderTargetViewDimension.Texture2DArray,
                Format = format
            };

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription()
            {
                ArraySize = elemcnt,
                FirstArraySlice = 0,
                Dimension = ShaderResourceViewDimension.Texture2DArray,
                Format = format,
                MipLevels = 1,
                MostDetailedMip = 0
            };

            this.SRV = new ShaderResourceView(context.Device, this.Resource, srvd);
            this.RTV = new RenderTargetView(context.Device, this.Resource, rtd);

            this.SRVArray = new ShaderResourceView[elemcnt];

            ShaderResourceViewDescription srvad = new ShaderResourceViewDescription()
            {
                ArraySize = 1,
                Dimension = ShaderResourceViewDimension.Texture2DArray,
                Format = format,
                MipLevels = 1,
                MostDetailedMip = 0
            };

            for (int i = 0; i < elemcnt; i++)
            {
                srvad.FirstArraySlice = i;
                this.SRVArray[i] = new ShaderResourceView(context.Device, this.Resource, srvad);
            }

            this.desc = texBufferDesc;
        }
开发者ID:kopffarben,项目名称:FeralTic,代码行数:59,代码来源:DX11RenderTextureArray.cs


示例19: InitD3D

        void InitD3D()
        {
            D3DDevice = new Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0);

            Texture2DDescription colordesc = new Texture2DDescription();
            colordesc.BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource;
            colordesc.Format = Format.B8G8R8A8_UNorm;
            colordesc.Width = WindowWidth;
            colordesc.Height = WindowHeight;
            colordesc.MipLevels = 1;
            colordesc.SampleDescription = new SampleDescription(1, 0);
            colordesc.Usage = ResourceUsage.Default;
            colordesc.OptionFlags = ResourceOptionFlags.Shared;
            colordesc.CpuAccessFlags = CpuAccessFlags.None;
            colordesc.ArraySize = 1;

            Texture2DDescription depthdesc = new Texture2DDescription();
            depthdesc.BindFlags = BindFlags.DepthStencil;
            depthdesc.Format = Format.D32_Float_S8X24_UInt;
            depthdesc.Width = WindowWidth;
            depthdesc.Height = WindowHeight;
            depthdesc.MipLevels = 1;
            depthdesc.SampleDescription = new SampleDescription(1, 0);
            depthdesc.Usage = ResourceUsage.Default;
            depthdesc.OptionFlags = ResourceOptionFlags.None;
            depthdesc.CpuAccessFlags = CpuAccessFlags.None;
            depthdesc.ArraySize = 1;

            SharedTexture = new Texture2D(D3DDevice, colordesc);
            DepthTexture = new Texture2D(D3DDevice, depthdesc);
            SampleRenderView = new RenderTargetView(D3DDevice, SharedTexture);
            SampleDepthView = new DepthStencilView(D3DDevice, DepthTexture);
            SampleEffect = Effect.FromFile(D3DDevice, "MiniTri.fx", "fx_4_0");
            EffectTechnique technique = SampleEffect.GetTechniqueByIndex(0); ;
            EffectPass pass = technique.GetPassByIndex(0);
            SampleLayout = new InputLayout(D3DDevice, pass.Description.Signature, new[] {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) 
            });

            SampleStream = new DataStream(3 * 32, true, true);
            SampleStream.WriteRange(new[] {
                new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f),
                new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f),
                new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)
            });
            SampleStream.Position = 0;

            SampleVertices = new Buffer(D3DDevice, SampleStream, new BufferDescription()
            {
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.None,
                SizeInBytes = 3 * 32,
                Usage = ResourceUsage.Default
            });

            D3DDevice.Flush();
        }
开发者ID:zhandb,项目名称:slimdx,代码行数:59,代码来源:Scene.cs


示例20: DepthStencilBuffer

 internal DepthStencilBuffer(GraphicsDevice device, Texture2DDescription description2D, DepthFormat depthFormat)
     : base(device, description2D)
 {
     DepthFormat = depthFormat;
     DefaultViewFormat = ComputeViewFormat(DepthFormat, out HasStencil);
     Initialize(Resource);
     HasReadOnlyView = InitializeViewsDelayed(out ReadOnlyView);
 }
开发者ID:GrafSeismo,项目名称:SharpDX,代码行数:8,代码来源:DepthStencilBuffer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TextureCube类代码示例发布时间:2022-05-24
下一篇:
C# Texture2D类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap