~brandontschaefer/+junk/sdl-bouncy-ball

« back to all changes in this revision

Viewing changes to src/sdl_backend/MainLoop.cpp

  • Committer: Brandon Schaefer
  • Date: 2014-04-25 20:44:47 UTC
  • Revision ID: brandontschaefer@gmail.com-20140425204447-zhdk6gbcy2hsc1m4
* Use try/catch over main loop to catch any errors, and report them
* Add new font

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
MainLoop::MainLoop(std::string title, int width, int height)
42
42
  : world_(std::make_shared<World>(Rect(0, 0, width, height)))
43
43
{
44
 
  try
45
 
  {
46
 
    InitSDL();
47
 
    graphics_.Init(title, width, height);
48
 
  }
49
 
  catch (std::runtime_error const& e)
50
 
  {
51
 
    std::cerr << "Caught runtime error: " << e.what() << std::endl;
52
 
  }
 
44
  InitSDL();
 
45
  graphics_.Init(title, width, height);
53
46
}
54
47
 
55
48
MainLoop::~MainLoop()
159
152
 
160
153
void MainLoop::StartMainLoop()
161
154
{
 
155
  try
 
156
  {
 
157
    RunLoop();
 
158
  }
 
159
  catch (std::runtime_error const& e)
 
160
  {
 
161
    std::cerr << "Caught runtime error: " << e.what() << std::endl;
 
162
  }
 
163
}
 
164
 
 
165
void MainLoop::RunLoop()
 
166
{
162
167
  float delta_time = 0.0f;
163
168
  bool done = false;
164
169
  SDLTimer fps;