From f540e8dac10de8ff443692e78404b1508dde9d1e Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 8 Aug 2008 18:47:04 +0000 Subject: beter video settings --- src/client/video.cc | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'src/client/video.cc') diff --git a/src/client/video.cc b/src/client/video.cc index ceea25d..5a4e535 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -86,15 +86,32 @@ bool init() bpp = sdl_videoinfo->vfmt->BitsPerPixel; - SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); - SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ); - SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); - SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 2); - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + if (bpp == 32) { + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8); + } else if (bpp == 24) { + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 6); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 6); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 6); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 6); + } else if (bpp == 16) { + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 4); + } else { + con_warn << "Display depth " << bpp << " is not supported!" << std::endl; + } + + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1); - if (r_fullscreen->value()) flags = SDL_OPENGL | SDL_FULLSCREEN; - else flags = SDL_OPENGL; + if (r_fullscreen->value()) { + flags = SDL_OPENGL | SDL_FULLSCREEN; + } else { + flags = SDL_OPENGL; + } if(!SDL_SetVideoMode(width, height, bpp, flags )) { con_warn << "Failed to set video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl; @@ -109,6 +126,15 @@ bool init() return false; } con_print << " video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl; + int red, green, blue, alpha, depth; + + SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &red); + SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &green); + SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &blue); + SDL_GL_GetAttribute( SDL_GL_ALPHA_SIZE, &alpha); + SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &depth); + + con_debug << " visual r: " << red << " g: " << green << " blue: " << blue << " alpha: " << alpha << " depth: " << depth << std::endl; render::Camera::set_aspect(width, height); (*r_width) = width; -- cgit v1.2.3