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


C# SamplerState.Activate方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SamplerState.Activate方法的典型用法代码示例。如果您正苦于以下问题:C# SamplerState.Activate方法的具体用法?C# SamplerState.Activate怎么用?C# SamplerState.Activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.SamplerState的用法示例。


在下文中一共展示了SamplerState.Activate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawBatchGL11

        public void DrawBatchGL11( SpriteSortMode sortMode, SamplerState samplerState )
        {
            // nothing to do
            if ( _batchItemList.Count == 0 )
                return;

            // sort the batch items
            switch ( sortMode )
            {
            case SpriteSortMode.Texture :
                throw new NotSupportedException();
                //_batchItemList.Sort( CompareTexture );
            case SpriteSortMode.FrontToBack :
                throw new NotSupportedException();
                //_batchItemList.Sort ( CompareDepth );
            case SpriteSortMode.BackToFront :
                throw new NotSupportedException();
                //_batchItemList.Sort ( CompareReverseDepth );
            }

            // make sure an old draw isn't still going on.
            // cross fingers, commenting this out!!
            //GL.Flush();

            // make sure the vertexArray has enough space
            if ( _batchItemList.Count*6 > _index.Length )
                ExpandIndexArray( _batchItemList.Count );

            LinkVertexArray();

            int size = sizeof(float)*4+sizeof(uint);
            GL11.VertexPointer(2,ALL11.Float,size,_vertexHandle.AddrOfPinnedObject() );
            GL11.ColorPointer(4, ALL11.UnsignedByte,size,(IntPtr)((uint)_vertexHandle.AddrOfPinnedObject()+(uint)(sizeof(float)*2)));
            GL11.TexCoordPointer(2, ALL11.Float,size,(IntPtr)((uint)_vertexHandle.AddrOfPinnedObject()+(uint)(sizeof(float)*2+sizeof(uint))) );

            // setup the vertexArray array
            int startIndex = 0;
            int index = 0;
            int texID = -1;

            foreach ( SpriteBatchItem item in _batchItemList )
            {
                // if the texture changed, we need to flush and bind the new texture
                if ( item.TextureID != texID )
                {
                    FlushVertexArrayGL11( startIndex, index );
                    startIndex = index;
                    texID = item.TextureID;
                    GL11.BindTexture ( ALL11.Texture2D, texID );

                    samplerState.Activate();
                }
                // store the SpriteBatchItem data in our vertexArray
                index += 4;
            }
            // flush the remaining vertexArray data
            FlushVertexArrayGL11(startIndex, index);

            _batchItemList.Clear();
            _vertexArray.Clear();
        }
开发者ID:ncoder,项目名称:MonoGame,代码行数:61,代码来源:SpriteBatcher.cs

示例2: DrawBatch

		public void DrawBatch ( SpriteSortMode sortMode, SamplerState samplerState )
		{
			// nothing to do
			if ( _batchItemList.Count == 0 )
				return;
			
			// sort the batch items
			switch ( sortMode )
			{
			case SpriteSortMode.Texture :
				_batchItemList.Sort( CompareTexture );
				break;
			case SpriteSortMode.FrontToBack :
				_batchItemList.Sort ( CompareDepth );
				break;
			case SpriteSortMode.BackToFront :
				_batchItemList.Sort ( CompareReverseDepth );
				break;
			}
			
			int size = sizeof(float)*4 + sizeof(uint);
			
			GL.VertexPointer(2, VertexPointerType.Float,size,_vertexHandle.AddrOfPinnedObject() );
			GL.ColorPointer(4, ColorPointerType.UnsignedByte,size,(IntPtr)((UInt64)_vertexHandle.AddrOfPinnedObject()+sizeof(float)*2));
			GL.TexCoordPointer(2, TexCoordPointerType.Float,size,(IntPtr)((UInt64)_vertexHandle.AddrOfPinnedObject()+sizeof(float)*2+sizeof(uint)) );			
			
			// setup the vertexArray array
			int startIndex = 0;
			int index = 0;
			int texID = -1;

			// make sure the vertexArray has enough space
			if ( _batchItemList.Count*4 > _vertexArray.Length )
				ExpandVertexArray( _batchItemList.Count );
			
			foreach ( SpriteBatchItem item in _batchItemList )
			{
				// if the texture changed, we need to flush and bind the new texture
				if ( item.TextureID != texID )
				{
					FlushVertexArray( startIndex, index );
					startIndex = index;
					texID = item.TextureID;

					GL.ActiveTexture(TextureUnit.Texture0);
					GL.BindTexture ( TextureTarget.Texture2D, texID );

					samplerState.Activate ();
				}
				// store the SpriteBatchItem data in our vertexArray
				_vertexArray[index++] = item.vertexTL;
				_vertexArray[index++] = item.vertexTR;
				_vertexArray[index++] = item.vertexBL;
				_vertexArray[index++] = item.vertexBR;
				
				_freeBatchItemQueue.Enqueue ( item );				
			}
			// flush the remaining vertexArray data
			FlushVertexArray(startIndex, index);
			_batchItemList.Clear();
		}
