Few months ago I coded in C++ a (high quality) zen photon ripoff, and I want to start over from the scratch. Was quite fun and I managed to get some nice results. The biggest performance bottleneck was the line drawing part, since I need to draw millions of lines to "trace the rays".
I ended up using Micah Elizabeth Scott's code directly for her github, which was faster than all methods I tried. But I was wondering how I could draw lines even faster. The thing is, not only I need to draw millions of lines, but I need to "add them up".
My program was divided into two main tasks. The first consisted in randomly casting rays from the light sources, calculating intersections with objects, bouncing them, etc.
The second part was drawing the lines. The final image was represented as a simple double vector (3x64 bits for each pixel), and drawing a line consisted in adding values to this vector. Concretely when I used the Bresenham algorithm, I made +=1 to the cells of the vector that corresponded to the pixels by which the line passes.
The image was rendered by mapping the values of this array to [0,255]. I could then play with the brightness, make gamma corrections etc.
I tried OpenGL and Cairo demo codes to draw lines. But I couldn't get the behavior I wanted: adding lines in a pixel array (or surface or buffer or whatever) with good precision, and then rendering the image from that array.
Do you have any ideas on how I could quickly draw lines over each other so that I could manipulate them as I just describe?