I have the following function which draws a grid of pixels on the window, I'm using sdl.
The problem is that is very slow! It makes my program to run at 10fps, so I think Im must be doing something wrong.
This is the code I'm using
void rayTracing(SDL &sdl) {
int nx = 1440;
int ny = 810;
for (int x = 0; x < nx; x++) {
for (int y = 0; y < ny; y++) {
float r = float(x) / float(nx);
float g = float(y) / float(ny);
float b = 0.2;
int ir = int(255.99 * r);
int ig = int(255.99 * g);
int ib = int(255.99 * b);
SDL_SetRenderDrawColor(sdl.renderer.get(), ir, ig, ib, 255);
SDL_RenderDrawPoint(sdl.renderer.get(), x, ny - y);
}
}
SDL_SetRenderDrawColor(sdl.renderer.get(), 0, 0, 0, 0);
}
Maybe the problem is the way I use SDL_RenderDrawPoint?