*
**************************************************************************/
+#include <sstream>
#include <stdexcept>
#include "dispatcher.hh"
mode(attributes_.mode);
if (!current_) make_current();
+
+ show_fps(false);
}
void video::recreate_context()
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);
}
}
-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();
}