Example #1
0
 public override void Draw(GameTime gameTime)
 {
     if (TestGame.gameState == TestGame.GameState.Game)
     {
         if (levelState == LevelState.Active)
         {
             shader.Render();
         }
         background.Draw(spriteBatch);
         DrawLevel(spriteBatch);
         DrawText(spriteBatch);
         if (levelState == LevelState.Active)
         {
             shader.Draw(spriteBatch);
         }
     }
 }
Example #2
0
        public override void Show(Main D)
        {
            Controller.projectionMatrix = projectionMatrix;
            Controller.Draw();

            if (OrbitActive)
            {
                GL.Enable(EnableCap.StencilTest);
                GL.StencilMask(~0);
                GL.ClearStencil(0);
                GL.Clear(ClearBufferMask.StencilBufferBit);

                GL.StencilFunc(StencilFunction.Always, 1, ~0);
                GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);


                GL.ColorMask(false, false, false, false);
                GL.DepthMask(false);
                GL.Rect(0, 0, Rect.Width, Rect.Height);
                GL.ColorMask(true, true, true, true);
                GL.DepthMask(true);
                GL.StencilFunc(StencilFunction.Equal, 1, ~0);
                GL.StencilMask(0);
                fractalMath.CoefficientArray = Controller.CoefficientArray;
                int       PathLength = 30;
                Complex[] Path       = new Complex[PathLength];
                Vector2[] WorldPath  = new Vector2[PathLength];
                Complex   Z;
                Complex   C;
                if (Controller.Julia)
                {
                    Z = OrbitPosition;
                    C = Controller.JuliaPos;
                    fractalMath.SetCoefficients(C);
                }
                else
                {
                    Z = new Complex(0, 0);
                    C = OrbitPosition;
                    fractalMath.SetCoefficients(C);
                    Z = fractalMath.Compute(Z);
                }

                for (int i = 0; i < PathLength; i++)
                {
                    Path[i]      = Z;
                    WorldPath[i] = GetScreenFromWorld(Z);
                    Z            = fractalMath.Compute(Z);
                    if (Z.MagSq() > 100)
                    {
                        PathLength = i + 1;
                        break;
                    }
                }
                GL.LineWidth(OrbitScale * 2);
                GL.Color3(Color.White);
                GL.Enable(EnableCap.LineStipple);
                LineStrippleOffset <<= 1;
                if ((LineStrippleOffset & 256) > 0)
                {
                    LineStrippleOffset++;
                }
                GL.LineStipple(StrippleScale, LineStrippleOffset);
                for (int i = 0; i < PathLength - 1; i++)
                {
                    GL.Begin(PrimitiveType.Lines);
                    GL.Vertex2(WorldPath[i]);
                    GL.Vertex2(WorldPath[i + 1]);
                    GL.End();
                }
                GL.Disable(EnableCap.LineStipple);
                Vector2 V1 = new Vector2(3, 0) * OrbitScale;
                Vector2 V2 = new Vector2(0, 3) * OrbitScale;
                GL.Begin(PrimitiveType.Quads);
                for (int i = 0; i < PathLength; i++)
                {
                    GL.Color3(Color.Gray);
                    GL.Vertex2(WorldPath[i] + V1 * 1.5f);
                    GL.Vertex2(WorldPath[i] + V2 * 1.5f);
                    GL.Vertex2(WorldPath[i] - V1 * 1.5f);
                    GL.Vertex2(WorldPath[i] - V2 * 1.5f);
                    GL.Color3(Color.Orange);
                    GL.Vertex2(WorldPath[i] + V1);
                    GL.Vertex2(WorldPath[i] + V2);
                    GL.Vertex2(WorldPath[i] - V1);
                    GL.Vertex2(WorldPath[i] - V2);
                }
                GL.End();



                GL.Disable(EnableCap.StencilTest);
            }
        }