#include "lighting.h" #include #include Light* light_create_dir(float r, float g, float b, float intensity, float dx, float dy, float dz) { Light* l = (Light*)calloc(1, sizeof(Light)); l->type = LIGHT_DIR; l->color[0] = r; l->color[1] = g; l->color[2] = b; l->intensity = intensity; l->direction[0] = dx; l->direction[1] = dy; l->direction[2] = dz; float len = sqrtf(dx*dx + dy*dy + dz*dz); if (len > 0.0001f) { l->direction[0] /= len; l->direction[1] /= len; l->direction[2] /= len; } return l; } Light* light_create_point(float r, float g, float b, float intensity, float x, float y, float z, float range) { Light* l = (Light*)calloc(1, sizeof(Light)); l->type = LIGHT_POINT; l->color[0] = r; l->color[1] = g; l->color[2] = b; l->intensity = intensity; l->position[0] = x; l->position[1] = y; l->position[2] = z; l->range = range; return l; } void light_destroy(Light* light) { free(light); }