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


C# DataStream.Seek方法代码示例

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


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

示例1: D3D10Renderer

        public D3D10Renderer(Device1 device3D)
        {
            Contract.Requires(device3D != null);

            _Device3D = device3D;

            string shader = GetShaderText(Properties.Resources.RenderingEffects);

            using(var byteCode = ShaderBytecode.Compile(
                    shader, "fx_4_0", ShaderFlags.None, EffectFlags.None))
            {
                _Effect = new Effect(_Device3D, byteCode);
            }

            _EffectTechnique = _Effect.GetTechniqueByName("WithTexture");

            Contract.Assert(_EffectTechnique != null);

            _EffectPass = _EffectTechnique.GetPassByIndex(0);

            Contract.Assert(_EffectPass != null);

            _InputLayout = new InputLayout(
                _Device3D, _EffectPass.Description.Signature, _InputLayoutData);

            const int byteSize = _Stride * _VertexCount;

            using(DataStream stream = new DataStream(byteSize, true, true))
            {
                for(int i = 0; i < _QuadPrimitiveData.Length; i += 2)
                {
                    float fx = (2.0f * _QuadPrimitiveData[i + 0].X) - 1.0f;
                    float fy = (2.0f * _QuadPrimitiveData[i + 0].Y) - 1.0f;

                    stream.Write(new Vector3(fx, -fy, 0.5f));
                    stream.Write(_QuadPrimitiveData[i + 1]);
                }

                stream.Seek(0, SeekOrigin.Begin);

                BufferDescription description = new BufferDescription
                {
                    BindFlags = BindFlags.VertexBuffer,
                    CpuAccessFlags = CpuAccessFlags.None,
                    OptionFlags = ResourceOptionFlags.None,
                    Usage = ResourceUsage.Immutable,
                    SizeInBytes = byteSize
                };

                description.SizeInBytes = byteSize;

                _VertexBuffer = new Buffer(_Device3D, stream, description);

                _VertexBufferBinding = new VertexBufferBinding(
                    _VertexBuffer, _Stride, _Offset);
            }
        }
开发者ID:fealty,项目名称:Frost,代码行数:57,代码来源:D3D10Renderer.cs

示例2: LoadTKTX

        /// <summary>
        /// Saves the specified pixel buffers in TKTX format.
        /// </summary>
        internal static Image LoadTKTX(IntPtr dataPointer, int dataSize, bool makeACopy, GCHandle? handle)
        {
            // Make a copy?
            if (makeACopy)
            {
                var temp = Utilities.AllocateMemory(dataSize);
                Utilities.CopyMemory(temp, dataPointer, dataSize);
                dataPointer = temp;
            }

            // Use DataStream to load from memory pointer
            var imageStream = new DataStream(dataPointer, dataSize, true, true);

            var beginPosition = imageStream.Position;

            var serializer = new BinarySerializer(imageStream, SerializerMode.Read);
            var description = default(ImageDescription);

            // Load MagicCode TKTX
            try
            {
                serializer.BeginChunk(MagicCodeTKTX);
            } catch (InvalidChunkException ex)
            {
                // If magic code not found, return null
                if (ex.ExpectedChunkId == MagicCodeTKTX)
                    return null;
                throw;
            }

            // Read description
            serializer.Serialize(ref description);

            // Read size of pixel buffer
            int size = 0;
            serializer.Serialize(ref size);

            // Pad to align pixel buffer on 16 bytes (fixed offset at 48 bytes from the beginning of the file).
            var padBuffer = new byte[OffsetBufferTKTX - (int)(imageStream.Position - beginPosition)];
            if (padBuffer.Length > 0)
            {
                if (imageStream.Read(padBuffer, 0, padBuffer.Length) != padBuffer.Length)
                    throw new EndOfStreamException();
            }

            // Check that current offset is exactly our fixed offset.
            int pixelBufferOffsets = (int)serializer.Stream.Position;
            if (pixelBufferOffsets != OffsetBufferTKTX)
                throw new InvalidOperationException(string.Format("Unexpected offset [{0}] for pixel buffers. Must be {1}", pixelBufferOffsets, OffsetBufferTKTX));

            // Seek to the end of the stream to the number of pixel buffers
            imageStream.Seek(size, SeekOrigin.Current);

            // Close the chunk to verify that we did read the whole chunk
            serializer.EndChunk();

            return new Image(description, dataPointer, pixelBufferOffsets, handle, makeACopy);
        }
