do gamma correction on post if we don't have an sRGB framebuffer
[laserbrain_demo] / src / main.cc
index 01c9d12..fb8a2e2 100644 (file)
@@ -41,7 +41,11 @@ int main(int argc, char **argv)
                        SDL_Quit();
                        return 1;
                }
+               fprintf(stderr, "failed to get an sRGB framebuffer.\n");
        }
+       int val;
+       SDL_GL_GetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, &val);
+       printf("SDL says we %s an sRGB framebuffer\n", val ? "got" : "didn't get");
 
        if(!(ctx = SDL_GL_CreateContext(win))) {
                fprintf(stderr, "failed to create OpenGL context\n");
@@ -113,8 +117,11 @@ bool app_is_fullscreen()
 
 void app_grab_mouse(bool grab)
 {
-       SDL_SetWindowGrab(win, grab ? SDL_TRUE : SDL_FALSE);
-       SDL_ShowCursor(grab ? 1 : 0);
+       if(grab) {
+               SDL_WarpMouseInWindow(win, win_width / 2, win_height / 2);
+       }
+       //SDL_SetWindowGrab(win, grab ? SDL_TRUE : SDL_FALSE);
+       //SDL_ShowCursor(grab ? 1 : 0);
        SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE);
        mouse_grabbed = grab;
 }
@@ -164,7 +171,8 @@ static void process_event(SDL_Event *ev)
 
        case SDL_MOUSEMOTION:
                if(mouse_grabbed) {
-                       app_mouse_delta(ev->motion.xrel, ev->motion.yrel);
+                       // XXX xrel/yrel seems faster by default
+                       app_mouse_delta(ev->motion.xrel * 0.5, ev->motion.yrel * 0.5);
                } else {
                        app_mouse_motion(ev->motion.x * scale_factor, ev->motion.y * scale_factor);
                }