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


C# Usage类代码示例

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


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

示例1: PixelDataProvider

        public PixelDataProvider(int width, int height, int numChannels, Device device, Usage usage)
            : base()
        {
            Format pf = Format.X8R8G8B8;
            switch (numChannels)
            {
                case 1:
                    pf = Format.A8;
                    break;
                case 3:
                    pf = Format.R8G8B8;
                    break;
                case 4:
                    pf = Format.X8R8G8B8;
                    break;
                case 8:
                    pf = Format.A16B16G16R16;
                    break;
            }
            //TODO: how to find out which Formats are supported??
            //device.DeviceCaps.TextureCaps
            if (pf == Format.R8G8B8)
                pf = Format.X8R8G8B8;

            //RenderToSurface sf = new RenderToSurface(device, width, height, pf, false, null);
            //this._tx = new Texture(device, width, height, 1, Usage.RenderTarget, pf, Pool.Default); // Pool.Managed doesn't work with Usage.RenderTarget
            Pool pool = Pool.Managed;
            if (usage == Usage.RenderTarget)
                pool = Pool.Default;

            this._tx = new Texture(device, width, height, 1, usage, pf, pool);
            //this._sd = this._tx.GetLevelDescription(0);
            this._surf = this._tx.GetSurfaceLevel(0); //AOAO
            this._sd = this._surf.Description;
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:35,代码来源:PixelDataProvider.cs

示例2: CreateIndexBuffer

 public DataBuffer CreateIndexBuffer(int length, Usage usage, Format format, Pool pool)
 {
     IntPtr pOut = IntPtr.Zero;
     int res = Interop.Calli(comPointer, length, (int)usage, (int)format, (int)pool, (IntPtr)(void*)&pOut, IntPtr.Zero,(*(IntPtr**)comPointer)[27]);
     if( res < 0 ) { throw new SharpDXException( res ); }
     return new DataBuffer( pOut );
 }
开发者ID:lavajoe,项目名称:ClassicalSharp,代码行数:7,代码来源:Device.cs

示例3: FromFile

 public static Texture2D FromFile(DeviceContext context, string file, Usage usage, Pool pool)
 {
     using (var stream = File.OpenRead(file))
     {
         return FromStream(context, stream, usage, pool);
     }
 }
开发者ID:TormentedEmu,项目名称:OpenUO,代码行数:7,代码来源:Texture2D.cs

示例4: ReadTexture

		public ReadTexture(int width, int height, uint handle, EnumEntry formatEnum, EnumEntry usageEnum)
		{
			Format format;
			if (formatEnum.Name == "INTZ")
				format = D3DX.MakeFourCC((byte)'I', (byte)'N', (byte)'T', (byte)'Z');
			else if (formatEnum.Name == "RAWZ")
				format = D3DX.MakeFourCC((byte)'R', (byte)'A', (byte)'W', (byte)'Z');
			else if (formatEnum.Name == "RESZ")
				format = D3DX.MakeFourCC((byte)'R', (byte)'E', (byte)'S', (byte)'Z');
			else if (formatEnum.Name == "No Specific")
				throw (new Exception("Texture mode not supported"));
			else
				format = (Format)Enum.Parse(typeof(Format), formatEnum, true);

			var usage = Usage.Dynamic;
			if (usageEnum.Index == (int)(TextureType.RenderTarget))
				usage = Usage.RenderTarget;
			else if (usageEnum.Index == (int)(TextureType.DepthStencil))
				usage = Usage.DepthStencil;

			this.FWidth = width;
			this.FHeight = height;
			this.FHandle = (IntPtr)unchecked((int)handle);
			this.FFormat = format;
			this.FUsage = usage;

			Initialise();
		}
开发者ID:kevinbs,项目名称:VVVV.Packs.Image,代码行数:28,代码来源:ReadTexture.cs

示例5: WrappedCubeTexture

 private WrappedCubeTexture(Device device, int edgeSize, Usage usage, Format format, Pool pool)
 {
     _usage = usage;
     _format = format;
     _edgeSize = edgeSize;
     _pool = pool;
     CreateCubeTexture(device);
 }
开发者ID:HaKDMoDz,项目名称:Psy,代码行数:8,代码来源:WrappedCubeTexture.cs

示例6: CubeTexture

 /// <summary>
 /// Initializes a new instance of the <see cref="CubeTexture"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="edgeLength">Length of the edge.</param>
 /// <param name="levelCount">The level count.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="format">The format.</param>
 /// <param name="pool">The pool.</param>
 /// <param name="sharedHandle">The shared handle.</param>
 public CubeTexture(Device device, int edgeLength, int levelCount, Usage usage, Format format, Pool pool, ref IntPtr sharedHandle) : base(IntPtr.Zero)
 {
     unsafe
     {
         fixed (void* pSharedHandle = &sharedHandle)
             device.CreateCubeTexture(edgeLength, levelCount, (int)usage, format, pool, this, (IntPtr)pSharedHandle);
     }
 }
开发者ID:Ziriax,项目名称:SharpDX,代码行数:18,代码来源:CubeTexture.cs

示例7: VolumeTexture

 /// <summary>
 /// Initializes a new instance of the <see cref="VolumeTexture"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="depth">The depth.</param>
 /// <param name="levelCount">The level count.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="format">The format.</param>
 /// <param name="pool">The pool.</param>
 /// <param name="sharedHandle">The shared handle.</param>
 /// <unmanaged>HRESULT IDirect3DDevice9::CreateVolumeTexture([In] unsigned int Width,[In] unsigned int Height,[In] unsigned int Levels,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[Out, Fast] IDirect3DVolumeTexture9** ppVolumeTexture,[In] void** pSharedHandle)</unmanaged>
 public VolumeTexture(Device device, int width, int height, int depth, int levelCount, Usage usage, Format format, Pool pool, ref IntPtr sharedHandle)
     : base(IntPtr.Zero)
 {
     unsafe
     {
         fixed (void* pSharedHandle = &sharedHandle)
             device.CreateVolumeTexture(width, height, depth, levelCount, (int)usage, format, pool, this, new IntPtr(pSharedHandle));
     }
 }
开发者ID:rbwhitaker,项目名称:SharpDX,代码行数:22,代码来源:VolumeTexture.cs

示例8: Texture2D

 public Texture2D(Device d, int width, int height, Usage u)
 {
     handle = new Texture(d, width, height, 1, u, Format.A8R8G8B8, Pool.Default);
     usage = u;
     Width = width;
     Height = height;
     device = d;
     managed = false;
 }
开发者ID:Naronco,项目名称:Rekd-Sharp,代码行数:9,代码来源:Texture2D.cs

示例9: IndexBuffer

 /// <summary>
 /// Initializes a new instance of the <see cref="IndexBuffer"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="sizeInBytes">The size in bytes.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="pool">The pool.</param>
 /// <param name="sixteenBit">if set to <c>true</c> use 16bit index buffer, otherwise, use 32bit index buffer.</param>
 /// <param name="sharedHandle">The shared handle.</param>
 /// <msdn-id>bb174357</msdn-id>	
 /// <unmanaged>HRESULT IDirect3DDevice9::CreateIndexBuffer([In] unsigned int Length,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[Out, Fast] IDirect3DIndexBuffer9** ppIndexBuffer,[In] void** pSharedHandle)</unmanaged>	
 /// <unmanaged-short>IDirect3DDevice9::CreateIndexBuffer</unmanaged-short>	
 public IndexBuffer(Device device, int sizeInBytes, Usage usage, Pool pool, bool sixteenBit, ref IntPtr sharedHandle)
     : base(IntPtr.Zero)
 {
     unsafe
     {
         fixed (void* pSharedHandle = &sharedHandle)
             device.CreateIndexBuffer(sizeInBytes, (int)usage, sixteenBit ? Format.Index16 : Format.Index32, pool, this, (IntPtr)pSharedHandle);
     }
 }
开发者ID:alexey-bez,项目名称:SharpDX,代码行数:21,代码来源:IndexBuffer.cs

示例10: VertexBuffer

 /// <summary>
 /// Initializes a new instance of the <see cref="SharpDX.Direct3D9.VertexBuffer" /> class.
 /// </summary>
 /// <param name="device">The device that will be used to create the buffer.</param>
 /// <param name="sizeInBytes">Size of the buffer, in bytes.</param>
 /// <param name="usage">The requested usage of the buffer.</param>
 /// <param name="format">The vertex format of the vertices in the buffer. If set to <see cref="SharpDX.Direct3D9.VertexFormat" />.None, the buffer will be a non-FVF buffer.</param>
 /// <param name="pool">The memory class into which the resource will be placed.</param>
 /// <param name="sharedHandle">The variable that will receive the shared handle for this resource.</param>
 /// <remarks>This method is only available in Direct3D9 Ex.</remarks>
 /// <msdn-id>bb174364</msdn-id>	
 /// <unmanaged>HRESULT IDirect3DDevice9::CreateVertexBuffer([In] unsigned int Length,[In] D3DUSAGE Usage,[In] D3DFVF FVF,[In] D3DPOOL Pool,[Out, Fast] IDirect3DVertexBuffer9** ppVertexBuffer,[In] void** pSharedHandle)</unmanaged>	
 /// <unmanaged-short>IDirect3DDevice9::CreateVertexBuffer</unmanaged-short>	
 public VertexBuffer(Device device, int sizeInBytes, Usage usage, VertexFormat format, Pool pool, ref IntPtr sharedHandle)
     : base(IntPtr.Zero)
 {
     unsafe
     {
         sharedHandle = IntPtr.Zero;
         fixed (void* pSharedHandle = &sharedHandle)
             device.CreateVertexBuffer(sizeInBytes, usage, format, pool, this, new IntPtr(pSharedHandle));
     }
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:23,代码来源:VertexBuffer.cs

示例11: CheckRequirements

 /// <summary>
 /// Checks texture-creation parameters.
 /// </summary>
 /// <param name="device">Device associated with the texture.</param>
 /// <param name="size">Requested size of the texture. Null if </param>
 /// <param name="mipLevelCount">Requested number of mipmap levels for the texture.</param>
 /// <param name="usage">The requested usage for the texture.</param>
 /// <param name="format">Requested format for the texture.</param>
 /// <param name="pool">Memory class where the resource will be placed.</param>
 /// <returns>A value type containing the proposed values to pass to the texture creation functions.</returns>
 /// <unmanaged>HRESULT D3DXCheckCubeTextureRequirements([In] IDirect3DDevice9* pDevice,[InOut] unsigned int* pSize,[InOut] unsigned int* pNumMipLevels,[In] unsigned int Usage,[InOut] D3DFORMAT* pFormat,[In] D3DPOOL Pool)</unmanaged>
 public static CubeTextureRequirements CheckRequirements(Device device, int size, int mipLevelCount, Usage usage, Format format, Pool pool)
 {
     var result = new CubeTextureRequirements
         {
             Size = size,
             MipLevelCount = mipLevelCount,
             Format = format
         };
     D3DX9.CheckCubeTextureRequirements(device, ref result.Size, ref result.MipLevelCount, (int)usage, ref result.Format, pool);
     return result;
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:22,代码来源:CubeTexture.cs

示例12: BufferDescription

 public BufferDescription(
     int sizeInBytes,
     Usage usage,
     BindFlags bindFlags,
     MiscFlags miscFlags,
     ExtraFlags extraFlags,
     int structureByteStide)
 {
     SizeInBytes = sizeInBytes;
     Usage = usage;
     BindFlags = bindFlags;
     MiscFlags = miscFlags;
     ExtraFlags = extraFlags;
     StructureByteStride = structureByteStide;
 }
开发者ID:Zulkir,项目名称:Beholder,代码行数:15,代码来源:BufferDescription.cs

示例13: TextureBase

        protected TextureBase(DeviceContext context, int width, int height, int levelCount, Usage usage, Format format, Pool pool)
            : base(context)
        {
            _size = new Vector2(width, height);
            _width = width;
            _height = height;
            _levelCount = levelCount;
            _usage = usage;
            _format = format;
            _pool = pool;

            _texture = new Texture(context, width, height, levelCount, usage, format, pool);
            #if DEBUG
            Context.PerformanceMonitor.IncreaseLifetimeCounter(LifetimeCounters.TextureCount);
            #endif
        }
开发者ID:TormentedEmu,项目名称:OpenUO,代码行数:16,代码来源:TextureBase.cs

示例14: GetAttributesTextFor

        public override IEnumerable<string> GetAttributesTextFor(FieldInfo field, Usage defaultUsage, ParsingPolicyAttribute[] parsingPolicies)
        {
            var res = new List<string>(base.GetAttributesTextFor(field, defaultUsage, parsingPolicies));

            var fieldType = field.FieldType;
            var renameRule = field.GetCustomAttribute<RenameAttribute>();
            string fieldName = field.GetCustomAttribute<NameAttribute>()?.Name ?? field.Name;

            if (!field.IsDefined<RefAttribute>())
            {
                if (field.IsPolymorphic())
                {
                    Type attributeType = !fieldType.IsArray || field.IsDefined<InlineAttribute>() ? typeof(XmlElementAttribute) : typeof(XmlArrayItemAttribute);
                    foreach (var t in field.GetKnownSerializableTypes())
                        res.Add(GetItemAttributeText(attributeType, t, renameRule));
                }
                else if (
                    field.FieldType.IsArray &&
                    !field.IsDefined<ConverterAttribute>() &&
                    !field.IsDefined<ParserAttribute>() &&
                    !parsingPolicies.Any(p => p.CanParse(field.FieldType)))
                {
                    Type attributeType = field.IsDefined<InlineAttribute>() ? typeof(XmlElementAttribute) : typeof(XmlArrayItemAttribute);
                    Type itemTypeName = field.FieldType.GetElementType();
                    res.Add(GetItemAttributeText(attributeType, itemTypeName, renameRule));
                }
            }

            var rawFieldType = field.GetRawFieldType(parsingPolicies);
            if (rawFieldType.IsSimple())
            {
                res.Add(AttributeBuilder.GetTextFor<XmlAttributeAttribute>(fieldName));
            }
            else if (!res.Any(a => a.Contains(nameof(XmlElementAttribute))))
            {
                 if (rawFieldType.IsArray)
                    res.Add(AttributeBuilder.GetTextFor<XmlArrayAttribute>(fieldName));
                 else
                    res.Add(AttributeBuilder.GetTextFor<XmlElementAttribute>(fieldName));
            }

            if (field.IsDefined<HiddenAttribute>())
                res.Add(AttributeBuilder.GetTextFor<XmlIgnoreAttribute>());

            return res.Where(a => a != null);
        }
开发者ID:lukyad,项目名称:Eco,代码行数:46,代码来源:XmlAttributesGenerator.cs

示例15: GetAttributesTextFor

        public virtual IEnumerable<string> GetAttributesTextFor(FieldInfo field, Usage defaultUsage, ParsingPolicyAttribute[] parsingPolicies)
        {
            var result = new List<string>();
            var fieldType = field.FieldType;
            string usageAttribute = null;
            bool isForcedUsage = defaultUsage == Usage.ForceRequired || defaultUsage == Usage.ForceOptional;
            if (isForcedUsage)
            {
                if (defaultUsage == Usage.ForceRequired) usageAttribute = AttributeBuilder.GetTextFor<RequiredAttribute>();
                else if (defaultUsage == Usage.ForceOptional) usageAttribute = AttributeBuilder.GetTextFor<OptionalAttribute>();
            }
            else if (fieldType.IsValueType && Nullable.GetUnderlyingType(field.FieldType) == null)
            {
                usageAttribute = AttributeBuilder.GetTextFor<RequiredAttribute>();
            }
            else if (Nullable.GetUnderlyingType(field.FieldType) != null)
            {
                usageAttribute = AttributeBuilder.GetTextFor<OptionalAttribute>();
            }
            else if (!field.IsDefined<RequiredAttribute>() && !field.IsDefined<OptionalAttribute>())
            {
                if (defaultUsage == Usage.Required) usageAttribute = AttributeBuilder.GetTextFor<RequiredAttribute>();
                else if (defaultUsage == Usage.Optional) usageAttribute = AttributeBuilder.GetTextFor<OptionalAttribute>();
            }
            if (usageAttribute != null)
                result.Add(usageAttribute);

            var attributes = field.GetCustomAttributes().ToArray();
            var attributesData = field.GetCustomAttributesData();
            for (int i = 0; i < attributes.Length; i++)
            {
                // Skip any usage attributes, if field usage is forced by the calling method.
                bool isUsageAttribute = attributes[i] is OptionalAttribute || attributes[i] is RequiredAttribute;
                if (isForcedUsage && isUsageAttribute) continue;
                // Get c# compatible attribute text.
                string attributeText = CommonAttributeTranslator.Translate(attributes[i], attributesData[i], field);
                if (attributeText != null)
                    result.Add(attributeText);
            }
            return result;
        }
开发者ID:lukyad,项目名称:Eco,代码行数:41,代码来源:CommonAttributesGenerator.cs


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