开发者ID:rbwhitaker,项目名称:SharpDX,代码行数:61,代码来源:Image.cs

示例3: Deserialize

        void Deserialize(byte[] data)
        {
            using ( DataStream ds = new DataStream( data ) )
            {
                while ( ds.SizeRemaining() > 0 )
                {
                    uint magic = ds.ReadUInt32();
                    ds.Seek( -4, SeekOrigin.Current );

                    switch ( magic )
                    {
                        case Steam3Manifest.MAGIC:
                            Steam3Manifest binaryManifest = new Steam3Manifest( ds );
                            ParseBinaryManifest( binaryManifest );
                            break;

                            // todo: handle protobuf manifest?

                        default:
                            throw new NotImplementedException( string.Format( "Unrecognized magic value {0:X} in depot manifest.", magic ) );
                    }

                    uint marker = ds.ReadUInt32();
                    if ( marker != magic )
                        throw new InvalidDataException( "Unable to find end of message marker for depot manifest" );
                }
            }
        }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:28,代码来源:DepotManifest.cs

示例4: CreateBuffer

        /// <summary>
        /// Create buffer base on data stream and specific struct
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        public static Buffer CreateBuffer(int numElements, int sizeOfElementInByte, AccessViewType type, DataStream data = null)
        {
            // set the buffer desc
            BufferDescription BuffDescription = new BufferDescription
            {
                BindFlags = BindFlags.None,
                StructureByteStride = sizeOfElementInByte,
                SizeInBytes = numElements * sizeOfElementInByte,
                OptionFlags = ResourceOptionFlags.BufferStructured,
            };

            if (type.HasFlag(AccessViewType.SRV))
                BuffDescription.BindFlags |= BindFlags.ShaderResource;

            if (type.HasFlag(AccessViewType.UAV))
                BuffDescription.BindFlags |= BindFlags.UnorderedAccess;

            if (type.HasFlag(AccessViewType.UAV))
                BuffDescription.Usage = ResourceUsage.Default;

            // create the buffer
            Buffer Output;
            if (data == null)
            {
                Output = new Buffer(Engine.g_device, BuffDescription);
            }
            else
            {
                // reset the seek point
                data.Seek(0, System.IO.SeekOrigin.Begin);

                Output = new Buffer(Engine.g_device, data, BuffDescription);
            }

            return Output;
        }
开发者ID:fxbit,项目名称:FxGraphicsEngine,代码行数:41,代码来源:ComputeShader.cs

示例5: Steam2Manifest

        const uint ENTRY_SIZE = 28; // the size of a single node


        internal Steam2Manifest( byte[] manifestBlob )
        {
            this.Nodes = new List<Node>();

            using ( DataStream ds = new DataStream( manifestBlob ) )
            {
                uint headerVersion = ds.ReadUInt32();

                this.DepotID = ds.ReadUInt32();
                this.DepotVersion = ds.ReadUInt32();

                this.NodeCount = ds.ReadUInt32();
                this.FileCount = ds.ReadUInt32();

                this.BlockSize = ds.ReadUInt32();

                // checksum is the last field in the header
                ds.Seek( HEADER_SIZE - 4, SeekOrigin.Begin );

                this.DepotChecksum = ds.ReadUInt32();

                // the start of the names section is after the header and every node
                uint namesStart = HEADER_SIZE + ( this.NodeCount * ENTRY_SIZE );

                for ( int x = 0 ; x < this.NodeCount ; ++x )
                {
                    ds.Seek( HEADER_SIZE + ( x * ENTRY_SIZE ), SeekOrigin.Begin );

                    // the first value within a node is the offset from the start of the names section
                    uint nameOffset = namesStart + ds.ReadUInt32();

                    Node entry = new Node
                    {
                        SizeOrCount = ds.ReadUInt32(),
                        FileID = ds.ReadInt32(),
                        Attributes = ( Node.Attribs )ds.ReadUInt32(),
                        ParentIndex = ds.ReadInt32(),

                        Parent = this,
                    };

                    ds.Seek( nameOffset, SeekOrigin.Begin );

                    entry.Name = ds.ReadNullTermString( Encoding.ASCII );

                    this.Nodes.Add( entry );
                }
            }

            // now build full names
            for ( int x = 0 ; x < this.NodeCount ; ++x )
            {
                Node entry = this.Nodes[ x ];
                string fullName = entry.Name;

                while ( entry.ParentIndex != -1 )
                {
                    entry = this.Nodes[ entry.ParentIndex ];
                    fullName = Path.Combine( entry.Name, fullName );
                }

                entry = this.Nodes[ x ];
                entry.FullName = fullName;
            }
        }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:68,代码来源:Manifest.cs

