コード例 #1
0
        public XnaHardwareVertexBuffer(HardwareBufferManagerBase manager, VertexDeclaration vertexDeclaration,
                                       int numVertices, BufferUsage usage, 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 DynamicVertexBuffer(_device,
                                                  ((XnaVertexDeclaration)vertexDeclaration).XFGVertexDeclaration,
                                                  numVertices, XnaHelper.Convert(usage));
            }
            else
            {
                _buffer = new VertexBuffer(_device, ((XnaVertexDeclaration)vertexDeclaration).XFGVertexDeclaration,
                                           numVertices, XnaHelper.Convert(usage));
            }

            _bufferBytes = new byte[vertexDeclaration.GetVertexSize() * numVertices];
            _bufferBytes.Initialize();
        }
コード例 #2
0
        public XnaHardwareVertexBuffer( HardwareBufferManagerBase manager, VertexDeclaration vertexDeclaration,
                                        int numVertices, BufferUsage usage, 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 DynamicVertexBuffer( _device,
                                                   ( (XnaVertexDeclaration)vertexDeclaration ).XFGVertexDeclaration,
                                                   numVertices, XnaHelper.Convert( usage ) );
            }
            else
            {
                _buffer = new VertexBuffer( _device, ( (XnaVertexDeclaration)vertexDeclaration ).XFGVertexDeclaration,
                                            numVertices, XnaHelper.Convert( usage ) );
            }

            _bufferBytes = new byte[vertexDeclaration.GetVertexSize()*numVertices];
            _bufferBytes.Initialize();
        }
コード例 #3
0
        public XnaHardwarePixelBuffer(BufferUsage usage)
            : base(0, 0, 0, PixelFormat.Unknown, usage, false, false)
        {
            device      = null;
            surface     = null;
            tempSurface = null;
#if !SILVERLIGHT
            volume     = null;
            tempVolume = null;
#endif
            doMipmapGen = false;
            HWMipmaps   = false;
            mipTex      = null;
            sliceTRT    = new List <RenderTexture>();
        }
コード例 #4
0
        public XnaHardwareIndexBuffer( HardwareBufferManagerBase manager, IndexType type, int numIndices, BufferUsage usage, GraphicsDevice device, bool useSystemMemory, bool useShadowBuffer )
            : base(manager, Validate(type), numIndices, usage, useSystemMemory, useShadowBuffer)
        {
            if (this.type == IndexType.Size16)
                _bufferType = IndexElementSize.SixteenBits;
#if !SILVERLIGHT
            else
                _bufferType = IndexElementSize.ThirtyTwoBits;
#endif

            // create the buffer
            if ( usage == BufferUsage.Dynamic || usage == BufferUsage.DynamicWriteOnly )
            {
                _xnaBuffer = new IndexBuffer( device, _bufferType, numIndices, XnaHelper.Convert( usage ) );
            }
            else
            {
                _xnaBuffer = new IndexBuffer( device, _bufferType, numIndices,
                                              Microsoft.Xna.Framework.Graphics.BufferUsage.None );
            }

            _bufferBytes = new byte[sizeInBytes];
            _bufferBytes.Initialize();
        }
コード例 #5
0
 ///<summary>
 ///</summary>
 ///<param name="width"></param>
 ///<param name="height"></param>
 ///<param name="depth"></param>
 ///<param name="format"></param>
 ///<param name="usage"></param>
 ///<param name="useSystemMemory"></param>
 ///<param name="useShadowBuffer"></param>
 public XnaHardwarePixelBuffer( int width, int height, int depth, PixelFormat format, BufferUsage usage, bool useSystemMemory, bool useShadowBuffer )
     : base( width, height, depth, format, usage, useSystemMemory, useShadowBuffer )
 {
 }
コード例 #6
0
        public XnaHardwarePixelBuffer( BufferUsage usage )
            : base( 0, 0, 0, PixelFormat.Unknown, usage, false, false )
        {
            device = null;
            surface = null;
            tempSurface = null;
#if !SILVERLIGHT
            volume = null;
            tempVolume = null;
#endif
            doMipmapGen = false;
            HWMipmaps = false;
            mipTex = null;
            sliceTRT = new List<RenderTexture>();
        }
コード例 #7
0
        public override HardwareVertexBuffer CreateVertexBuffer(VertexDeclaration vertexDeclaration, int numVerts, BufferUsage usage, bool useShadowBuffer)
        {
            var buffer = new XnaHardwareVertexBuffer(this, vertexDeclaration, numVerts, usage, _device, false, useShadowBuffer);

            lock (VertexBuffersMutex)
                vertexBuffers.Add(buffer);
            return(buffer);
        }
