Files

81 lines
1.5 KiB
C

#pragma once
#include <pthread.h>
struct vec3 {
double x, y, z;
};
typedef struct vec3 vec3;
struct triangle {
vec3 a, b, c;
vec3 normal;
}; typedef struct triangle triangle;
struct ray {
vec3 origin;
vec3 direction;
}; typedef struct ray ray;
struct camera {
vec3 origin;
vec3 direction;
double height;
double width;
double resolutionX;
double resolutionY;
double screenDistance;
}; typedef struct camera camera;
struct rgba {
double r, g, b, a;
}; typedef struct rgba RGBA;
struct sphere {
vec3 origin;
double radius;
RGBA color;
}; typedef struct sphere sphere;
struct plane {
vec3 origin;
vec3 normal;
}; typedef struct plane plane;
struct quad {
vec3 origin;
vec3 v1;
vec3 v2;
vec3 normal;
RGBA color;
}; typedef struct quad quad;
struct object {
int objectType; // 0 = sphere, 1 = Quad
void *objectPointer;
bool isLight;
}; typedef struct object object;
struct cube {
quad quad1,quad2,quad3,quad4,quad5,quad6;
}; typedef struct cube cube;
typedef struct {
//int pixelId;
object *objectList;
int objectCount;
int width;
int channels;
vec3 *screenTopLeft;
vec3 *vecPixelStepX;
vec3 *vecPixelStepY;
camera *cam1;
unsigned char **image;
int nextPixelId;
pthread_mutex_t mutexKey;
int pixelCount;
} RenderArgs;
typedef struct {
int *nextPixelId;
int pixelCount;
pthread_mutex_t *mutexKey;
} MonitorArgs;