MinVR  0.9.0
A multi-platform virtual reality library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AbstractMVREngine.H
Go to the documentation of this file.
1 //========================================================================
2 // MinVR
3 // Platform: Any
4 // API version: 1.0
5 //------------------------------------------------------------------------
6 // The MIT License (MIT)
7 //
8 // Copyright (c) 2013 Regents of the University of Minnesota
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy of
11 // this software and associated documentation files (the "Software"), to deal in
12 // the Software without restriction, including without limitation the rights to
13 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 // the Software, and to permit persons to whom the Software is furnished to do so,
15 // subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included in all
18 // copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //========================================================================
27 
28 #ifndef ABSTRACTMVRENGINE_H
29 #define ABSTRACTMVRENGINE_H
30 
31 #include "MVRCore/AbstractMVRApp.H"
32 #include "MVRCore/AbstractWindow.H"
33 #include "MVRCore/ConfigMap.H"
34 #include "MVRCore/ConfigVal.H"
35 #include "MVRCore/WindowSettings.H"
36 #include "MVRCore/AbstractCamera.H"
37 #include "MVRCore/CameraOffAxis.H"
44 #include "MVRCore/RenderThread.H"
45 #include "MVRCore/DataFileUtils.H"
46 #include "MVRCore/Event.H"
47 #include <glm/glm.hpp>
48 #include <boost/shared_ptr.hpp>
49 #include <boost/thread/mutex.hpp>
50 #include <boost/thread/condition_variable.hpp>
51 #include <boost/date_time/posix_time/posix_time.hpp>
52 #include <boost/make_shared.hpp>
53 #include <boost/log/core.hpp>
54 #include <boost/log/trivial.hpp>
55 #include <boost/log/sinks/sync_frontend.hpp>
56 #include <boost/log/sinks/text_ostream_backend.hpp>
57 #include <boost/log/utility/setup/common_attributes.hpp>
58 #include <boost/log/sources/logger.hpp>
59 #include <boost/log/sources/record_ostream.hpp>
60 #include <boost/log/utility/empty_deleter.hpp>
61 #include <boost/log/sources/severity_logger.hpp>
62 #include <boost/log/expressions.hpp>
63 #include <boost/log/utility/setup/file.hpp>
64 #include <vector>
65 #include <fstream>
66 #include <iostream>
67 #include <algorithm>
68 
69 #define BOOST_ASSERT_MSG_OSTREAM std::cout
70 #include <boost/assert.hpp>
71 
72 namespace MinVR {
73 
79 public:
80 
82  virtual ~AbstractMVREngine();
83 
89  virtual void init(int argc, char **argv);
90 
99  virtual void init(ConfigMapRef configMap);
100 
108  virtual void runApp(AbstractMVRAppRef app);
109 
117  virtual void runOneFrameOfApp(AbstractMVRAppRef app);
118 
126  virtual void initializeContextSpecificVars(int threadId, WindowRef window);
127 
132  virtual void initializeLogging();
133 
134 protected:
135 
142  virtual void setupWindowsAndViewports();
143 
153  virtual WindowRef createWindow(WindowSettingsRef settings, std::vector<AbstractCameraRef> cameras) = 0;
154 
161  virtual void setupInputDevices();
162 
168  virtual void setupRenderThreads();
169 
175  virtual void pollUserInput();
176 
181  virtual void updateProjectionForHeadTracking();
182 
185  std::vector<EventRef> _events;
186  std::vector<WindowRef> _windows;
187  std::vector<AbstractInputDeviceRef> _inputDevices;
188  std::vector<RenderThreadRef> _renderThreads;
190  boost::condition_variable _threadsInitializedCond;
191  boost::mutex _startRenderingMutex;
192  boost::condition_variable _startRenderingCond;
194  boost::condition_variable _renderingCompleteCond;
195  boost::shared_ptr<boost::barrier> _swapBarrier;
196  boost::posix_time::ptime _syncTimeStart;
197  unsigned long _frameCount;
198 };
199 
200 } // end namespace
201 
202 #endif
203 
204