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


C# BufferUsage类代码示例

本文整理汇总了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 );
			}
		}
开发者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


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