Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-04 18:42:05 +0000
committerStijn Buys <ingar@osirion.org>2008-02-04 18:42:05 +0000
commit151a2ac2434f4b4c23c107d9c21e4a18dd1a3c68 (patch)
tree18154b52b44327de28d82ff187f25c8369ddc5d9 /src/client/video.cc
parent09fb43f3d36847977ac202c10c5a11f34af03a43 (diff)
converted client:: singleton classes to namespaces
Diffstat (limited to 'src/client/video.cc')
-rw-r--r--src/client/video.cc69
1 files changed, 34 insertions, 35 deletions
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
+