示例6: GetScreenData

        private unsafe static byte[] GetScreenData(Vector2I resolution, byte[] screenData = null)
        {
            const uint headerPadding = 256; // Need to allocate some space for the bitmap headers
            const uint bytesPerPixel = 4;
            uint imageSizeInBytes = (uint)(resolution.Size() * bytesPerPixel);
            uint dataSizeInBytes = imageSizeInBytes + headerPadding;

            byte[] returnData = null;
            if(screenData == null)
                screenData = new byte[imageSizeInBytes];
            else if(screenData.Length != imageSizeInBytes)
            {
                Debug.Fail("Preallocated buffer for GetScreenData incorrect size: " + imageSizeInBytes.ToString() + " expected, " + screenData.Length + " received");
                return returnData;
            }

            MyBindableResource imageSource = Backbuffer;
            MyBindableResource imageSourceResourceView = null;

            if (imageSource != null && (resolution.X != imageSource.GetSize().X || resolution.Y != imageSource.GetSize().Y))
            {
                MyViewKey viewKey = new MyViewKey { View = MyViewEnum.SrvView, Fmt = MyRender11Constants.DX11_BACKBUFFER_FORMAT };
                if(m_backbufferCopyResource == null)
                {
                    m_backbufferCopyResource = new MyCustomTexture(m_resolution.X, m_resolution.Y, BindFlags.ShaderResource, MyRender11Constants.DX11_BACKBUFFER_FORMAT);
                    m_backbufferCopyResource.AddView(viewKey);
                }
                MyRenderContext.Immediate.DeviceContext.CopyResource(imageSource.m_resource, m_backbufferCopyResource.m_resource);
                imageSource = m_backbufferCopyResource;
                imageSourceResourceView = m_backbufferCopyResource.GetView(viewKey);
            }

            if (imageSource == null)
                return returnData;

            if(imageSizeInBytes > int.MaxValue)
            {
                Debug.Fail("Image size too large to read!");
                return returnData;
            }

            MyBindableResource imageResource = imageSource;
            bool shouldResize = imageSourceResourceView != null;
            if (shouldResize)
            {
                imageResource = m_lastScreenDataResource;
                if (imageResource == null || (imageResource.GetSize().X != resolution.X || imageResource.GetSize().Y != resolution.Y))
                {
                    if (m_lastScreenDataResource != null && (m_lastScreenDataResource != m_backbufferCopyResource && m_lastScreenDataResource != Backbuffer))
                    {
                        m_lastScreenDataResource.Release();
                    }
                    m_lastScreenDataResource = null;

                    imageResource = new MyRenderTarget(resolution.X, resolution.Y, MyRender11Constants.DX11_BACKBUFFER_FORMAT, 1, 0);
                }
                var RC = MyRenderContext.Immediate;
                var deviceContext = RC.DeviceContext;
                deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
                deviceContext.Rasterizer.SetViewport(0, 0, resolution.X, resolution.Y);
                deviceContext.PixelShader.Set(MyDebugRenderer.BlitTextureShader);
                deviceContext.PixelShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);

                RC.BindDepthRT(null, DepthStencilAccess.ReadWrite, imageResource);
                RC.BindSRV(0, imageSourceResourceView);
                MyDebugRenderer.DrawQuad(0, 0, resolution.X, resolution.Y, MyScreenPass.QuadVS);
                //MyCopyToRT.Run(imageResource, imageSourceResourceView, new MyViewport(resolution));
            }

            m_lastScreenDataResource = imageResource;

            Stream dataStream = m_lastDataStream;
            if (m_lastDataStream == null || m_lastDataStream.Length != dataSizeInBytes)
            {
                if (m_lastDataStream != null)
                {
                    m_lastDataStream.Dispose();
                    m_lastDataStream = null;
                }
                dataStream = new DataStream((int)dataSizeInBytes, true, true);
                dataStream.Seek(0, SeekOrigin.Begin);
            }

            m_lastDataStream = dataStream;

            Resource.ToStream(MyRenderContext.Immediate.DeviceContext, imageResource.m_resource, ImageFileFormat.Bmp, dataStream);

            if (!(dataStream.CanRead && dataStream.CanSeek))
            {
                Debug.Fail("Screen data stream does not support the necessary operations to get the data");
                return returnData;
            }

            fixed (byte* dataPointer = screenData)
            {
                GetBmpDataFromStream(dataStream, dataPointer, imageSizeInBytes);
            }

            returnData = screenData;

