public static void Draw() { if (instances == null || instances.Count == 0) { return; } Game.Device.Rasterizer.State = rs; spriteDrawer.Begin(SpriteFlags.SaveState); foreach (KeyValuePair <String, CustomSpriteInstance> entry in instances) { CustomSpriteInstance i = instances[entry.Key]; if (i.enabled == false) { continue; } if (i.blendMode == SpriteBlendMode.Additive) { Game.Device.OutputMerger.BlendState = bsAdditive; } else { Game.Device.OutputMerger.BlendState = bsAlphaBlend; } spriteDrawer.DrawImmediate(new CustomSpriteInstance[] { i }); } spriteDrawer.End(); }
public static void AddInstance(string instanceName, ShaderResourceView srv, Vector2 pos, Color4 c, float s, SpriteBlendMode mode) { Matrix m = Matrix.Scaling(s, s, s) * Matrix.Translation(pos.X, pos.Y, 0); if (instances.ContainsKey(instanceName)) { instances[instanceName].Color = c; instances[instanceName].Transform = m; instances[instanceName].blendMode = mode; } else { CustomSpriteInstance si = new CustomSpriteInstance(srv, coordiantes, dimensions); si.Color = c; si.Transform = m; si.blendMode = mode; instances.Add(instanceName, si); } }