public BitmapBatch GetBitmapBatch(int?layer, bool?worldSpace, BlendState blendState, SamplerState samplerState) { if (Materials == null) { throw new InvalidOperationException("You cannot use the argumentless ImperativeRenderer constructor."); } var actualLayer = layer.GetValueOrDefault(Layer); var actualWorldSpace = worldSpace.GetValueOrDefault(WorldSpace); var desiredBlendState = blendState ?? BlendState; var desiredSamplerState = samplerState ?? SamplerState; CachedBatch cacheEntry; if (!Cache.TryGet <BitmapBatch>( out cacheEntry, container: Container, layer: actualLayer, worldSpace: actualWorldSpace, rasterizerState: RasterizerState, depthStencilState: DepthStencilState, blendState: desiredBlendState, samplerState: desiredSamplerState, useZBuffer: UseZBuffer )) { var material = Materials.GetBitmapMaterial( actualWorldSpace, RasterizerState, DepthStencilState, desiredBlendState ); cacheEntry.Batch = BitmapBatch.New(Container, actualLayer, material, desiredSamplerState, desiredSamplerState, UseZBuffer); Cache.InsertAtFront(ref cacheEntry, null); } if (AutoIncrementLayer && !layer.HasValue) { Layer += 1; } return((BitmapBatch)cacheEntry.Batch); }
public IBitmapBatch GetBitmapBatch(int?layer, bool?worldSpace, BlendState blendState, SamplerState samplerState, Material customMaterial) { if (Materials == null) { throw new InvalidOperationException("You cannot use the argumentless ImperativeRenderer constructor."); } var actualLayer = layer.GetValueOrDefault(Layer); var actualWorldSpace = worldSpace.GetValueOrDefault(WorldSpace); var desiredBlendState = blendState ?? BlendState; var desiredSamplerState = samplerState ?? SamplerState; if (LowPriorityMaterialOrdering) { desiredSamplerState = null; } CachedBatch cacheEntry; if (!Cache.TryGet <IBitmapBatch>( out cacheEntry, LowPriorityMaterialOrdering ? CachedBatchType.MultimaterialBitmap : CachedBatchType.Bitmap, container: Container, layer: actualLayer, worldSpace: actualWorldSpace, rasterizerState: RasterizerState, depthStencilState: DepthStencilState, blendState: desiredBlendState, samplerState: desiredSamplerState, customMaterial: customMaterial, useZBuffer: UseZBuffer )) { Material material; if (customMaterial != null) { material = Materials.Get( customMaterial, RasterizerState, DepthStencilState, desiredBlendState ); } else { material = Materials.GetBitmapMaterial( actualWorldSpace, RasterizerState, DepthStencilState, desiredBlendState ); } IBitmapBatch bb; if (LowPriorityMaterialOrdering) { bb = MultimaterialBitmapBatch.New(Container, actualLayer, Material.Null, UseZBuffer); } else { bb = BitmapBatch.New(Container, actualLayer, material, desiredSamplerState, desiredSamplerState, UseZBuffer); } bb.Sorter = DeclarativeSorter; cacheEntry.Batch = bb; Cache.InsertAtFront(ref cacheEntry, null); } if (AutoIncrementLayer && !layer.HasValue) { Layer += 1; } return((IBitmapBatch)cacheEntry.Batch); }