//.........这里部分代码省略.........
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:101,代码来源:MyRender-DrawScene.cs

示例7: Insert

        public TextureNode Insert(ref Color3[] lightData, int width, int height, int offset, ref DataStream ds, bool flipY)
        {
            if (!leaf)
            {
                if (Child[0].Rectangle.Width >= width && Child[0].Rectangle.Height >= height)
                {
                    TextureNode newnode = Child[0].Insert(ref lightData, width, height, offset, ref ds, flipY);
                    if (newnode != null) return newnode;
                }

                if (Child[1].Rectangle.Width >= width && Child[1].Rectangle.Height >= height)
                    return Child[1].Insert(ref lightData, width, height, offset, ref ds, flipY);
                else
                    return null;
            }
            else
            {
                // allready used?
                if(Used)
                {
                    return null;
                }

                // not a fit?
                if(Rectangle.Width < width || Rectangle.Height < height)
                {
                    return null;
                }

                // perfect fit?
                if((Rectangle.Width == width && Rectangle.Height == height))
                {

                    for (int j = 0; j < (width*height); j++)
                    {
                        int x = Rectangle.X + ((j) % (width));
                        int y = Rectangle.Y + ((j) / (width));
                        long pos = (y * 1024L * 8L) + (x * 8L);
                        if(ds.Position != pos)
                            ds.Seek(pos, System.IO.SeekOrigin.Begin);
                        Half[] half =  Half.ConvertToHalf(new float[] {lightData[offset + j].Red, lightData[offset + j].Green, lightData[offset + j] .Blue});
                        ds.Write<Half3>(new Half3(half[0], half[1], half[2]));
                    }
                    this.Used = true;

                    return this;
                }

                // Else split up and make this a node
                int dw = Rectangle.Width - width;
                int dh = Rectangle.Height - height;

                if (dw > dh)
                {
                    Rectangle rect0 = new Rectangle(Rectangle.Left, Rectangle.Top, width , Rectangle.Height);
                    Rectangle rect1 = new Rectangle(Rectangle.Left + width, Rectangle.Top, Rectangle.Width-width, Rectangle.Height);

                    Child[0] = new TextureNode(rect0, this);
                    Child[1] = new TextureNode(rect1, this);
                }
                else
                {
                    Rectangle rect0 = new Rectangle(Rectangle.Left, Rectangle.Top, Rectangle.Width, height);
                    Rectangle rect1 = new Rectangle(Rectangle.Left, Rectangle.Top+height, Rectangle.Width, Rectangle.Height-height);
                    Child[0] = new TextureNode(rect0, this);
                    Child[1] = new TextureNode(rect1, this);
                }
                leaf = false;
                Used = true;
                return Child[0].Insert(ref lightData, width, height, offset, ref ds, flipY);
            }
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:72,代码来源:TextureNode.cs

示例8: CreateBatch

        private void CreateBatch(PositionTexCoordNormalVertex[] vertices, short[] indices, Renderer renderer)
        {
            Debug.Assert(vertices != null && indices != null);

            int vertexBufferSize = PositionTexCoordNormalVertex.SizeInBytes * vertices.Length;
            var verticesData = new DataStream(vertexBufferSize, true, true);
            verticesData.WriteRange(vertices);
            verticesData.Seek(0, SeekOrigin.Begin);
            var vertexBuffer = new Buffer(renderer.Device, verticesData, vertexBufferSize, ResourceUsage.Default,
                                          BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None);
            verticesData.Close();

            int indexBufferSize = sizeof(short) * indices.Length;
            var indicesData = new DataStream(indexBufferSize, true, true);
            indicesData.WriteRange(indices);
            indicesData.Seek(0, SeekOrigin.Begin);
            var indexBuffer = new Buffer(renderer.Device, indicesData, indexBufferSize, ResourceUsage.Default,
                                         BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None);
            indicesData.Close();

            // Create batch
            var vertexBufferBinding = new VertexBufferBinding(vertexBuffer, PositionTexCoordNormalVertex.SizeInBytes, 0);
            var inputLayout = new InputLayout(renderer.Device, PositionTexCoordNormalVertex.InputElements,
                                              effect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature);
            batch = new DrawIndexedBatch(renderer.Device, effect, new[] { vertexBufferBinding }, inputLayout, indexBuffer, Format.R16_UInt,
                                         indices.Length, 0, 0);
            batches.Add(batch);
        }
开发者ID:TheProjecter,项目名称:romantiquex,代码行数:28,代码来源:SimpleObject.cs

示例9: UploadData

        public void UploadData(Size size, byte[] rgbaData)
        {
            Contract.Requires(Check.IsPositive(size.Width));
            Contract.Requires(Check.IsPositive(size.Height));
            Contract.Requires(rgbaData != null);
            Contract.Requires(
                rgbaData.Length >= (Convert.ToInt32(size.Width) * Convert.ToInt32(size.Height)) * 4);

            int regionWidth = Convert.ToInt32(size.Width);
            int regionHeight = Convert.ToInt32(size.Height);

            if(regionWidth != _Description.Width || regionHeight != _Description.Height)
            {
                _Description.Width = regionWidth;
                _Description.Height = regionHeight;

                _Texture.SafeDispose();

                _Texture = new Texture2D(_Device3D, _Description);
            }

            DataRectangle data = _Texture.Map(0, MapMode.Write, MapFlags.None);

            try
            {
                int stageSize = data.Pitch * regionHeight;

                using(var stream = new DataStream(data.DataPointer, stageSize, false, true))
                {
                    int stride = regionWidth * 4;
                    int indexTotal = regionHeight * stride;

                    for(int index = 0; index < indexTotal; index += stride)
                    {
                        stream.Write(rgbaData, index, stride);

                        stream.Seek(data.Pitch - stride, SeekOrigin.Current);
                    }
                }
            }
            finally
            {
                _Texture.Unmap(0);
            }
        }
开发者ID:fealty,项目名称:Frost,代码行数:45,代码来源:StagingTexture.cs

示例10: context_DeviceReset

        private async void context_DeviceReset(object sender, DeviceResetEventArgs e)
        {
            this.ReleaseResources();

            string assetsPath = Package.Current.InstalledLocation.Path + "/Assets/Render/";

            byte[] vertexShaderByteCode = NativeFile.ReadAllBytes(assetsPath + "MiniCubeTexture_VS.fxo");
            this.vertexShader = new VertexShader(this.parentContext.D3DDevice, vertexShaderByteCode);

            byte[] pixelShaderByteCode = NativeFile.ReadAllBytes(assetsPath + "MiniCubeTexture_PS.fxo");
            this.pixelShader = new PixelShader(this.parentContext.D3DDevice, pixelShaderByteCode);

            this.vertexLayout = new InputLayout(this.parentContext.D3DDevice, vertexShaderByteCode, new[]
            {
                new InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32A32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, 16, 0)
            });

            SharpDX.Direct3D11.Buffer vertices = SharpDX.Direct3D11.Buffer.Create(this.parentContext.D3DDevice, BindFlags.VertexBuffer, new[]
            {
                -0.5f, -0.5f, -0.5f, 0.5f,     0.0f, 1.0f,
                -0.5f,  0.5f, -0.5f, 0.5f,     0.0f, 0.0f,
                0.5f,  0.5f, -0.5f, 0.5f,     1.0f, 0.0f,
                -0.5f, -0.5f, -0.5f, 0.5f,     0.0f, 1.0f,
                0.5f,  0.5f, -0.5f, 0.5f,     1.0f, 0.0f,
                0.5f, -0.5f, -0.5f, 0.5f,     1.0f, 1.0f,
            });

            this.vertexBufferBinding = new VertexBufferBinding(vertices, sizeof(float) * 6, 0);

            this.constantBuffer = new SharpDX.Direct3D11.Buffer(this.parentContext.D3DDevice, Utilities.SizeOf<Matrix>(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);

            this.sampler = new SamplerState(this.parentContext.D3DDevice, new SamplerStateDescription()
            {
                Filter = Filter.MinMagMipLinear,
                AddressU = TextureAddressMode.Wrap,
                AddressV = TextureAddressMode.Wrap,
                AddressW = TextureAddressMode.Wrap,
                BorderColor = Color.Black,
                ComparisonFunction = Comparison.Never,
                MaximumAnisotropy = 16,
                MipLodBias = 0,
                MinimumLod = -float.MaxValue,
                MaximumLod = float.MaxValue
            });

#if SILVERLIGHT
            Deployment.Current.Dispatcher.BeginInvoke(() =>
#else
            await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
#endif

            {
                using (MemoryStream sourceStream = new MemoryStream(NativeFile.ReadAllBytes(assetsPath + "sharpdx.png")))
                {
#if SILVERLIGHT
                    BitmapImage image = new BitmapImage();
                    image.CreateOptions = BitmapCreateOptions.None;
                    image.SetSource(sourceStream);

                    WriteableBitmap bitmap = new WriteableBitmap(image);

                    using (DataStream dataStream = new DataStream(bitmap.Pixels.Length * 4, true, true))
                    {
                        dataStream.WriteRange<int>(bitmap.Pixels);
#else
                    BitmapDecoder decoder = await BitmapDecoder.CreateAsync(sourceStream.AsRandomAccessStream());
                    BitmapFrame bitmap = await decoder.GetFrameAsync(0);
                    PixelDataProvider dataProvider = await bitmap.GetPixelDataAsync(BitmapPixelFormat.Bgra8,
                        BitmapAlphaMode.Premultiplied,
                        new BitmapTransform(),
                        ExifOrientationMode.IgnoreExifOrientation,
                        ColorManagementMode.DoNotColorManage);
                    byte[] pixelData = dataProvider.DetachPixelData();

                    using (DataStream dataStream = new DataStream(pixelData.Length, true, true))
                    {
                        dataStream.WriteRange<byte>(pixelData);
#endif

                        dataStream.Seek(0, SeekOrigin.Begin);

                        DataRectangle dataRectangle = new DataRectangle(dataStream.DataPointer, (int)(bitmap.PixelWidth * 4));

                        this.texture = new Texture2D(this.parentContext.D3DDevice, new Texture2DDescription()
                        {
                            Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm,
                            Width = (int)bitmap.PixelWidth,
                            Height = (int)bitmap.PixelHeight,
                            ArraySize = 1,
                            MipLevels = 1,
                            BindFlags = BindFlags.ShaderResource,
                            Usage = ResourceUsage.Default,
                            CpuAccessFlags = CpuAccessFlags.None,
                            OptionFlags = ResourceOptionFlags.None,
                            SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0)
                        }, dataRectangle);

                        this.textureView = new ShaderResourceView(this.parentContext.D3DDevice, this.texture);
                    }
//.........这里部分代码省略.........
开发者ID:r2d2rigo,项目名称:SharpDX.SimpleInitializer-Samples,代码行数:101,代码来源:SceneRenderer.cs


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