protected override void OnRender(double dt) { float time = (float)stopwatch.Elapsed.TotalSeconds; graphicsDevice.Clear(ClearBufferMask.ColorBufferBit); Vector2 mousePos = new Vector2(InputContext.Mice[0].Position.X, InputContext.Mice[0].Position.Y); textureBatcher.Begin(BatcherBeginMode.OnTheFly); float loreIpsumScale = 1 + 0.1f * MathF.Sin(time * 4.32f); textureBatcher.DrawString(arialFont, loremIpsum, new Vector2(50, 25), Color4b.White, loreIpsumScale, Vector2.Zero); string comicText = "You can draw text!!\nIt's very nice :)"; Vector2 comicTextSize = comicSansFont.Measure(comicText); Color4b comicTextColor = Color4b.FromHSV(time % 1, 1f, 1f); float comicTextScale = 1 + 0.1f * MathF.Sin(time); float comicTextRot = 0.3f * MathF.Sin(time * 4.32f); textureBatcher.DrawString(comicSansFont, comicText, new Vector2(500, 610), comicTextColor, comicTextScale, comicTextRot, comicTextSize / 2f); foreach (Particle particle in particles) { particle.Draw(textureBatcher); } for (int i = 0; i < diamonds.Length; i++) { diamonds[i].Draw(textureBatcher); } for (int i = 0; i < balls.Length; i++) { balls[i].Draw(textureBatcher); } textureBatcher.End(); textureBatcher.Begin(BatcherBeginMode.SortBackToFront); Vector2 rectOrigin = new Vector2(rectangleTexture.Width / 2f, rectangleTexture.Height / 2f); const float meh = 100; const int times = 6; for (float x = -meh * times; x <= meh * times; x += meh) { for (float y = -meh * times; y <= meh * times; y += meh) { float dist = Math.Abs(x) + Math.Abs(y); byte alpha = (byte)Math.Max(0, 255 - (3f / times) * dist); float dep = dist / 500f; float sc = dist / meh * 0.175f; sc = 1 - sc * sc; Vector2 pos = mousePos + new Vector2(MathF.Sign(x), MathF.Sign(y)) * Vector2.SquareRoot(new Vector2(MathF.Abs(x), MathF.Abs(y)) / meh) * meh; textureBatcher.Draw(rectangleTexture, pos, null, new Color4b(255, 255, 255, alpha), sc, time, rectOrigin, dep); } } textureBatcher.End(); Window.SwapBuffers(); }
public void End() { _batch.End(); // Restore old state _device.DepthState = _oldDepthState; _device.FaceCullingEnabled = _oldFaceCullingEnabled; _device.BlendState = _oldBlendState; }
public void End() { _batch.End(); _beginCalled = false; // Restore old state _device.DepthState = _oldDepthState; _device.FaceCullingEnabled = _oldFaceCullingEnabled; _device.BlendState = _oldBlendState; _device.ScissorTestEnabled = _oldScissorEnabled; }
protected override void OnRender(double dt) { graphicsDevice.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.DepthBufferBit); // _desktop.Render(); _batch.Begin(); _batch.Draw(_white, new Vector2(0, 0), null, Color4b.Red, 100, 0); _batch.End(); Window.SwapBuffers(); }