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