demo update

main
Dominik Madarász 2024-08-29 20:51:44 +02:00
parent 6319b11df6
commit d219cb88a3
1 changed files with 26 additions and 2 deletions

View File

@ -60,6 +60,12 @@ int main(int argc, char** argv) {
array(light_t) directional_lights = 0; array(light_t) directional_lights = 0;
array_push(directional_lights, lit4); array_push(directional_lights, lit4);
array(light_t) all_lights = 0;
array_push(all_lights, lit);
array_push(all_lights, lit2);
array_push(all_lights, lit3);
array_push(all_lights, lit4);
bool initialized = 0; bool initialized = 0;
bool must_reload = 0; bool must_reload = 0;
@ -92,19 +98,20 @@ int main(int argc, char** argv) {
camera_fps(&cam, mouse.x,mouse.y); camera_fps(&cam, mouse.x,mouse.y);
enum { enum {
POINT, SPOT, DIR POINT, SPOT, DIR, ALL
}; };
static unsigned mode = POINT; static unsigned mode = POINT;
if (input_down(KEY_1)) mode = POINT; if (input_down(KEY_1)) mode = POINT;
if (input_down(KEY_2)) mode = SPOT; if (input_down(KEY_2)) mode = SPOT;
if (input_down(KEY_3)) mode = DIR; if (input_down(KEY_3)) mode = DIR;
if (input_down(KEY_4)) mode = ALL;
light_t *lights = 0; light_t *lights = 0;
switch (mode) { switch (mode) {
case POINT: lights = point_lights; break; case POINT: lights = point_lights; break;
case SPOT: lights = spot_lights; break; case SPOT: lights = spot_lights; break;
case DIR: lights = directional_lights; break; case DIR: lights = directional_lights; break;
case ALL: lights = all_lights; break;
} }
// Animate light // Animate light
@ -131,6 +138,23 @@ int main(int argc, char** argv) {
lights[0].dir = vec3(1,-1,-1); lights[0].dir = vec3(1,-1,-1);
} }
if (mode == ALL) {
lights[0].pos = vec3(0, 5.5, 1);
lights[0].pos.x += sinf(window_time()*2)*4.5f;
lights[0].pos.y += cosf(window_time()*2)*1.0;
lights[0].pos.z += cosf(window_time()*2)*6.0;
lights[1].pos = vec3(0, 7.5, 1);
lights[1].pos.x += sinf(window_time()*4)*4.5f;
lights[1].pos.y += cosf(window_time()*4)*1.0;
lights[1].pos.z += cosf(window_time()*4)*6.0;
lights[2].pos = cam.position;
lights[2].dir = cam.lookdir;
lights[3].dir = vec3(1,-1,-1);
}
// Render shadowmap // Render shadowmap
shadowmap_begin(&sm); shadowmap_begin(&sm);
{ {