X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fapp.cc;h=9245f06bf8adc627fea00361fc2303397b87301d;hp=d3b565763cdafb0b23015ebd1a239a9421aaf7fa;hb=31e1ffedb543e048673b7ba969607fbb8214ac9a;hpb=c5c29f4044110dd153ee5ca3b018c812d518a053 diff --git a/src/app.cc b/src/app.cc index d3b5657..9245f06 100644 --- a/src/app.cc +++ b/src/app.cc @@ -12,6 +12,7 @@ #include "datamap.h" #include "ui.h" #include "opt.h" +#include "post.h" #define NEAR_CLIP 5.0 #define FAR_CLIP 10000.0 @@ -21,6 +22,7 @@ static void draw_scene(); long time_msec; int win_width, win_height; float win_aspect; +bool fb_srgb; bool opt_gear_wireframe; static float cam_dist = 0.0; @@ -30,6 +32,7 @@ static float floor_y; // last floor height static float user_eye_height = 165; static float walk_speed = 300.0f; +static float mouse_speed = 1.0f; static bool show_walk_mesh, noclip = false; static bool have_headtracking, should_swap; @@ -41,7 +44,7 @@ static bool keystate[256]; static Mat4 view_matrix, mouse_view_matrix, proj_matrix; static TextureSet texman; static Scene *scn; -static unsigned int sdr; +static unsigned int sdr, sdr_post_gamma; static long prev_msec; @@ -69,7 +72,12 @@ bool app_init(int argc, char **argv) goatvr_recenter(); } + int srgb_capable; + glGetIntegerv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgb_capable); + printf("Framebuffer %s sRGB-capable\n", srgb_capable ? "is" : "is not"); + fb_srgb = srgb_capable != 0; glEnable(GL_FRAMEBUFFER_SRGB); + glEnable(GL_MULTISAMPLE); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); @@ -105,6 +113,10 @@ bool app_init(int argc, char **argv) set_uniform_int(sdr, "texmap", 0); set_uniform_int(sdr, "lightmap", 1); + if(!fb_srgb) { + sdr_post_gamma = create_program_load("sdr/post_gamma.v.glsl", "sdr/post_gamma.p.glsl"); + } + glUseProgram(0); if(opt.vr || opt.fullscreen) { @@ -266,6 +278,10 @@ void app_display() draw_scene(); + if(!fb_srgb && sdr_post_gamma) { + slow_post(sdr_post_gamma); + glUseProgram(0); + } app_swap_buffers(); } assert(glGetError() == GL_NO_ERROR); @@ -344,6 +360,13 @@ void app_keyboard(int key, bool pressed) } break; + case 'p': + if(mod & MOD_CTRL) { + fb_srgb = !fb_srgb; + show_message("gamma correction for non-sRGB framebuffers: %s\n", fb_srgb ? "off" : "on"); + } + break; + case '=': walk_speed *= 1.25; show_message("walk speed: %g", walk_speed); @@ -353,6 +376,16 @@ void app_keyboard(int key, bool pressed) walk_speed *= 0.75; show_message("walk speed: %g", walk_speed); break; + + case ']': + mouse_speed *= 1.2; + show_message("mouse speed: %g", mouse_speed); + break; + + case '[': + mouse_speed *= 0.8; + show_message("mouse speed: %g", mouse_speed); + break; } } @@ -370,8 +403,9 @@ void app_mouse_button(int bn, bool pressed, int x, int y) static inline void mouse_look(int dx, int dy) { - cam_theta += dx * 0.5; - cam_phi += dy * 0.5; + float scrsz = (float)win_height; + cam_theta += dx * 512.0 / scrsz; + cam_phi += dy * 512.0 / scrsz; if(cam_phi < -90) cam_phi = -90; if(cam_phi > 90) cam_phi = 90; @@ -403,8 +437,8 @@ void app_mouse_motion(int x, int y) void app_mouse_delta(int dx, int dy) { if(bnstate[2]) { - mouse_zoom(dx, dy); + mouse_zoom(dx * mouse_speed, dy * mouse_speed); } else { - mouse_look(dx, dy); + mouse_look(dx * mouse_speed, dy * mouse_speed); } }