35 lines
650 B
C
35 lines
650 B
C
#include "camera.h"
|
|
#include "ff.h"
|
|
#include "obj.h"
|
|
#include "rng.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
#define W 800
|
|
#define H 600
|
|
#define FOCAL_LEN 1.0
|
|
#define VIEWPORT_H 2.0
|
|
|
|
#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
|
|
|
|
static const vec3_t camera_pos = { 0.0, 0.0, 0.0 };
|
|
|
|
static const obj_t scene[] = {
|
|
SPHERE(1.0, 0.0, -3.0, 1.0),
|
|
SPHERE(-2.0, -0.5, -5.0, 1.0),
|
|
SPHERE(0.0, -1001.0, 0.0, 1000.0),
|
|
};
|
|
|
|
static pix_t pixbuf[W * H];
|
|
|
|
int main()
|
|
{
|
|
img_t img = { .pix = pixbuf };
|
|
camera_t camera = camera_init(camera_pos, FOCAL_LEN, VIEWPORT_H, W, H);
|
|
camera_render(&camera, scene, NELEMS(scene), &img);
|
|
|
|
ff_write(STDOUT_FILENO, img);
|
|
|
|
return 0;
|
|
}
|