private static void Render(Fractal fractal) { Model model = fractal.quad.model; GL.UseProgram(shader.id); GL.BindVertexArray(model.vao.ID); shader.SetUniform2f("vposoffset", fractal.quad.pos); shader.SetUniform2f("vsize", fractal.quad.model.size); shader.SetUniform1f("aspectRatio", (float)width / height); shader.SetUniform4m("rot", Matrix.CreateRotationZ(fractal.rot)); shader.SetUniform1i("maxIter", (int)fractal.maxIter); shader.SetUniform4c("clrRatio", fractal.clrRatio); if (activeFractal == fractal.fractalType) { float factor = activeFractalTimer.GetTime() / activeFractalTimer.GetCooldown(); if (factor > 1) { factor = 1; } shader.SetUniform3f("cursorClr", new Vector3(factor, factor, factor)); } else { shader.SetUniform3f("cursorClr", new Vector3(1f, 1f, 1f)); } shader.SetUniform1b("crosshair", fractal.crosshair); shader.SetUniform1i("julia_mode", (int)fractal.mode); shader.SetUniform1i("fractalType", (int)fractal.fractalType); if (fractal.fractalType == Fractal.FractalType.Mandelbrot) { shader.SetUniform2d("julia_c", fractal.pos); } shader.SetUniform2d("pos", fractal.pos); shader.SetUniform1d("zoom", fractal.zoom); GL.DrawElements(model.drawmode, model.vao.count, DrawElementsType.UnsignedInt, 0); GL.BindVertexArray(0); GL.UseProgram(0); }
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; }