X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fvideo.cc;fp=src%2Fmoof%2Fvideo.cc;h=263ea882bcfce6751078674436ffe155aa555aab;hp=aa49b03c249b9d2927d0b43e52adfd5a8a8b357b;hb=af88821a172c4dfd138b91b2a5148ae50b502fa2;hpb=d6990468d297a6cbee98e4d0d33ab37e1b2352c9 diff --git a/src/moof/video.cc b/src/moof/video.cc index aa49b03..263ea88 100644 --- a/src/moof/video.cc +++ b/src/moof/video.cc @@ -9,6 +9,7 @@ * **************************************************************************/ +#include #include #include "dispatcher.hh" @@ -54,6 +55,8 @@ void video::init() mode(attributes_.mode); if (!current_) make_current(); + + show_fps(false); } void video::recreate_context() @@ -158,14 +161,16 @@ bool video::iconify() void video::caption(const std::string& caption) { + caption_ = caption; SDL_WM_SetCaption(caption.c_str(), 0); } -std::string video::caption() const +const std::string& video::caption() const { - char* caption; - SDL_WM_GetCaption(&caption, 0); - return std::string(caption); + return caption_; + //char* caption; + //SDL_WM_GetCaption(&caption, 0); + //return std::string(caption); } @@ -261,8 +266,27 @@ void video::toggle_cursor_captured() } -void video::swap() +void video::swap(scalar t) { + if (show_fps_) + { + scalar dt = t - last_swap_; + last_swap_ = t; + + fps_accumulator_ += dt; + if (SCALAR(1.0) <= fps_accumulator_) + { + std::ostringstream stream; + stream << caption_ << " - " << fps_counter_ << " fps"; + SDL_WM_SetCaption(stream.str().c_str(), 0); + + fps_accumulator_ -= SCALAR(1.0); + fps_counter_ = 0; + } + + ++fps_counter_; + } + SDL_GL_SwapBuffers(); }