本文整理汇总了C#中BufferUsage类的典型用法代码示例。如果您正苦于以下问题:C# BufferUsage类的具体用法?C# BufferUsage怎么用?C# BufferUsage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BufferUsage类属于命名空间,在下文中一共展示了BufferUsage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
}
示例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 );
}
示例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;
}
示例4: IndexBuffer
public IndexBuffer(Device device, BufferUsage usage)
{
this.device = device;
this.usage = usage;
Gl.glGenBuffersARB(1, out this.handle);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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 );
}
示例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 ] );
}
}
}
示例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];
}
示例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;
}
}
示例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);
}
示例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 );
}
示例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();
}