本文整理汇总了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;
}
示例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 );
}
示例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);
}
}
示例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();
}
示例5: WrappedCubeTexture
private WrappedCubeTexture(Device device, int edgeSize, Usage usage, Format format, Pool pool)
{
_usage = usage;
_format = format;
_edgeSize = edgeSize;
_pool = pool;
CreateCubeTexture(device);
}
示例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);
}
}
示例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));
}
}
示例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;
}
示例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);
}
}
示例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));
}
}
示例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;
}
示例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;
}
示例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
}
示例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);
}
示例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;
}