Пример #1
0
        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();
        }
Пример #2
0
        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();
        }
        public void Begin()
        {
            // Save old state
            _oldDepthState         = _device.DepthState;
            _oldFaceCullingEnabled = _device.FaceCullingEnabled;
            _oldBlendState         = _device.BlendState;

            // Set new state
            _device.DepthState         = DepthState.None;
            _device.FaceCullingEnabled = false;
            _device.BlendState         = BlendState.AlphaBlend;

            _batch.Begin();
        }
Пример #4
0
        public void Begin(Matrix3x2?transform, TextureFiltering textureFiltering)
        {
            // Save old state
            _oldDepthState         = _device.DepthState;
            _oldFaceCullingEnabled = _device.FaceCullingEnabled;
            _oldBlendState         = _device.BlendState;
            _oldScissorEnabled     = _device.ScissorTestEnabled;

            // Set new state
            _device.DepthState         = DepthState.None;
            _device.FaceCullingEnabled = false;
            _device.BlendState         = BlendState.AlphaBlend;
            _device.ScissorTestEnabled = true;

            _batch.Begin();

            _beginCalled = true;
            _transform   = transform;
            _filtering   = textureFiltering;
        }