Newton's Fractal Curve: Rendering to OpenGL Win 10 Thanx iLya2IK lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2024-08-02 10:52 Here is a Newton's Fractal Curve Maker on a TPaintbox. It's a bit slow on the rendering. I wonder how it could be rendered much more quickly? Possibly (Bgrabmp) When colour changing with the TColorbutton it refreshes. When changing the 2 TSpinedits please use the refresh button after making changes. I found the Mods in the curve by experimenting. I wonder if anyone knows of any other interesting ways to color it? The last reddish attached png is sort of like a "Lost in a Universe type pic." ---------------------------------------------------------------------- Boleeman · 2024-08-02 11:00 I used a different way to colour and got some colour splitting, but it was not consistently splitting up into many colours for different TColorbutton colour choices. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.PaintBox1Paint(Sender: TObject);const  max = 1e6;  min = 1e-6;var  z, t, d: Complex;  p: Real;  x, y, n, iter: Integer;  mx, my: Integer;  baseColor: TColor;  r, g, b: Byte;  col: TColor;begin  mx := PaintBox1.Width div 2;  my := PaintBox1.Height div 2;   baseColor := ColorButton1.ButtonColor;  r := Red(baseColor);  g := Green(baseColor);  b := Blue(baseColor);   iter := seRecursion.Value;   for y := -my to my do    for x := -mx to mx do  begin      n := 0;      z.x := x * 0.005;      z.y := y * 0.005;      d := z;      while (sqr(z.x) + sqr(z.y) < max) and (sqr(d.x) + sqr(d.y) > min) and (n < iter) do      begin        t := z;        {z^3 - 1}        p := sqr(sqr(t.x) + sqr(t.y));        if p = 0 then        break;        z.x := 2 / 3 * t.x + (sqr(t.x) - sqr(t.y)) / (seCoeffPonZX.value * p);        z.y := 2 / 3 * t.y * (1 - t.x / p);      d.x := abs(t.x - z.x);        d.y := abs(t.y - z.y);        Inc(n);      end;       col := RGBToColor((r * n) mod 255, (g * n) mod 255, (b * n) mod 255);      if (r * n mod 255 = 0) and (g * n mod 255 = 0) and (b * n mod 255 = 0) then        col := baseColor;      PaintBox1.Canvas.Pixels[mx + x, my + y] := col;    end;end; ---------------------------------------------------------------------- iLya2IK · 2024-08-06 09:01 I love fractals. I tried to do something similar using opengl (glsl) ---------------------------------------------------------------------- Boleeman · 2024-08-06 11:17 Thanks iLya2IK for your OpenGL fractal code example. I tried it, but get an error as the form loads up. GL Framebuffer error 36062 I tried compiling on an Intel and on an AMD CPU laptop (each running Windows 10). Perhaps I have the older version of OpenGL or need to compile on Linux ? Not sure. iLya2IK. I appreciate your upload. Always wanted to learn more about openGL and it's possibilites. ---------------------------------------------------------------------- circular · 2024-08-06 11:43 Indeed, using OpenGL could help. If each pixel can be translated into a simple algorithm in C shader language, then this can be implemented using TBGLFullCanvasShader class. This is in latest release: https://github.com/bgrabitmap/bgrabitmap/releases/tag/v11.6.3 Here is an example made by Gigatron: https://forum.lazarus.freepascal.org/index.php/topic,67755.msg522793.h tml#msg522793 If you have any question, I'll be happy to assist. Warm regards ---------------------------------------------------------------------- iLya2IK · 2024-08-08 05:25 Quote from: Boleeman on August 06, 2024, 01:17:48 pmThanks iLya2IK for your OpenGL fractal code example. I tried it, but get an error as the form loads up. GL Framebuffer error 36062 I tried compiling on an Intel and on an AMD CPU laptop (each running Windows 10). Perhaps I have the older version of OpenGL or need to compile on Linux ? Not sure. iLya2IK. I appreciate your upload. Always wanted to learn more about openGL and it's possibilites. Thank you for the opportunity to play with such a wonderful thing as fractal  Unfortunately, this is my mistake. If you want to run the program, try changing the line Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i e := glCheckFramebufferStatus(fb);to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i e := glCheckFramebufferStatus(GL_FRAMEBUFFER); The drivers on my computer allow such a mistake, but on your device they follow the specification more precisely. ---------------------------------------------------------------------- Boleeman · 2024-08-09 09:17 Hi iLya2IK I tried that change to:   //e := glCheckFramebufferStatus(fb);   e := glCheckFramebufferStatus(GL_FRAMEBUFFER); but I still get Access violation reading from address $00000000 GL_Framebuffer_Error 36053 Did some Googling and that code is for The framebuffer is complete I thing this might have something to do with needing to clear the color or depth glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); So perhaps need to clear the framebuffer somewhere? I don't know where? Sorry for the hassles. Not sure how to correct this error for Windows 10 OS? ---------------------------------------------------------------------- iLya2IK · 2024-08-09 11:43 Quote from: Boleeman on August 09, 2024, 11:17:15 amHi iLya2IK I tried that change to:   //e := glCheckFramebufferStatus(fb);   e := glCheckFramebufferStatus(GL_FRAMEBUFFER); but I still get Access violation reading from address $00000000 GL_Framebuffer_Error 36053 Did some Googling and that code is for The framebuffer is complete I thing this might have something to do with needing to clear the color or depth glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); So perhaps need to clear the framebuffer somewhere? I don't know where? Sorry for the hassles. Not sure how to correct this error for Windows 10 OS? Hello. That's ok  - just add this code to the switch-case statement: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure CheckFBStatus();var  e : glenum;begin  e := glCheckFramebufferStatus(GL_FRAMEBUFFER);  case e of  GL_FRAMEBUFFER_COMPLETE: begin // framebuffer ok    end; ---------------------------------------------------------------------- Boleeman · 2024-08-09 12:39 And eventually ... I SEE THE CURVES Thanks  iLya2IK for that extra help. Much appreciated. That OpenGL rendering on Win 10 OS looks nicely shaded. Groovey. Gave the TSpinedits larger variations.