當前位置: 首頁>>代碼示例>>C#>>正文


C# SamplerState.ApplyTo方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.SamplerState.ApplyTo方法的典型用法代碼示例。如果您正苦於以下問題:C# SamplerState.ApplyTo方法的具體用法?C# SamplerState.ApplyTo怎麽用?C# SamplerState.ApplyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.SamplerState的用法示例。


在下文中一共展示了SamplerState.ApplyTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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.ApplyTo(TextureTarget.Texture2D);
                }
                // 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:jbekkedal,項目名稱:MonoGame,代碼行數:61,代碼來源:SpriteBatcher.cs


注:本文中的Microsoft.Xna.Framework.Graphics.SamplerState.ApplyTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。