public BasicMaterial(GraphicsDevice graphics) { effect = GraphicsResources <BasicEffect> .GetInstance(graphics, typeof(BasicMaterial)); pass = effect.CurrentTechnique.Passes[0]; GraphicsDevice = graphics; }
public AlphaTestMaterial(GraphicsDevice graphics) { GraphicsDevice = graphics; effect = GraphicsResources <AlphaTestEffect> .GetInstance(graphics, typeof(AlphaTestMaterial)); effect.ReferenceAlpha = Constants.ReferenceAlpha; }
public TextureMaterial(GraphicsDevice graphics) { effect = GraphicsResources <BasicEffect> .GetInstance(graphics, typeof(TextureMaterial)); effect.LightingEnabled = false; pass = effect.CurrentTechnique.Passes[0]; GraphicsDevice = graphics; }
/// <summary> /// The main constructor for the class. /// </summary> public FrameRate(GraphicsDevice graphics, SpriteFont font) { this.Font = font; this.GraphicsDevice = graphics; this.UpdateFrequency = TimeSpan.FromSeconds(1); this.Color = new Color(255, 255, 0, 255); this.Visible = true; this.Scale = 1; this.spriteBatch = GraphicsResources <SpriteBatch> .GetInstance(GraphicsDevice); }
public void Draw(float elapsedTime) { if (Font == null) { return; } SpriteBatch spriteBatch = GraphicsResources <SpriteBatch> .GetInstance(GraphicsDevice); spriteBatch.Begin(); const int Border = 8; // Compute number of lines to be rendered int height = (int)(FontSize + LineSpacing); int lineCount = messages.Count + 1; if (lineCount > MaxLines) { lineCount = MaxLines; } // Use Graphics.Clear to draw a background quad int y = GraphicsDevice.PresentationParameters.BackBufferHeight - lineCount * height - Border; // Draw text float fontScale = 1.0f * FontSize / (Font.MeasureString("A").Y - 10); int i = messages.Count - (lineCount - 1); if (i < 0) { i = 0; } for (; i < messages.Count; ++i) { spriteBatch.DrawString( Font, messages[i], new Vector2(Border + 2, y), ForegroundColor, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); y += height; } // Update text cursor currentBlinkTime += elapsedTime; if (currentBlinkTime > CursorBlinkInterval) { currentBlinkTime = -CursorBlinkInterval; } // Draw last line and text cursor // FIXME: Timing not working when game is paused if (currentBlinkTime < 0) { spriteBatch.DrawString( Font, lastLine, new Vector2(Border + 2, y), ForegroundColor, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); } else { spriteBatch.DrawString( Font, lastLine + CursorText, new Vector2(Border + 2, y), ForegroundColor, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); } spriteBatch.End(); }
public DualTextureMaterial(GraphicsDevice graphics) { GraphicsDevice = graphics; effect = GraphicsResources <DualTextureEffect> .GetInstance(graphics, typeof(DualTextureMaterial)); }
public SkinnedMaterial(GraphicsDevice graphics) { GraphicsDevice = graphics; effect = GraphicsResources <SkinnedEffect> .GetInstance(graphics, typeof(SkinnedMaterial)); }
private static SpriteBatch PrepareSprite(GraphicsDevice graphics, Effect effect) { SetViewport(effect as IEffectMatrices, graphics.Viewport.Bounds); return(GraphicsResources <SpriteBatch> .GetInstance(graphics)); }
public SpriteBatchRenderer(GraphicsDevice graphics) : base(graphics) { spriteBatch = GraphicsResources <SpriteBatch> .GetInstance(graphics); }
public EnvironmentMapMaterial(GraphicsDevice graphics) { GraphicsDevice = graphics; effect = GraphicsResources <EnvironmentMapEffect> .GetInstance(graphics, typeof(EnvironmentMapMaterial)); }
public static void Draw(this SpriteBatch spriteBatch, Rectangle rect, Color color) { var texture = GraphicsResources <BlankTexture> .GetInstance(spriteBatch.GraphicsDevice); spriteBatch.Draw(texture.Texture, rect, color); }
public static void Draw(this SpriteBatch spriteBatch, Vector2 position, Vector2 scale, float rotation, Color color) { var texture = GraphicsResources <BlankTexture> .GetInstance(spriteBatch.GraphicsDevice); spriteBatch.Draw(texture.Texture, position, null, color, rotation, Vector2.Zero, scale, SpriteEffects.None, 0); }