From f030154fe727e25a2afe1f78b3998c2d2dba95e4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 18 Aug 2009 09:24:15 +0000 Subject: astyle cleanup, corrects not loading of material textures --- src/client/video.cc | 104 ++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 51 deletions(-) (limited to 'src/client/video.cc') diff --git a/src/client/video.cc b/src/client/video.cc index 4ad1c97..9e9d553 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -1,7 +1,7 @@ /* client/video.cc - This file is part of the Osirion project and is distributed under - the terms and conditions of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms and conditions of the GNU General Public License version 2 */ #include "client/video.h" @@ -21,7 +21,8 @@ using namespace render; -namespace client { +namespace client +{ /* -- engine variables --------------------------------------------- */ @@ -34,7 +35,8 @@ core::Cvar *draw_stats = 0; core::Cvar *draw_devinfo = 0; core::Cvar *draw_keypress = 0; -namespace video { +namespace video +{ float fullscreen = 0; @@ -53,7 +55,7 @@ const int height_default = 768; std::string loader_message; bool is_loading = false; -bool init() +bool init() { con_print << "^BInitializing video..." << std::endl; @@ -79,7 +81,7 @@ bool init() draw_ui = core::Cvar::get("draw_ui", "1", core::Cvar::Archive); draw_ui->set_info("[bool] draw the user interface"); - if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 ) { + if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { con_error << "SDL_InitSubSystem() failed: " << SDL_GetError() << std::endl; return false; } @@ -97,12 +99,12 @@ bool init() if (image) { Uint32 colorkey = SDL_MapRGB(image->format, 255, 0, 255); SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey); - SDL_WM_SetIcon(image,NULL); + SDL_WM_SetIcon(image, NULL); } } const SDL_VideoInfo* sdl_videoinfo = SDL_GetVideoInfo(); - if( !sdl_videoinfo) { + if (!sdl_videoinfo) { con_error << "SDL_GetVideoInfo() failed: " << SDL_GetError() << std::endl; return false; } @@ -115,25 +117,25 @@ bool init() bpp = sdl_videoinfo->vfmt->BitsPerPixel; 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); + 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); + 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); + 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); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); fullscreen = r_fullscreen->value(); if (r_fullscreen->value()) { @@ -145,12 +147,12 @@ bool init() #endif } - if(!SDL_SetVideoMode(width, height, bpp, flags )) { + if (!SDL_SetVideoMode(width, height, bpp, flags)) { con_warn << "Failed to set video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl; if (width_prev && height_prev) { width = width_prev; height = height_prev; - if(!SDL_SetVideoMode(width, height, bpp, flags )) { + if (!SDL_SetVideoMode(width, height, bpp, flags)) { con_error << "Failed to restore video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl; return false; } @@ -163,11 +165,11 @@ bool init() 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); + 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; @@ -198,7 +200,7 @@ bool init() // apply render options ui::root()->apply_render_options(); - + // initialize target drawer targets::init(); @@ -222,8 +224,8 @@ void resize(int w, int h) if (w < 320) w = 320; if (h < 200) h = 200; - - if (SDL_SetVideoMode(w, h, bpp, flags )) { + + if (SDL_SetVideoMode(w, h, bpp, flags)) { render::resize(w, h); ui::root()->set_size(w, h); ui::root()->event_resize(); @@ -247,7 +249,7 @@ void set_cursor() if (ui::console()->visible()) { ui::root()->set_pointer(); - } else if(core::localplayer()->view() || ui::root()->active()) { + } else if (core::localplayer()->view() || ui::root()->active()) { ui::root()->set_pointer("pointer"); @@ -268,7 +270,7 @@ void set_cursor() ui::root()->set_pointer("target", ui::Palette::Active, true); if (input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) { - ui::root()->input_mouse(render::State::width()/2, render::State::height() /2); + ui::root()->input_mouse(render::State::width() / 2, render::State::height() / 2); } } else if (input::mouse_control) { @@ -276,11 +278,11 @@ void set_cursor() ui::root()->set_pointer("control", ui::Palette::Pointer); if (input::mouse_deadzone) { - ui::root()->input_mouse(render::State::width()/2, render::State::height() /2); + ui::root()->input_mouse(render::State::width() / 2, render::State::height() / 2); } - } else if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) && - (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) { + } else if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) && + (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) { ui::root()->set_pointer(); @@ -293,7 +295,7 @@ void set_cursor() void set_loader_message(const std::string message) { loader_message.assign(message); - + if (is_loading) frame_loader(); } @@ -304,7 +306,7 @@ void set_loader_message(const char *message) loader_message.assign(message); else loader_message.clear(); - + if (is_loading) frame_loader(); } @@ -312,7 +314,7 @@ void set_loader_message(const char *message) void draw_loader() { render::Camera::ortho(); - + gl::enable(GL_BLEND); gl::color(1.0f, 1.0f, 1.0f, 1.0f); @@ -322,7 +324,7 @@ void draw_loader() if (loader_message.size()) { using render::Text; - gl::enable(GL_TEXTURE_2D); + gl::enable(GL_TEXTURE_2D); Text::setfont("gui", 12, 18); Text::setcolor('N'); //set normal color Text::draw(Text::fontwidth(), Text::fontheight(), loader_message); @@ -330,7 +332,7 @@ void draw_loader() } gl::disable(GL_BLEND); - + is_loading = true; } @@ -338,9 +340,9 @@ void frame_loader() { // Clear the color and depth buffers. gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - + draw_loader(); - + SDL_GL_SwapBuffers(); } @@ -351,15 +353,15 @@ void frame(float elapsed) restart(); using namespace render; - + is_loading = false; - + // Clear the color and depth buffers. gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); render::Stats::clear(); if (core::application()->connected()) { - + if (core::game()->time() && core::localplayer()->zone()) { render::Camera::frame(elapsed); render::Camera::frustum(); @@ -372,12 +374,12 @@ void frame(float elapsed) render::Camera::ortho(); client()->worldview()->show(); - + } else { draw_loader(); client()->worldview()->hide(); } - + } else { client()->worldview()->hide(); render::Camera::ortho(); @@ -398,17 +400,17 @@ void frame(float elapsed) ui::console()->event_draw(); } - + gl::disable(GL_TEXTURE_2D); gl::disable(GL_BLEND); - + SDL_GL_SwapBuffers(); } void shutdown() { con_print << "^BShutting down video..." << std::endl; - + targets::shutdown(); render::shutdown(); -- cgit v1.2.3