That isn't a fixed-sized array since n_spheres is a variable.
pixel_array is also obviously variable-sized.
You should be getting warnings about variable-sized arrays being forbidden in standard C++.
I don't understand why you want to pass it as a reference.
Code:
#include <iostream>
using namespace std;
struct Vec3f {
float x,y,z;
};
struct Image {
int height, width, bpp;
};
struct Camera {
Vec3f origin;
Vec3f dir;
};
struct Sphere {
Vec3f origin;
Vec3f normal;
float radius;
};
void trace(const Image& image, const Sphere sphere_array[]) {
auto pixel_array = new unsigned char[image.height * image.width * image.bpp];
Camera camera { {512, 384, 0}, {0, 0, 1} };
for (int y = 0; y < image.height; y++) {
for (int x = 0; y < image.width; y++) {
camera.dir = {float(x), float(y), 1};
for (int z = 0; z < 3; z++) {
}
}
}
delete[] pixel_array;
}
int main() {
Image image = {768, 1024, 4};
const int n_spheres = 3;
Sphere sphere_array[n_spheres] = {
{ {700, 700, 100}, {0, 0, 0}, 100 },
{ {300, 300, 100}, {0, 0, 0}, 100 },
{ {500, 500, 100}, {0, 0, 0}, 100 }
};
trace (image, sphere_array);
}