private static void Update() { if (Input.Keys(Key.Tab)) { if (activeFractalTimer.Ready()) { activeFractal = activeFractal == Fractal.FractalType.Mandelbrot ? Fractal.FractalType.Julia : Fractal.FractalType.Mandelbrot; activeFractalTimer.Reset(); } } if (Input.Keys(Key.B)) { if (fractalsToRenderTimer.Ready()) { int f = (int)(fractalsToRender) + 1; f %= 3; fractalsToRender = (FractalsToRender)f; fractalsToRenderTimer.Reset(); } } if (activeFractal == Fractal.FractalType.Mandelbrot) { HandleKeys(mandelbrot); } else { HandleKeys(julia); } float clr_amt = GameTime.DeltaTime / 1000 * (Input.Keys(Key.LeftShift) ? 1 : -1); if (Input.Keys(Key.Z)) { mandelbrot.clrRatio.R += clr_amt; julia.clrRatio.R += clr_amt; } if (Input.Keys(Key.X)) { mandelbrot.clrRatio.G += clr_amt; julia.clrRatio.G += clr_amt; } if (Input.Keys(Key.C)) { mandelbrot.clrRatio.B += clr_amt; julia.clrRatio.B += clr_amt; } if (Input.Keys(Key.J)) { mandelbrot.rot -= GameTime.DeltaTime / 200; julia.rot -= GameTime.DeltaTime / 200; } if (Input.Keys(Key.L)) { mandelbrot.rot += GameTime.DeltaTime / 200; julia.rot += GameTime.DeltaTime / 200; } if (Input.Keys(Key.One)) { julia.SetMode(Fractal.Mode.Normal); } if (Input.Keys(Key.Two)) { julia.SetMode(Fractal.Mode.Reciprocal); } if (Input.Keys(Key.Three)) { julia.SetMode(Fractal.Mode.SquaredReciprocal); } if (Input.Keys(Key.Four)) { julia.SetMode(Fractal.Mode.t1); } if (Input.Keys(Key.Five)) { julia.SetMode(Fractal.Mode.t2); } if (Input.Keys(Key.Six)) { julia.SetMode(Fractal.Mode.t3); } if (Input.Keys(Key.Escape)) { Glfw.SetWindowShouldClose(window, true); } if (Input.Keys(Key.F1)) { if (screenshotTimer.Ready()) { screenshotTimer.Reset(); SaveScreenshot(); } } switch (fractalsToRender) { case FractalsToRender.Mandelbrot: mandelbrot.quad.pos = Vector2.Zero; mandelbrot.quad.model.size = new Vector2(1, 1); julia.quad.model.size = Vector2.Zero; activeFractal = Fractal.FractalType.Mandelbrot; break; case FractalsToRender.Julia: julia.quad.pos = Vector2.Zero; julia.quad.model.size = new Vector2(1, 1); mandelbrot.quad.model.size = Vector2.Zero; activeFractal = Fractal.FractalType.Julia; break; case FractalsToRender.MandelbrotJulia: mandelbrot.quad.pos = new Vector2(-0.5f, 0f); mandelbrot.quad.model.size = new Vector2(0.5f, 1); julia.quad.pos = new Vector2(0.5f, 0f); julia.quad.model.size = new Vector2(0.5f, 1f); break; } }
private static void Init() { shader = new ShaderProgram("Assets/Shaders/Shader.vert", "Assets/Shaders/Shader.frag"); shader.AddUniform("vposoffset"); shader.AddUniform("vsize"); shader.AddUniform("aspectRatio"); shader.AddUniform("rot"); shader.AddUniform("maxIter"); shader.AddUniform("clrRatio"); shader.AddUniform("cursorClr"); shader.AddUniform("julia_mode"); shader.AddUniform("crosshair"); shader.AddUniform("fractalType"); shader.AddUniform("julia_c"); shader.AddUniform("pos"); shader.AddUniform("zoom"); //guishader = new ShaderProgram("Asset/Shaders/Gui.vert", "Asset/Shaders/Gui.frag"); //guishader.AddUniform("pos"); //guishader.AddUniform("size"); try { Serialization.FractalPair pair = Serialization.Load(); mandelbrot = pair.mandelbrot; julia = pair.julia; activeFractal = pair.activeFractal; fractalsToRender = pair.fractalsToRender; // ScreenshotCount = pair.screenshotCount; ScreenshotCount = 0; } catch (Exception) { mandelbrot = Fractal.CreateMandelbrot(); julia = Fractal.CreateJulia(); } mandelbrot.Load(); julia.Load(); activeFractalTimer = new CooldownTimer(60); activeFractalTimer.SetTime(activeFractalTimer.GetCooldown()); screenshotTimer = new CooldownTimer(20); fractalsToRenderTimer = new CooldownTimer(20); if (!view) { mandelbrot.pos = new Vector2d(-0.129078142625295, 0.98765122402576); mandelbrot.maxIter = 2000; fractalsToRender = FractalsToRender.Mandelbrot; mandelbrot.crosshair = false; mandelbrot.zoom = 4; } else { //Random rand = new Random(); //mandelbrot.pos = new Vector2d(rand.NextDouble() * 2 - 1, rand.NextDouble() * 2 - 1); //mandelbrot.zoom = 2; } // mandelbrot.zoom = 1E-10; }