- shaders for both lightmapped objects with or without albedo maps
[laserbrain_demo] / src / app.cc
index 9245f06..330241c 100644 (file)
@@ -25,6 +25,8 @@ float win_aspect;
 bool fb_srgb;
 bool opt_gear_wireframe;
 
+unsigned int sdr_ltmap, sdr_ltmap_notex;
+
 static float cam_dist = 0.0;
 static float cam_theta, cam_phi = 20;
 static Vec3 cam_pos;
@@ -44,7 +46,7 @@ static bool keystate[256];
 static Mat4 view_matrix, mouse_view_matrix, proj_matrix;
 static TextureSet texman;
 static Scene *scn;
-static unsigned int sdr, sdr_post_gamma;
+static unsigned int sdr_post_gamma;
 
 static long prev_msec;
 
@@ -106,12 +108,15 @@ bool app_init(int argc, char **argv)
                cam_pos = bcent + Vec3(0, user_eye_height, 0);
        }
 
-       if(!(sdr = create_program_load("sdr/test.v.glsl", "sdr/test.p.glsl"))) {
-               fprintf(stderr, "failed to load test shaders\n");
+       if(!(sdr_ltmap_notex = create_program_load("sdr/lightmap.v.glsl", "sdr/lightmap-notex.p.glsl"))) {
+               return false;
+       }
+
+       if(!(sdr_ltmap = create_program_load("sdr/lightmap.v.glsl", "sdr/lightmap-tex.p.glsl"))) {
                return false;
        }
-       set_uniform_int(sdr, "texmap", 0);
-       set_uniform_int(sdr, "lightmap", 1);
+       set_uniform_int(sdr_ltmap, "texmap", 0);
+       set_uniform_int(sdr_ltmap, "lightmap", 1);
 
        if(!fb_srgb) {
                sdr_post_gamma = create_program_load("sdr/post_gamma.v.glsl", "sdr/post_gamma.p.glsl");
@@ -295,9 +300,7 @@ static void draw_scene()
        set_light(1, lpos[1], Vec3(0.6, 0.7, 1.0) * 0.6);
        set_light(2, lpos[2], Vec3(0.8, 1.0, 0.8) * 0.3);
 
-       glUseProgram(sdr);
        scn->draw();
-       glUseProgram(0);
 
        if(show_walk_mesh && scn->walk_mesh) {
                glPushAttrib(GL_ENABLE_BIT);
@@ -337,8 +340,11 @@ void app_keyboard(int key, bool pressed)
                        app_quit();
                        break;
 
-               case 'f':
-                       app_toggle_fullscreen();
+               case '\n':
+               case '\r':
+                       if(mod & MOD_ALT) {
+                               app_toggle_fullscreen();
+                       }
                        break;
 
                case '`':
@@ -360,6 +366,23 @@ void app_keyboard(int key, bool pressed)
                        }
                        break;
 
+               case 'f':
+                       {
+                               static float prev_walk_speed = -1.0;
+                               if(prev_walk_speed < 0.0) {
+                                       noclip = true;
+                                       prev_walk_speed = walk_speed;
+                                       walk_speed = 1000.0;
+                                       show_message("fly mode\n");
+                               } else {
+                                       noclip = false;
+                                       walk_speed = prev_walk_speed;
+                                       prev_walk_speed = -1.0;
+                                       show_message("walk mode\n");
+                               }
+                       }
+                       break;
+
                case 'p':
                        if(mod & MOD_CTRL) {
                                fb_srgb = !fb_srgb;