开发者ID:adison,项目名称:Tank-Wars,代码行数:61,代码来源:SpriteBatcher.cs

示例3: DrawBatch

        public void DrawBatch( SpriteSortMode sortMode, SamplerState samplerState )
        {
            // nothing to do
            if ( _batchItemList.Count == 0 )
                return;

            // sort the batch items
            switch ( sortMode )
            {
            case SpriteSortMode.Texture :
                _batchItemList.Sort( CompareTexture );
                break;
            case SpriteSortMode.FrontToBack :
                _batchItemList.Sort ( CompareDepth );
                break;
            case SpriteSortMode.BackToFront :
                _batchItemList.Sort ( CompareReverseDepth );
                break;
            }

            GL.EnableVertexAttribArray(attributePosition);
            GL.EnableVertexAttribArray(attributeTexCoord);

            int size = VertexPosition2ColorTexture.GetSize();
            GL.VertexAttribPointer(attributePosition,2,VertexAttribPointerType.Float,false,size,_vertexHandle.AddrOfPinnedObject());
            GL.VertexAttribPointer(attributeTexCoord,2,VertexAttribPointerType.Float,false,size,(IntPtr)((uint)_vertexHandle.AddrOfPinnedObject()+(uint)(sizeof(float)*2+sizeof(uint))));
            //GL.VertexAttribPointer(
            // setup the vertexArray array
            int startIndex = 0;
            int index = 0;
            int texID = -1;
            // store last tint color
            Color lastTint =  new Color(0.0f,0.0f,0.0f,0.0f);

            // make sure the vertexArray has enough space
            if ( _batchItemList.Count*4 > _vertexArray.Length )
                ExpandVertexArray( _batchItemList.Count );

            foreach ( SpriteBatchItem item in _batchItemList )
            {
                //Tint Color
                Vector4 vtint = item.Tint.ToVector4();
                //vtint /= 255;
                //GL20.VertexAttrib4(attributeTint, vtint.X, vtint.Y, vtint.Z, vtint.W);

                // if the texture changed, we need to flush and bind the new texture
                if ( item.TextureID != texID || item.Tint != lastTint)
                {
                    FlushVertexArrayGL20( startIndex, index );
                    startIndex = index;
                    texID = item.TextureID;
                    lastTint = item.Tint;

                    GL.ActiveTexture(TextureUnit.Texture0);
                    GL.BindTexture ( TextureTarget.Texture2D, texID );
                    //GL.Uniform1(texID, 0);
                    GL.VertexAttrib4(attributeTint,vtint.X, vtint.Y, vtint.Z, vtint.W);

                    samplerState.Activate();
                }
                // store the SpriteBatchItem data in our vertexArray
                _vertexArray[index++] = item.vertexTL;
                _vertexArray[index++] = item.vertexTR;
                _vertexArray[index++] = item.vertexBL;
                _vertexArray[index++] = item.vertexBR;

                _freeBatchItemQueue.Enqueue ( item );
            }
            // flush the remaining vertexArray data
            FlushVertexArrayGL20(startIndex, index);

            _batchItemList.Clear();
        }
开发者ID:noxo,项目名称:MonoGame,代码行数:73,代码来源:SpriteBatcher.cs


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