From 151a2ac2434f4b4c23c107d9c21e4a18dd1a3c68 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 4 Feb 2008 18:42:05 +0000 Subject: converted client:: singleton classes to namespaces --- src/client/video.cc | 69 ++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'src/client/video.cc') diff --git a/src/client/video.cc b/src/client/video.cc index bfff445..47e9dde 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -14,51 +14,43 @@ using namespace render; namespace client { -Video::Video() -{ - width = 0; - height = 0; - initialized = false; - ratio = 1; -} - -Video::~Video() -{ -} - -void Video::reset() -{ - ratio = (float) width / (float) height; +namespace video { +const int defaultwidth = 1024; +const int defaultheight = 768; +int width = 0; +int height = 0; +float aspect = 1; - // Set the clear color - gl::clearcolor( 0, 0, 0, 0 ); +void reset() +{ + // recalculate the video aspect + aspect = (float) width / (float) height; - // Setup our viewport. + // settup our viewport. gl::viewport(0, 0, width, height ); - view.reset(); + // reset the view + view::reset(); } -void Video::init() +bool init() { - if (initialized) { - return; - } + con_print << "Initializing video..." << std::endl; int bpp = 0; int flags = 0; if( SDL_Init(SDL_INIT_VIDEO) < 0 ) { std::cerr << "SDL_Init() failed: " << SDL_GetError() << std::endl; - return; + return false; } const SDL_VideoInfo* sdl_videoinfo = SDL_GetVideoInfo(); if( !sdl_videoinfo) { std::cerr << "SDL_GetVideoInfo() failed: " << SDL_GetError() << std::endl; - return; + return false; } width = 1024; @@ -76,33 +68,40 @@ void Video::init() if(!SDL_SetVideoMode(width, height, bpp, flags )) { std::cerr << "SDL_SetVideoMode() failed: " << SDL_GetError() << std::endl; - return; + return false; } + aspect = (float) width / (float) height; + con_print << " video mode " << width << "x" << height << "x" << bpp << "bpp" << std::endl; + render::init(); + view::init(); - initialized = true; - view.init(); + video::reset(); - reset(); - return; + return true; } -void Video::frame(float seconds) +void frame(float seconds) { - view.frame(seconds); + // render a client frame + view::frame(seconds); SDL_GL_SwapBuffers(); } -void Video::shutdown() +void shutdown() { - view.shutdown(); + con_print << "Shutting down video..." << std::endl; + + view::shutdown(); render::shutdown(); - initialized = false; width = 0; height = 0; } +} // namespace video + } // namespace client + -- cgit v1.2.3