VIZ++ Class: OpenGLTimerThread

 VIZ++ Class Library  VIZ++ Samples  VIZ++ ClassTree 

Source code

/*
 * OpenGLTimerThread.h 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */



// 2016/02/22 

#include <viz++/Thread.h>
#include <viz++/Mutex.h>
#include <viz++/CriticalSection.h>

#include <viz++/opengl/OpenGLIView.h>

namespace VIZ {
  
class OpenGLTimerThread : public Thread {
private:
  OpenGLIView*       openglView;
  int               renderingInterval;
  bool              looping;
  
public:
  OpenGLTimerThread(__in OpenGLIView* view, int interval)
  :openglView(view),
  renderingInterval(interval),
  looping(true)
  {
    if (view == NULL) {
      throw IException("Invalid view parameter.");
    } else {
      openglView = view;
    }
  }
    
public:
  ~OpenGLTimerThread()
  {
    looping = false;
    Sleep(renderingInterval+1);
  }

public:
  void terminate()
  {
    looping = false;
  }
  
public:
  //Thread main procedure which will be started  by Thread::start() method.
  virtual void run()
  {
    looping = true;
    while (looping) {
      Sleep(renderingInterval);

      openglView ->postRenderRequest();
     // openglView ->postResizeRequest();
    }
  }
};
  
}
  

Last modified: 10 Feb 2017

Copyright (c) 2009-2017 Antillia.com ALL RIGHTS RESERVED.