Reputation: 3337
I have a function that calculates a basic Julia fractal. It works fine and I can show it in a SDL window. it works as I expect. However I want to be able to see the Julia fractal while is it being created.
The fractal is calculated in a simple forx,fory fashion. So it is not a recursive function. At the end of the loop I color the pixels and draw the ones that are in the range of the Julia description. The pixel drawing writes to the main Sdl surface *screen.
Is there a way to display an ongoing calculation in an SDL app? I want to be able to see the progression of the image. I realize that this might require a different type of programming approach. I am just trying to figure out what my options are.
Upvotes: 1
Views: 329
Reputation: 726
the easiest way is to display your image after each pixel or each row of your calculation. Optionally you can only update your image if the time since the last update is larger than a given minimum value (e.g. 1/60.0 s)
A more complicated solution would be to separate rendering and computation into separate threads. This offers various advantages: The actual computation is not intermingled with the rendering part and the display (and other UI-related functions) does not depend on the computation speed.
Upvotes: 1