diff options
author | sanine-a <sanine.not@pm.me> | 2020-06-03 00:34:36 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2020-06-03 00:34:36 -0500 |
commit | 70784cdb24628e758df27cbe1965ff83102decb0 (patch) | |
tree | 46c4b223f63ff044161216dab9511ec8d8ce2192 /src/shader.c | |
parent | e1935b6f7af6d036eb15c75c2a98bf43805c48fc (diff) |
add multiple lights to shaders
Diffstat (limited to 'src/shader.c')
-rw-r--r-- | src/shader.c | 57 |
1 files changed, 57 insertions, 0 deletions
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); +} + |