X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmain.c;h=f0588c01f5ad12dc41223a3981ce6cd2bdc30d2c;hb=21180fdf54f0c578af0959df088de308ce25ca61;hp=8881963284eea003037c2ae5769b9ab6d28f5edc;hpb=6c34c443c62d0b40c91aee5f28985ee99c944caa;p=fbgfx diff --git a/src/main.c b/src/main.c index 8881963..f0588c0 100644 --- a/src/main.c +++ b/src/main.c @@ -20,17 +20,26 @@ static int quit; int main(void) { + int i, trybpp[] = {32, 24, 16, 0}; + fbgfx_save_video_mode(); fbgfx_get_video_mode(&xsz, &ysz, &depth); - if(!(vmem = fbgfx_set_video_mode(xsz, ysz, 16))) { - return 1; + for(i=0; trybpp[i]; i++) { + if(!(vmem = fbgfx_set_video_mode(xsz, ysz, trybpp[i]))) { + continue; + } + fbgfx_get_video_mode(&xsz, &ysz, &depth); + if(depth == trybpp[i]) { + break; + } + fprintf(stderr, "failed to set color depth: %dbpp\n", trybpp[i]); } - fbgfx_get_video_mode(&xsz, &ysz, &depth); - if(depth != 16) { - fprintf(stderr, "failed to set color depth: 16bpp\n"); + if(trybpp[i] == 0) { + fprintf(stderr, "no usable color depths found\n"); goto end; } + if(fbev_init() == -1) { goto end; } @@ -38,7 +47,7 @@ int main(void) fbev_mbutton(mouse, 0); fbev_mmotion(motion, 0); - if(init_tunnel(xsz, ysz) == -1) { + if(init_tunnel(xsz, ysz, depth) == -1) { goto end; }