I am using Qt to build a ray tracer with GUI. The ideal effect is to paint a pixel immediately after computing the RGB value of that pixel, as in most professional renderer. But I find out that my tracer could only display the entire rendered image after the loop below:
for(int i=0; i<row; ++i)
for(int j=0; j<column; ++j) {
compute pixel value;
painter.drawPoint(i, j);
}
I am drawing to the central widget of the mainwindow. I reimplemented QWidget paintEvent function and put the loop above in this function. It seems that paintEvent only display the whole screen after being executed once and in the process it gives me this:
I don't know if this is just how paintEvent works or I am doing something wrong.
Anyway, it cannot display pixel in real time. And this is very unsatisfying for an interactive tracer. I hope you guys can provide some explanations and/or solutions. A million thanks!