コード例 #8
0
        public override HardwareIndexBuffer CreateIndexBuffer(IndexType type, int numIndices, BufferUsage usage, bool useShadowBuffer)
        {
            var buffer = new XnaHardwareIndexBuffer(this, type, numIndices, usage, _device, false, useShadowBuffer);

            lock (IndexBuffersMutex)
                indexBuffers.Add(buffer);
            return(buffer);
        }
コード例 #9
0
 ///<summary>
 ///</summary>
 ///<param name="width"></param>
 ///<param name="height"></param>
 ///<param name="depth"></param>
 ///<param name="format"></param>
 ///<param name="usage"></param>
 ///<param name="useSystemMemory"></param>
 ///<param name="useShadowBuffer"></param>
 public XnaHardwarePixelBuffer(int width, int height, int depth, PixelFormat format, BufferUsage usage, bool useSystemMemory, bool useShadowBuffer)
     : base(width, height, depth, format, usage, useSystemMemory, useShadowBuffer)
 {
 }
コード例 #10
0
ファイル: XnaHelper.cs プロジェクト: WolfgangSt/axiom
		public static XFG.BufferUsage Convert( BufferUsage usage )
		{
			XFG.BufferUsage xnaUsage = 0;
			if ( usage == BufferUsage.Dynamic ||
				 usage == BufferUsage.DynamicWriteOnly )

				xnaUsage |= XFG.BufferUsage.WriteOnly;

			if ( usage == BufferUsage.WriteOnly ||
				 usage == BufferUsage.StaticWriteOnly ||
				 usage == BufferUsage.DynamicWriteOnly )

				xnaUsage |= XFG.BufferUsage.WriteOnly;

			return xnaUsage;
		}
コード例 #11
0
        public XnaHardwareIndexBuffer(HardwareBufferManagerBase manager, IndexType type, int numIndices, BufferUsage usage, GraphicsDevice device, bool useSystemMemory, bool useShadowBuffer)
            : base(manager, Validate(type), numIndices, usage, useSystemMemory, useShadowBuffer)
        {
            if (this.type == IndexType.Size16)
            {
                _bufferType = IndexElementSize.SixteenBits;
            }
#if !SILVERLIGHT
            else
            {
                _bufferType = IndexElementSize.ThirtyTwoBits;
            }
#endif

            // create the buffer
            if (usage == BufferUsage.Dynamic || usage == BufferUsage.DynamicWriteOnly)
            {
                _xnaBuffer = new IndexBuffer(device, _bufferType, numIndices, XnaHelper.Convert(usage));
            }
            else
            {
                _xnaBuffer = new IndexBuffer(device, _bufferType, numIndices,
                                             Microsoft.Xna.Framework.Graphics.BufferUsage.None);
            }

            _bufferBytes = new byte[sizeInBytes];
            _bufferBytes.Initialize();
        }
コード例 #12
0
 public override HardwareVertexBuffer CreateVertexBuffer( VertexDeclaration vertexDeclaration, int numVerts, BufferUsage usage, bool useShadowBuffer )
 {
     var buffer = new XnaHardwareVertexBuffer( this, vertexDeclaration, numVerts, usage, _device, false, useShadowBuffer );
     lock ( VertexBuffersMutex )
         vertexBuffers.Add( buffer );
     return buffer;
 }
コード例 #13
0
 public override HardwareIndexBuffer CreateIndexBuffer( IndexType type, int numIndices, BufferUsage usage, bool useShadowBuffer )
 {
     var buffer = new XnaHardwareIndexBuffer( this, type, numIndices, usage, _device, false, useShadowBuffer );
     lock ( IndexBuffersMutex )
         indexBuffers.Add( buffer );
     return buffer;
 }
コード例 #14
0
        public GLES2HardwareIndexBuffer(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);
            GLES2Config.GlCheckError(this);
            if (this._bufferId == 0)
            {
                throw new AxiomException("Cannot create GL index buffer");
            }

            OpenGL.BindBuffer(All.ElementArrayBuffer, this._bufferId);
            GLES2Config.GlCheckError(this);
            OpenGL.BufferData(All.ElementArrayBuffer, new IntPtr(sizeInBytes), IntPtr.Zero, GLES2HardwareBufferManager.GetGLUsage(usage));
            GLES2Config.GlCheckError(this);
        }