本文整理汇总了C#中BufferUsage类的典型用法代码示例。如果您正苦于以下问题:C# BufferUsage类的具体用法?C# BufferUsage怎么用?C# BufferUsage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BufferUsage类属于命名空间,在下文中一共展示了BufferUsage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HardwareIndexBuffer
/// <summary>
/// Constructor.
/// </summary>
///<param name="manager"></param>
///<param name="type">Type of index (16 or 32 bit).</param>
/// <param name="numIndices">Number of indices to create in this buffer.</param>
/// <param name="usage">Buffer usage.</param>
/// <param name="useSystemMemory">Create in system memory?</param>
/// <param name="useShadowBuffer">Use a shadow buffer for reading/writing?</param>
public HardwareIndexBuffer( HardwareBufferManagerBase manager, IndexType type, int numIndices, BufferUsage usage, bool useSystemMemory, bool useShadowBuffer )
: base( usage, useSystemMemory, useShadowBuffer )
{
this.type = type;
this.numIndices = numIndices;
this.Manager = manager;
// calc the index buffer size
sizeInBytes = numIndices;
if ( type == IndexType.Size32 )
{
indexSize = Marshal.SizeOf( typeof( int ) );
}
else
{
indexSize = Marshal.SizeOf( typeof( short ) );
}
sizeInBytes *= indexSize;
// create a shadow buffer if required
if ( useShadowBuffer )
{
shadowBuffer = new DefaultHardwareIndexBuffer( Manager, type, numIndices, BufferUsage.Dynamic );
}
}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:35,代码来源:HardwareIndexBuffer.cs
示例2: GLESHardwareIndexBuffer
public GLESHardwareIndexBuffer( HardwareBufferManagerBase manager, IndexType type, int numIndices, BufferUsage usage, bool useShadowBuffer )
: base( manager, type, numIndices, usage, false, useShadowBuffer )
{
if ( type == IndexType.Size32 )
{
throw new AxiomException( "32 bit hardware buffers are not allowed in OpenGL ES." );
}
if ( !useShadowBuffer )
{
throw new AxiomException( "Only support with shadowBuffer" );
}
OpenGL.GenBuffers( 1, ref this._bufferId );
GLESConfig.GlCheckError( this );
if ( this._bufferId == 0 )
{
throw new AxiomException( "Cannot create GL index buffer" );
}
OpenGL.BindBuffer( All.ElementArrayBuffer, this._bufferId );
GLESConfig.GlCheckError( this );
OpenGL.BufferData( All.ElementArrayBuffer, new IntPtr( sizeInBytes ), IntPtr.Zero, GLESHardwareBufferManager.GetGLUsage( usage ) );
GLESConfig.GlCheckError( this );
}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:25,代码来源:GLESHardwareIndexBuffer.cs
示例3: CreateVertexBuffer
public override HardwareVertexBuffer CreateVertexBuffer( VertexDeclaration vertexDeclaration, int numVerts,
BufferUsage usage, bool useShadowBuffer )
{
Contract.Requires( numVerts > 0 );
#if AXIOM_D3D_MANAGE_BUFFERS
// Override shadow buffer setting; managed buffers are automatically
// backed by system memory
// Don't override shadow buffer if discardable, since then we use
// unmanaged buffers for speed (avoids write-through overhead)
if ( useShadowBuffer && ( usage & BufferUsage.Discardable ) == 0 )
{
useShadowBuffer = false;
// Also drop any WRITE_ONLY so we can read direct
if ( usage == BufferUsage.DynamicWriteOnly )
{
usage = BufferUsage.Dynamic;
}
else if ( usage == BufferUsage.StaticWriteOnly )
{
usage = BufferUsage.Static;
}
}
#endif
var vbuf = new D3D9HardwareVertexBuffer( this, vertexDeclaration, numVerts, usage, false, useShadowBuffer );
lock ( VertexBuffersMutex )
{
vertexBuffers.Add( vbuf );
}
return vbuf;
}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:33,代码来源:D3D9HardwareBufferManager.cs
示例4: IndexBuffer
public IndexBuffer(Device device, BufferUsage usage)
{
this.device = device;
this.usage = usage;
Gl.glGenBuffersARB(1, out this.handle);
}
开发者ID:sinclairzx81,项目名称:vector-cs,代码行数:8,代码来源:IndexBuffer.cs
示例5: CreateIndexBuffer
public override HardwareIndexBuffer CreateIndexBuffer( IndexType type, int numIndices, BufferUsage usage,
bool useShadowBuffer )
{
var buffer = new GLHardwareIndexBuffer( this, type, numIndices, usage, useShadowBuffer );
lock ( IndexBuffersMutex )
indexBuffers.Add( buffer );
return buffer;
}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:8,代码来源:GLHardwareBufferManager.cs
示例6: CreateIndexBuffer
public override HardwareIndexBuffer CreateIndexBuffer( IndexType type, int numIndices, BufferUsage usage, bool useShadowBuffer )
{
var indexBuffer = new GLESHardwareIndexBuffer( this, type, numIndices, usage, true );
lock ( IndexBuffersMutex )
{
indexBuffers.Add( indexBuffer );
}
return indexBuffer;
}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:9,代码来源:GLES2HardwareBufferManagerBase.cs
示例7: CreateVertexBuffer
public override HardwareVertexBuffer CreateVertexBuffer( VertexDeclaration vertexDeclaration, int numVerts, BufferUsage usage, bool useShadowBuffer )
{
var vertexBuffer = new GLESHardwareVertexBuffer( this, vertexDeclaration, numVerts, usage, true );
lock ( VertexBuffersMutex )
{
vertexBuffers.Add( vertexBuffer );
}
return vertexBuffer;
}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:9,代码来源:GLES2HardwareBufferManagerBase.cs
示例8: AllocateStorage
public void AllocateStorage(IntPtr dataPtr, int size, BufferUsage usage)
{
if (size < 1)
return;
//if (dataPtr == IntPtr.Zero)
// return;
// Allocate memory for the buffer
GI.BufferData(fBufferTarget, size, dataPtr, usage);
}
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:11,代码来源:GLBufferObject.cs
示例9: GLES2DefaultHardwareIndexBuffer
/// <summary>
/// </summary>
/// <param name="idxType"> </param>
/// <param name="numIndexes"> </param>
/// <param name="usage"> </param>
public GLES2DefaultHardwareIndexBuffer( IndexType idxType, int numIndexes, BufferUsage usage )
: base( null, idxType, numIndexes, usage, true, false ) // always software, never shadowed
{
if ( idxType == IndexType.Size32 )
{
throw new AxiomException( "32 bit hardware buffers are not allowed in OpenGL ES." );
}
this._data = new byte[ sizeInBytes ];
this._dataPtr = BufferBase.Wrap( this._data );
}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:16,代码来源:GLES2DefaultHardwareIndexBuffer.cs
示例10: GLESTextureBuffer
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="target"></param>
/// <param name="id"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="format"></param>
/// <param name="face"></param>
/// <param name="level"></param>
/// <param name="usage"></param>
/// <param name="crappyCard"></param>
/// <param name="writeGamma"></param>
/// <param name="fsaa"></param>
public GLESTextureBuffer( string basename, All targetfmt, int id, int width, int height, int format, int face, int level, BufferUsage usage, bool crappyCard, bool writeGamma, int fsaa )
: base( 0, 0, 0, Media.PixelFormat.Unknown, usage )
{
_target = targetfmt;
_textureId = id;
_face = face;
_level = level;
_softwareMipmap = crappyCard;
GLESConfig.GlCheckError( this );
OpenGL.BindTexture( All.Texture2D, _textureId );
GLESConfig.GlCheckError( this );
// Get face identifier
_faceTarget = _target;
// TODO verify who get this
Width = width;
Height = height;
Depth = 1;
_glInternalFormat = (All)format;
Format = GLESPixelUtil.GetClosestAxiomFormat( _glInternalFormat );
RowPitch = Width;
SlicePitch = Height * Width;
sizeInBytes = PixelUtil.GetMemorySize( Width, Height, Depth, Format );
// Set up a pixel box
_buffer = new PixelBox( Width, Height, Depth, Format );
if ( Width == 0 || Height == 0 || Depth == 0 )
{
/// We are invalid, do not allocate a buffer
return;
}
// Is this a render target?
if ( ( (int)Usage & (int)TextureUsage.RenderTarget ) != 0 )
{
// Create render target for each slice
for ( int zoffset = 0; zoffset < Depth; zoffset++ )
{
string name = string.Empty;
name = "rtt/" + this.GetHashCode() + "/" + basename;
GLESSurfaceDescription target = new GLESSurfaceDescription();
target.Buffer = this;
target.ZOffset = zoffset;
RenderTexture trt = GLESRTTManager.Instance.CreateRenderTexture( name, target, writeGamma, fsaa );
_sliceTRT.Add( trt );
Root.Instance.RenderSystem.AttachRenderTarget( _sliceTRT[ zoffset ] );
}
}
}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:69,代码来源:GLESTextureBuffer.cs
示例11: VertexBuffer
public VertexBuffer(int _numElements, int _elementSize, BufferUsage _usage)
{
type = Gl.GL_ARRAY_BUFFER;
numElem = _numElements;
elemSize = _elementSize;
usage = _usage;
int[] ids = new int[1];
Gl.glGenBuffers (1, ids);
id = ids[0];
}
开发者ID:jcnossen,项目名称:upspring.net,代码行数:12,代码来源:VertexBuffer.cs
示例12: ConvertEnum
/// <summary>
///
/// </summary>
/// <param name="usage"></param>
/// <returns></returns>
public static int ConvertEnum(BufferUsage usage)
{
switch(usage) {
case BufferUsage.Static:
case BufferUsage.StaticWriteOnly:
return (int)Gl.GL_STATIC_DRAW_ARB;
case BufferUsage.Dynamic:
case BufferUsage.DynamicWriteOnly:
default:
return (int)Gl.GL_DYNAMIC_DRAW_ARB;
}
}
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:18,代码来源:GLHelper.cs
示例13: HardwarePixelBuffer
///<summary>
/// Should be called by HardwareBufferManager
///</summary>
public HardwarePixelBuffer(int width, int height, int depth,
Axiom.Media.PixelFormat format, BufferUsage usage,
bool useSystemMemory, bool useShadowBuffer)
: base(usage, useSystemMemory, useShadowBuffer)
{
this.width = width;
this.height = height;
this.depth = depth;
this.format = format;
// Default
rowPitch = width;
slicePitch = height * width;
sizeInBytes = height * width * depth * PixelUtil.GetNumElemBytes(format);
}
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:17,代码来源:HardwarePixelBuffer.cs
示例14: Define
public void Define( Array controlPointArray, VertexDeclaration declaration, int width, int height,
int uMaxSubdivisionLevel, int vMaxSubdivisionLevel, VisibleSide visibleSide, BufferUsage vbUsage,
BufferUsage ibUsage, bool vbUseShadow, bool ibUseShadow )
{
VertexBufferUsage = vbUsage;
UseVertexShadowBuffer = vbUseShadow;
IndexBufferUsage = ibUsage;
UseIndexShadowBuffer = ibUseShadow;
// Init patch builder
// define the surface
// NB clone the declaration to make it independent
this.vertexDeclaration = (VertexDeclaration)declaration.Clone();
this.patchSurface.DefineSurface( controlPointArray, this.vertexDeclaration, width, height, PatchSurfaceType.Bezier,
uMaxSubdivisionLevel, vMaxSubdivisionLevel, visibleSide );
}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:16,代码来源:PatchMesh.cs
示例15: GLBufferObject
public GLBufferObject(GraphicsInterface gi, BufferTarget target, BufferUsage usage, IntPtr dataPtr, int size)
:base(gi)
{
fBufferTarget = target;
// Generate the buffer ID
gi.GenBufferID(out fBufferID);
// Bind the buffer so subsequent calls apply to that buffer
Bind();
if (size > 0)
AllocateStorage(dataPtr, size, usage);
Unbind();
}
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:16,代码来源:GLBufferObject.cs
示例16: GLHardwareVertexBuffer
public GLHardwareVertexBuffer(int vertexSize, int numVertices, BufferUsage usage, bool useShadowBuffer)
: base(vertexSize, numVertices, usage, false, useShadowBuffer)
{
bufferID = 0;
Gl.glGenBuffersARB(1, out bufferID);
if(bufferID == 0) {
throw new Exception("Cannot create GL vertex buffer");
}
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, bufferID);
// initialize this buffer. we dont have data yet tho
Gl.glBufferDataARB(Gl.GL_ARRAY_BUFFER_ARB, sizeInBytes, IntPtr.Zero, GLHelper.ConvertEnum(usage));
}
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:16,代码来源:GLHardwareVertexBuffer.cs
示例17: XnaHardwareIndexBuffer
unsafe public XnaHardwareIndexBuffer( HardwareBufferManagerBase manager, IndexType type, int numIndices, BufferUsage usage, XFG.GraphicsDevice device, bool useSystemMemory, bool useShadowBuffer )
: base( manager, type, numIndices, usage, useSystemMemory, useShadowBuffer )
{
_bufferType = ( type == IndexType.Size16 ) ? XFG.IndexElementSize.SixteenBits : XFG.IndexElementSize.ThirtyTwoBits;
// create the buffer
if (usage == BufferUsage.Dynamic || usage == BufferUsage.DynamicWriteOnly)
{
_xnaBuffer = new XFG.IndexBuffer(device, _bufferType, numIndices, XnaHelper.Convert(usage));
}
else
_xnaBuffer = new XFG.IndexBuffer(device, _bufferType, numIndices, XFG.BufferUsage.None);
_bufferBytes = new byte[ sizeInBytes ];
_bufferBytes.Initialize();
}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:16,代码来源:XnaHardwareIndexBuffer.cs
示例18: GenIndependentBuffer
///// <summary>
///// Generates an atomic counter buffer.
///// </summary>
///// <param name="array"></param>
///// <param name="usage"></param>
///// <returns></returns>
//public static AtomicCounterBuffer GenAtomicCounterBuffer(this UnmanagedArrayBase array, BufferUsage usage)
//{
// return GenIndependentBuffer(array, IndependentBufferTarget.AtomicCounterBuffer, usage) as AtomicCounterBuffer;
//}
///// <summary>
///// Generates a pixel pack buffer.
///// </summary>
///// <param name="array"></param>
///// <param name="usage"></param>
///// <returns></returns>
//public static PixelPackBuffer GenPixelPackBuffer(this UnmanagedArrayBase array, BufferUsage usage)
//{
// return GenIndependentBuffer(array, IndependentBufferTarget.PixelPackBuffer, usage) as PixelPackBuffer;
//}
///// <summary>
///// Generates a pixel unpack buffer.
///// </summary>
///// <param name="array"></param>
///// <param name="usage"></param>
///// <returns></returns>
//public static PixelUnpackBuffer GenPixelUnpackBuffer(this UnmanagedArrayBase array, BufferUsage usage)
//{
// return GenIndependentBuffer(array, IndependentBufferTarget.PixelUnpackBuffer, usage) as PixelUnpackBuffer;
//}
///// <summary>
///// Generates a shader storage buffer.
///// </summary>
///// <param name="array"></param>
///// <param name="usage"></param>
///// <returns></returns>
//public static ShaderStorageBuffer GenShaderStorageBuffer(this UnmanagedArrayBase array, BufferUsage usage)
//{
// return GenIndependentBuffer(array, IndependentBufferTarget.ShaderStorageBuffer, usage) as ShaderStorageBuffer;
//}
///// <summary>
///// Generates a texture buffer.
///// </summary>
///// <param name="array"></param>
///// <param name="usage"></param>
///// <returns></returns>
//public static TextureBuffer GenTextureBuffer(this UnmanagedArrayBase array, BufferUsage usage)
//{
// return GenIndependentBuffer(array, IndependentBufferTarget.TextureBuffer, usage) as TextureBuffer;
//}
///// <summary>
///// Generates an uniform buffer.
///// </summary>
///// <param name="array"></param>
///// <param name="usage"></param>
///// <returns></returns>
//public static UniformBuffer GenUniformBuffer(this UnmanagedArrayBase array, BufferUsage usage)
//{
// return GenIndependentBuffer(array, IndependentBufferTarget.UniformBuffer, usage) as UniformBuffer;
//}
/// <summary>
/// Generates an independent buffer.
/// </summary>
/// <param name="array"></param>
/// <param name="bufferTarget"></param>
/// <param name="usage"></param>
/// <returns></returns>
private static Buffer GenIndependentBuffer(this UnmanagedArrayBase array, IndependentBufferTarget bufferTarget, BufferUsage usage)
{
if (glGenBuffers == null)
{
InitFunctions();
}
uint[] buffers = new uint[1];
glGenBuffers(1, buffers);
var target = (uint)bufferTarget;
glBindBuffer(target, buffers[0]);
glBufferData(target, array.ByteLength, array.Header, (uint)usage);
glBindBuffer(target, 0);
Buffer buffer = null;
switch (bufferTarget)
{
case IndependentBufferTarget.AtomicCounterBuffer:
buffer = new AtomicCounterBuffer(buffers[0], array.Length, array.ByteLength);
break;
case IndependentBufferTarget.PixelPackBuffer:
buffer = new PixelPackBuffer(buffers[0], array.Length, array.ByteLength);
break;
case IndependentBufferTarget.PixelUnpackBuffer:
buffer = new PixelUnpackBuffer(buffers[0], array.Length, array.ByteLength);
break;
case IndependentBufferTarget.ShaderStorageBuffer:
buffer = new ShaderStorageBuffer(buffers[0], array.Length, array.ByteLength);
break;
//.........这里部分代码省略.........
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:101,代码来源:GenOtherBuffers.UnmanagedArrayBase.cs
示例19: PatchMesh
// ------------------------------------
// ------------------------------------
/// <summary>
/// Creates a new PatchMesh.
/// </summary>
/// <remarks>
/// As defined in <see cref="MeshManager.CreateBezierPatch" />.
/// </remarks>
public PatchMesh(string name, System.Array controlPointBuffer, VertexDeclaration declaration,
int width, int height, int uMaxSubdivisionLevel, int vMaxSubdivisionLevel, VisibleSide visibleSide,
BufferUsage vbUsage, BufferUsage ibUsage, bool vbUseShadow, bool ibUseShadow)
: base(name)
{
vertexBufferUsage = vbUsage;
useVertexShadowBuffer = vbUseShadow;
indexBufferUsage = ibUsage;
useIndexShadowBuffer = ibUseShadow;
// Init patch builder
// define the surface
// NB clone the declaration to make it independent
vertexDeclaration = (VertexDeclaration)declaration.Clone();
patchSurface.DefineSurface(controlPointBuffer, vertexDeclaration, width, height,
PatchSurfaceType.Bezier, uMaxSubdivisionLevel, vMaxSubdivisionLevel, visibleSide);
}
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:25,代码来源:PatchMesh.cs
示例20: XnaHardwareVertexBuffer
public XnaHardwareVertexBuffer( HardwareBufferManagerBase manager, VertexDeclaration vertexDeclaration, int numVertices, BufferUsage usage, XFG.GraphicsDevice dev, bool useSystemMemory, bool useShadowBuffer )
: base( manager, vertexDeclaration, numVertices, usage, useSystemMemory, useShadowBuffer )
{
_device = dev;
if ( !( vertexDeclaration is XnaVertexDeclaration ) )
{
throw new AxiomException ("Invalid VertexDeclaration supplied, must be created by HardwareBufferManager.CreateVertexDeclaration()" );
}
if (usage == BufferUsage.Dynamic || usage == BufferUsage.DynamicWriteOnly)
{
_buffer = new XFG.DynamicVertexBuffer(_device, ( (XnaVertexDeclaration)vertexDeclaration ).XFGVertexDeclaration , numVertices, XnaHelper.Convert(usage));
}
else
_buffer = new XFG.VertexBuffer(_device, ( (XnaVertexDeclaration)vertexDeclaration ).XFGVertexDeclaration, numVertices, XnaHelper.Convert(usage));
_bufferBytes = new byte[ vertexDeclaration.GetVertexSize() * numVertices];
_bufferBytes.Initialize();
}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:18,代码来源:XnaHardwareVertexBuffer.cs
注:本文中的BufferUsage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论