當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。