summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/light.c20
-rw-r--r--src/shader.c57
2 files changed, 77 insertions, 0 deletions
diff --git a/src/light.c b/src/light.c
new file mode 100644
index 0000000..08da8e6
--- /dev/null
+++ b/src/light.c
@@ -0,0 +1,20 @@
+#include "../include/light.h"
+
+void honey_point_light_new(honey_point_light* light,
+ float x, float y, float z,
+ float r, float g, float b,
+ float constant,
+ float linear,
+ float quadratic) {
+ light->position[0] = x;
+ light->position[1] = y;
+ light->position[2] = z;
+
+ light->color[0] = r;
+ light->color[1] = g;
+ light->color[2] = b;
+
+ light->constant = constant;
+ light->linear = linear;
+ light->quadratic = quadratic;
+}
diff --git a/src/shader.c b/src/shader.c
index d250629..d570f52 100644
--- a/src/shader.c
+++ b/src/shader.c
@@ -164,4 +164,61 @@ void honey_shader_set_mat4(honey_shader shader,
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+void honey_shader_set_point_light(honey_shader shader,
+ int point_light_index,
+ honey_point_light light) {
+ char name[HONEY_MAX_LIGHT_NAME_LENGTH];
+
+ snprintf(name,
+ HONEY_MAX_LIGHT_NAME_LENGTH,
+ "point_lights[%d].position",
+ point_light_index);
+ honey_shader_set_vec3(shader, name, light.position);
+
+ snprintf(name,
+ HONEY_MAX_LIGHT_NAME_LENGTH,
+ "point_lights[%d].color",
+ point_light_index);
+ honey_shader_set_vec3(shader, name, light.color);
+
+ snprintf(name,
+ HONEY_MAX_LIGHT_NAME_LENGTH,
+ "point_lights[%d].constant",
+ point_light_index);
+ honey_shader_set_float(shader, name, light.constant);
+
+ snprintf(name,
+ HONEY_MAX_LIGHT_NAME_LENGTH,
+ "point_lights[%d].linear",
+ point_light_index);
+ honey_shader_set_float(shader, name, light.linear);
+
+ snprintf(name,
+ HONEY_MAX_LIGHT_NAME_LENGTH,
+ "point_lights[%d].quadratic",
+ point_light_index);
+ honey_shader_set_float(shader, name, light.quadratic);
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+void honey_shader_set_directional_light(honey_shader shader,
+ int directional_light_index,
+ honey_directional_light light) {
+ char name[HONEY_MAX_LIGHT_NAME_LENGTH];
+
+ snprintf(name,
+ HONEY_MAX_LIGHT_NAME_LENGTH,
+ "directional_lights[%d].direction",
+ directional_light_index);
+ honey_shader_set_vec3(shader, name, light.direction);
+
+ snprintf(name,
+ HONEY_MAX_LIGHT_NAME_LENGTH,
+ "directional_lights[%d].color",
+ directional_light_index);
+ honey_shader_set_vec3(shader, name, light.color);
+}
+